[ipxe-devel] [PATCH 1/1] [build] Fix no-PIE workaround for i386 builds

Christian Hesse list at eworm.de
Wed Apr 8 08:13:37 UTC 2015


From: Christian Hesse <mail at eworm.de>

This workaround did not work for my version of gcc (4.9.2 20150304) as
no option -nopie exists.

We take another way: Let's check whether or not the macro __PIE__ is defined
and add -fno-PIE if it is.

Signed-off-by: Christian Hesse <mail at eworm.de>
---
 src/arch/i386/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/arch/i386/Makefile b/src/arch/i386/Makefile
index 99f8753..897081b 100644
--- a/src/arch/i386/Makefile
+++ b/src/arch/i386/Makefile
@@ -75,8 +75,8 @@ CFLAGS			+= -Ui386
 # output on stderr instead of checking the exit status.
 #
 ifeq ($(CCTYPE),gcc)
-PIE_TEST = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ]
-PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie')
+PIE_TEST = $(CC) -dM -E - < /dev/null | grep -q '__PIE__'
+PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE')
 WORKAROUND_CFLAGS += $(PIE_FLAGS)
 endif
 
-- 
2.3.5




More information about the ipxe-devel mailing list