[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[XEN PATCH v6 21/31] build: set XEN_BUILD_EFI earlier


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Anthony PERARD <anthony.perard@xxxxxxxxxx>
  • Date: Thu, 1 Jul 2021 15:10:01 +0100
  • Authentication-results: esa3.hc3370-68.iphmx.com; dkim=none (message not signed) header.i=none
  • Cc: Anthony PERARD <anthony.perard@xxxxxxxxxx>, Jan Beulich <jbeulich@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, Roger Pau Monné <roger.pau@xxxxxxxxxx>, Wei Liu <wl@xxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, Ian Jackson <iwj@xxxxxxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Thu, 01 Jul 2021 14:21:58 +0000
  • Ironport-hdrordr: A9a23:9LtKtq7leBdzp6fg6APXwDLXdLJyesId70hD6qkQc3FomwKj9/ xG/c5rsSMc7Qx6ZJhOo7+90cW7L080lqQFhLX5X43SPzUO0VHARO1fBOPZqAEIcBeOlNK1u5 0AT0B/YueAcGSTj6zBkXWF+wBL+qj5zEiq792usUuEVWtRGsZdB58SMHfhLqVxLjM2Y6YRJd 6nyedsgSGvQngTZtTTPAh+YwCSz+e77a4PeHQ9dmYa1DU=
  • Ironport-sdr: 2hiLc/rv5YZvB7xMScsNK+RP/DATlm5u6nfbHqoWNzyv1NQyIIuaanwfVS39WtqpwOYZNQ8+2a RvpZzFe3OTjhWGav6qmSOnFL8xyZ7ScmeY6WWzMYVpkPhGTdeSLk+gk4lFPYrCRotosrCWGXSe 7pBW1G+btqkPQyeCg1XfZfMWD191C4rG1P4D0YVxNcrCL2AoKP54WH/GW7pXVkBSvJjejxXB0i oHhzFYY7X3ocHEc+VfgeJKzVtNt8vm7Qf24tNrFzZSZ7iOg4WgxbFr5nPykBOgvmf/T2ud2paL IqA=
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

We are going to need the variable XEN_BUILD_EFI earlier.

This early check is using "try-run" to allow to have a temporary
output file in case it is needed for $(CC) to build the *.c file.

The "efi/check.o" file is still needed in "arch/x86/Makefile" so the
check is currently duplicated.

This patch imports the macro "try-run" from Linux v5.12.

Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx>
---
 xen/arch/x86/Makefile      |  2 +-
 xen/arch/x86/arch.mk       |  5 +++++
 xen/scripts/Kbuild.include | 17 +++++++++++++++++
 3 files changed, 23 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile
index bb446a1b928d..d3e38e4e9f02 100644
--- a/xen/arch/x86/Makefile
+++ b/xen/arch/x86/Makefile
@@ -126,7 +126,7 @@ $(TARGET): $(TARGET)-syms $(efi-y) boot/mkelf32
 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)
+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.
diff --git a/xen/arch/x86/arch.mk b/xen/arch/x86/arch.mk
index 9f5fade39e91..5a4a1704636f 100644
--- a/xen/arch/x86/arch.mk
+++ b/xen/arch/x86/arch.mk
@@ -60,5 +60,10 @@ ifeq ($(CONFIG_UBSAN),y)
 $(call cc-option-add,CFLAGS_UBSAN,CC,-fno-sanitize=alignment)
 endif
 
+ifneq ($(CONFIG_PV_SHIM_EXCLUSIVE),y)
+# Check if the compiler supports the MS ABI.
+export XEN_BUILD_EFI := $(call try-run,$(CC) $(CFLAGS) -c arch/x86/efi/check.c 
-o "$$TMPO",y)
+endif
+
 # Set up the assembler include path properly for older toolchains.
 CFLAGS += -Wa,-I$(BASEDIR)/include
diff --git a/xen/scripts/Kbuild.include b/xen/scripts/Kbuild.include
index 838c9440f35e..5fe13a7c5abd 100644
--- a/xen/scripts/Kbuild.include
+++ b/xen/scripts/Kbuild.include
@@ -57,6 +57,23 @@ define filechk
        fi
 endef
 
+# output directory for tests below
+TMPOUT = .tmp_$$$$
+
+# try-run
+# Usage: option = $(call try-run, $(CC)...-o "$$TMP",option-ok,otherwise)
+# Exit code chooses option. "$$TMP" serves as a temporary file and is
+# automatically cleaned up.
+try-run = $(shell set -e;              \
+       TMP=$(TMPOUT)/tmp;              \
+       TMPO=$(TMPOUT)/tmp.o;           \
+       mkdir -p $(TMPOUT);             \
+       trap "rm -rf $(TMPOUT)" EXIT;   \
+       if ($(1)) >/dev/null 2>&1;      \
+       then echo "$(2)";               \
+       else echo "$(3)";               \
+       fi)
+
 # as-insn: Check whether assembler supports an instruction.
 # Usage: cflags-y += $(call as-insn,CC FLAGS,"insn",option-yes,option-no)
 as-insn = $(if $(shell echo 'void _(void) { asm volatile ( $(2) ); }' \
-- 
Anthony PERARD




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.