All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: "Anthony PERARD" <anthony.perard@citrix.com>,
	"Jan Beulich" <jbeulich@suse.com>,
	"Andrew Cooper" <andrew.cooper3@citrix.com>,
	"Roger Pau Monné" <roger.pau@citrix.com>, "Wei Liu" <wl@xen.org>
Subject: [XEN PATCH v7 17/51] build: set XEN_BUILD_EFI earlier
Date: Tue, 24 Aug 2021 11:50:04 +0100	[thread overview]
Message-ID: <20210824105038.1257926-18-anthony.perard@citrix.com> (raw)
In-Reply-To: <20210824105038.1257926-1-anthony.perard@citrix.com>

We are going to need the variable XEN_BUILD_EFI earlier.

But a side effect of calculating the value of $(XEN_BUILD_EFI) is to
also to generate "efi/check.o" which is used for further checks.
Thus the whole chain that check for EFI support is moved to
"arch.mk".

Some other changes are made to avoid too much duplication:
    - $(efi-check-o): Used to avoid repeating "efi/check.*". We don't
      set it to the path to the source as it would be wrong as soon
      as we support out-of-tree build.
    - $(LD_PE_check_cmd): As it is called twice, with an updated
      $(EFI_LDFLAGS).

$(nr-fixups) is renamed to $(efi-check-relocs) as the former might be
a bit too generic.

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v7:
    - Do the whole check for EFI support in arch.mk. So efi/check.o is
      produce there and used there, and produce efi/check.efi and use it there.
      Thus avoid the need to repeat the test done for XEN_BUILD_EFI.

 xen/arch/x86/Makefile | 36 ++----------------------------------
 xen/arch/x86/arch.mk  | 42 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 34 deletions(-)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index 5e1d38d6cd5b..dfcbd01bb4ed 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -123,41 +123,7 @@ $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
 	mv $(TMP) $(TARGET)
 
 ifneq ($(efi-y),)
-
-# Check if the compiler supports the MS ABI.
-export XEN_BUILD_EFI := $(shell $(CC) $(XEN_CFLAGS) -c efi/check.c -o efi/check.o 2>/dev/null && echo y)
 CFLAGS-$(XEN_BUILD_EFI) += -DXEN_BUILD_EFI
-
-# Check if the linker supports PE.
-EFI_LDFLAGS = $(patsubst -m%,-mi386pep,$(XEN_LDFLAGS)) --subsystem=10
-XEN_BUILD_PE := $(if $(XEN_BUILD_EFI),$(call ld-option,$(EFI_LDFLAGS) --image-base=0x100000000 -o efi/check.efi efi/check.o))
-# If the above failed, it may be merely because of the linker not dealing well
-# with debug info. Try again with stripping it.
-ifeq ($(CONFIG_DEBUG_INFO)-$(XEN_BUILD_PE),y-n)
-EFI_LDFLAGS += --strip-debug
-XEN_BUILD_PE := $(call ld-option,$(EFI_LDFLAGS) --image-base=0x100000000 -o efi/check.efi efi/check.o)
-endif
-
-ifeq ($(XEN_BUILD_PE),y)
-
-# Check if the linker produces fixups in PE by default
-nr-fixups := $(shell $(OBJDUMP) -p efi/check.efi | grep '^[[:blank:]]*reloc[[:blank:]]*[0-9][[:blank:]].*DIR64$$' | wc -l)
-ifeq ($(nr-fixups),2)
-MKRELOC := :
-relocs-dummy :=
-else
-MKRELOC := efi/mkreloc
-relocs-dummy := efi/relocs-dummy.o
-# If the linker produced fixups but not precisely two of them, we need to
-# disable it doing so.  But if it didn't produce any fixups, it also wouldn't
-# recognize the option.
-ifneq ($(nr-fixups),0)
-EFI_LDFLAGS += --disable-reloc-section
-endif
-endif
-
-endif # $(XEN_BUILD_PE)
-
 endif # $(efi-y)
 
 ALL_OBJS := $(BASEDIR)/arch/x86/boot/built_in.o $(BASEDIR)/arch/x86/efi/built_in.o $(ALL_OBJS)
@@ -218,8 +184,10 @@ endif
 
 $(TARGET).efi: VIRT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A VIRT_START$$,,p')
 ifeq ($(MKRELOC),:)
+relocs-dummy :=
 $(TARGET).efi: ALT_BASE :=
 else
+relocs-dummy := efi/relocs-dummy.o
 $(TARGET).efi: ALT_BASE = 0x$(shell $(NM) efi/relocs-dummy.o | sed -n 's, A ALT_START$$,,p')
 endif
 
diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index eea320e618b9..98dd41d32118 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -60,5 +60,47 @@ ifeq ($(CONFIG_UBSAN),y)
 $(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment)
 endif
 
+ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
+
+efi-check-o = arch/x86/efi/check.o
+
+# Check if the compiler supports the MS ABI.
+XEN_BUILD_EFI := $(call if-success,$(CC) $(CFLAGS) -c $(efi-check-o:.o=.c) -o $(efi-check-o),y)
+
+# Check if the linker supports PE.
+EFI_LDFLAGS := $(patsubst -m%,-mi386pep,$(LDFLAGS)) --subsystem=10
+LD_PE_check_cmd = $(call ld-option,$(EFI_LDFLAGS) --image-base=0x100000000 -o $(efi-check-o:.o=.efi) $(efi-check-o))
+XEN_BUILD_PE := $(LD_PE_check_cmd)
+
+# If the above failed, it may be merely because of the linker not dealing well
+# with debug info. Try again with stripping it.
+ifeq ($(CONFIG_DEBUG_INFO)-$(XEN_BUILD_PE),y-n)
+EFI_LDFLAGS += --strip-debug
+XEN_BUILD_PE := $(LD_PE_check_cmd)
+endif
+
+ifeq ($(XEN_BUILD_PE),y)
+
+# Check if the linker produces fixups in PE by default
+efi-check-relocs := $(shell $(OBJDUMP) -p $(efi-check-o:.o=.efi) | grep '^[[:blank:]]*reloc[[:blank:]]*[0-9][[:blank:]].*DIR64$$' | wc -l)
+
+ifeq ($(efi-check-relocs),2)
+MKRELOC := :
+else
+MKRELOC := efi/mkreloc
+# If the linker produced fixups but not precisely two of them, we need to
+# disable it doing so.  But if it didn't produce any fixups, it also wouldn't
+# recognize the option.
+ifneq ($(efi-check-relocs),0)
+EFI_LDFLAGS += --disable-reloc-section
+endif
+endif
+
+endif # $(XEN_BUILD_PE)
+
+export XEN_BUILD_EFI XEN_BUILD_PE MKRELOC
+export EFI_LDFLAGS
+endif
+
 # Set up the assembler include path properly for older toolchains.
 CFLAGS += -Wa,-I$(BASEDIR)/include
-- 
Anthony PERARD



  parent reply	other threads:[~2021-08-24 11:01 UTC|newest]

Thread overview: 161+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-24 10:49 [XEN PATCH v7 00/51] xen: Build system improvements, now with out-of-tree build! Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 01/51] build: introduce cpp_flags macro Anthony PERARD
2021-09-02 10:08   ` Jan Beulich
2021-09-06 10:06     ` Anthony PERARD
2021-09-06 10:30       ` Jan Beulich
2021-09-06 11:21         ` Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 02/51] build: use if_changed on built_in.o Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 03/51] build: use if_changed_rules with %.o:%.c targets Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 04/51] build: factorise generation of the linker scripts Anthony PERARD
2021-09-07 14:22   ` Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 05/51] x86/mm: avoid building multiple .o from a single .c file Anthony PERARD
2021-09-07  6:14   ` Jan Beulich
2021-09-08 11:14     ` Anthony PERARD
2021-09-08 11:44       ` Ian Jackson
2021-10-11 14:13         ` Andrew Cooper
2021-09-08 12:01       ` Jan Beulich
2021-09-09 10:03         ` Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 06/51] build,include: rework compat-build-source.py Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 07/51] build,include: rework compat-build-header.py Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 08/51] build: fix clean targets when subdir-y is used Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 09/51] build: use subdir-y in test/Makefile Anthony PERARD
2021-09-02 10:17   ` Jan Beulich
2021-08-24 10:49 ` [XEN PATCH v7 10/51] build,arm: move LDFLAGS change to arch.mk Anthony PERARD
2021-08-24 12:50   ` Julien Grall
2021-08-24 15:00     ` Anthony PERARD
2021-08-24 15:23       ` Julien Grall
2021-08-24 16:14         ` Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 11/51] build: move make option changes check earlier Anthony PERARD
2021-08-24 10:49 ` [XEN PATCH v7 12/51] build: avoid building arm/arm/*/head.o twice Anthony PERARD
2021-08-24 12:53   ` Julien Grall
2021-08-24 15:12     ` Anthony PERARD
2021-08-24 15:20       ` Julien Grall
2021-08-24 10:50 ` [XEN PATCH v7 13/51] build: convert binfile use to if_changed Anthony PERARD
2021-10-07 13:55   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 14/51] xen: move include/asm-* to arch/*/include/asm Anthony PERARD
2021-10-07 14:17   ` Jan Beulich
2021-10-11 13:57     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 15/51] build,riscv: tell the build system about riscv64/head.S Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 16/51] build: generate "include/xen/compile.h" with if_changed Anthony PERARD
2021-10-07 14:55   ` Jan Beulich
2021-10-11 14:11     ` Anthony PERARD
2021-08-24 10:50 ` Anthony PERARD [this message]
2021-10-07 16:14   ` [XEN PATCH v7 17/51] build: set XEN_BUILD_EFI earlier Jan Beulich
2021-10-11 14:21     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 18/51] build: fix $(TARGET).efi creation in arch/arm Anthony PERARD
2021-10-11 10:37   ` Jan Beulich
2021-10-11 14:22     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 19/51] build: fix arch/x86/note.o rule Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 20/51] build: avoid re-executing the main Makefile by introducing build.mk Anthony PERARD
2021-10-11 10:56   ` Jan Beulich
2021-10-11 14:58     ` Anthony PERARD
2021-10-11 15:31       ` Jan Beulich
2021-10-11 17:07         ` Anthony PERARD
2021-10-12  8:06           ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 21/51] build: set ALL_OBJS to main Makefile; move prelink.o to main Makefile Anthony PERARD
2021-10-11 11:31   ` Jan Beulich
2021-10-13 12:30     ` Anthony PERARD
2021-10-13 12:41       ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 22/51] build: clean common temporary files from root makefile Anthony PERARD
2021-10-11 11:41   ` Jan Beulich
2021-10-13 10:36     ` Anthony PERARD
2021-10-13 12:32       ` Jan Beulich
2021-10-13 14:26         ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 23/51] build,include: remove arch-*/*.h public header listing from headers*.chk Anthony PERARD
2021-10-11 11:49   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 24/51] build: prepare to always invoke $(MAKE) from xen/, use $(obj) Anthony PERARD
2021-10-11 12:39   ` Jan Beulich
2021-10-13 10:57     ` Anthony PERARD
2021-10-13 12:35       ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 25/51] build: rework test/livepatch/Makefile Anthony PERARD
2021-10-11 13:28   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 26/51] build: build everything from the root dir, use obj=$subdir Anthony PERARD
2021-10-11 14:02   ` Jan Beulich
2021-10-13 14:24     ` Anthony PERARD
2021-10-14 13:33       ` Anthony PERARD
2021-10-14 13:54         ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 27/51] build: introduce if_changed_deps Anthony PERARD
2021-10-11 14:20   ` Jan Beulich
2021-10-14 13:56     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 28/51] build: rename __LINKER__ to LINKER_SCRIPT Anthony PERARD
2021-10-11 14:23   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 29/51] build: add an other explicite rules to not build $(XEN_ROOT)/.config Anthony PERARD
2021-10-11 14:29   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 30/51] build: hook kconfig into xen build system Anthony PERARD
2021-10-11 15:38   ` Jan Beulich
2021-10-14 15:09     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 31/51] xen/tools/kconfig: fix build with -Wdeclaration-after-statement Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 32/51] build: Remove KBUILD_ specific from Makefile.host Anthony PERARD
2021-10-11 15:47   ` Jan Beulich
2021-10-14 14:18     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 33/51] build: handle always-y and hostprogs-always-y Anthony PERARD
2021-10-11 15:48   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 34/51] build: start building the tools with the main makefiles Anthony PERARD
2021-10-11 15:49   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 35/51] build: Add headers path to CFLAGS once for all archs Anthony PERARD
2021-10-11 15:51   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 36/51] build: generate x86's asm-macros.h with filechk Anthony PERARD
2021-10-11 15:52   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 37/51] build: clean-up "clean" rules of duplication Anthony PERARD
2021-10-11 15:53   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 38/51] build: use main rune to build host binary x86's mkelf32 and mkreloc Anthony PERARD
2021-10-11 15:56   ` Jan Beulich
2021-10-14 14:20     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 39/51] build: rework coverage and ubsan CFLAGS handling Anthony PERARD
2021-10-11 16:04   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 40/51] build: fix dependencies in arch/x86/boot Anthony PERARD
2021-10-14  8:08   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 41/51] build,x86: remove the need for build32.mk Anthony PERARD
2021-10-14  8:32   ` Jan Beulich
2021-10-15 15:52     ` Anthony PERARD
2021-10-18  8:43       ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 42/51] build: grab common EFI source files in arch specific dir Anthony PERARD
2021-10-14  8:51   ` Jan Beulich
2021-10-15 16:29     ` Anthony PERARD
2021-10-18  8:48       ` Jan Beulich
2021-10-21 11:03         ` Anthony PERARD
2021-10-21 11:24           ` Jan Beulich
2021-10-21 13:54             ` Anthony PERARD
2021-10-21 14:16               ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 43/51] build: replace $(BASEDIR) by $(objtree) Anthony PERARD
2021-10-14  9:21   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 44/51] build: add $(srctree) in few key places Anthony PERARD
2021-10-14  9:26   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 45/51] build: rework cloc recipe Anthony PERARD
2021-10-14  9:33   ` Jan Beulich
2021-10-15 16:34     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 46/51] build: replace $(BASEDIR) by $(srctree) Anthony PERARD
2021-10-14  9:36   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 47/51] build: Rework "clean" to clean from the root dir Anthony PERARD
2021-10-14  9:44   ` Jan Beulich
2021-10-15 16:40     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 48/51] build: Rework "headers*.chk" prerequisite in include/ Anthony PERARD
2021-10-14  9:48   ` Jan Beulich
2021-08-24 10:50 ` [XEN PATCH v7 49/51] build: adding out-of-tree support to the xen build Anthony PERARD
2021-10-14 10:14   ` Jan Beulich
2021-10-15 16:58     ` Anthony PERARD
2021-10-18  9:02       ` Jan Beulich
2021-10-18  9:51         ` Anthony PERARD
2021-10-18 10:05           ` Jan Beulich
2021-10-18 10:28           ` Juergen Gross
2021-10-18 10:36             ` Jan Beulich
2021-10-18 10:40               ` Juergen Gross
2021-10-18 11:07                 ` Jan Beulich
2021-10-18 11:20                   ` Juergen Gross
2021-10-18 12:03                     ` Jan Beulich
2021-10-21 14:10               ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 50/51] build: specify source tree in include/ for prerequisite Anthony PERARD
2021-10-14 10:19   ` Jan Beulich
2021-10-15 17:02     ` Anthony PERARD
2021-08-24 10:50 ` [XEN PATCH v7 51/51] build: add %.E targets Anthony PERARD
2021-10-13 15:48   ` Jan Beulich
2021-10-14  6:52     ` Jan Beulich
2021-09-02 10:22 ` [XEN PATCH v7 00/51] xen: Build system improvements, now with out-of-tree build! Jan Beulich
2021-09-06 16:13 ` Anthony PERARD
2021-09-07  6:20   ` Jan Beulich
2021-09-07  7:46   ` Jan Beulich
2021-09-15  9:53 ` Michal Orzel
2021-11-04 15:49 ` Alex Bennée
2021-11-04 16:12   ` Alex Bennée
2021-11-04 16:34   ` Anthony PERARD
2021-11-04 16:59     ` Alex Bennée

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210824105038.1257926-18-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=roger.pau@citrix.com \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.