From: Andrew Cooper Date: Mon, 17 May 2021 09:48:57 +0000 (+0100) Subject: build: Fix build with binutils 2.36 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5ead491e36af6cb8681fc1278bd36c756ad62ac2;p=people%2Fandrewcoop%2Fxen-test-framework.git build: Fix build with binutils 2.36 Passing -no-pie to ld has never been correct, and binutils 2.36 now objects properly to it. https://sourceware.org/bugzilla/show_bug.cgi?id=27050 When this workaround was introduced, we used $(CC) to link, but this was adjusted back to $(LD) with c/s 8486a388e2 ("build: Use LD"). However, the adjustment should always have been passed to the compile step, not the link step. Move the adjustment into COMMON_CFLAGS. Fixes: c92015f8ab ("build: disable PIE during linking if necessary") Fixes: 8486a388e2 ("build: Use LD") Reported-by: Damien Thenot Signed-off-by: Andrew Cooper --- diff --git a/build/common.mk b/build/common.mk index 1f04880..886f190 100644 --- a/build/common.mk +++ b/build/common.mk @@ -17,6 +17,12 @@ $(foreach env,$(64BIT_ENVIRONMENTS),$(eval $(env)_arch := x86_64)) COMMON_FLAGS := -pipe -I$(ROOT)/include -I$(ROOT)/arch/x86/include -MMD -MP +cc-option = $(shell if [ -z "`echo 'int p=1;' | $(CC) $(1) -S -o /dev/null -x c - 2>&1`" ]; \ + then echo y; else echo n; fi) + +# Disable PIE, but need to check if compiler supports it +COMMON_CFLAGS-$(call cc-option,-no-pie) += -no-pie + COMMON_AFLAGS := $(COMMON_FLAGS) -D__ASSEMBLY__ COMMON_CFLAGS := $(COMMON_FLAGS) $(COMMON_CFLAGS-y) COMMON_CFLAGS += -Wall -Wextra -Werror -std=gnu99 -Wstrict-prototypes -O3 -g @@ -38,13 +44,6 @@ obj-perarch := obj-perenv := include $(ROOT)/build/files.mk - -cc-option = $(shell if [ -z "`echo 'int p=1;' | $(CC) $(1) -S -o /dev/null -x c - 2>&1`" ]; \ - then echo y; else echo n; fi) - -# Disable PIE, but need to check if compiler supports it -LDFLAGS-$(call cc-option,-no-pie) += -no-pie - # Run once per environment to set up some common bits & pieces define PERENV_setup