Bläddra i källkod

[build] Fix compilation when gcc is patched to default to -fPIE -Wl,-pie

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Gilles Espinasse 13 år sedan
förälder
incheckning
fe61f6de0d
1 ändrade filer med 11 tillägg och 0 borttagningar
  1. 11
    0
      src/Makefile.housekeeping

+ 11
- 0
src/Makefile.housekeeping Visa fil

@@ -138,6 +138,17 @@ SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
138 138
 WORKAROUND_CFLAGS += $(SP_FLAGS)
139 139
 endif
140 140
 
141
+# Some widespread patched versions of gcc include -fPIE -Wl,-pie by
142
+# default.  Note that gcc will exit *successfully* if it fails to
143
+# recognise an option that starts with "no", so we have to test for
144
+# output on stderr instead of checking the exit status.
145
+#
146
+ifeq ($(CCTYPE),gcc)
147
+PIE_TEST = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ]
148
+PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie')
149
+WORKAROUND_CFLAGS += $(PIE_FLAGS)
150
+endif
151
+
141 152
 # gcc 4.4 generates .eh_frame sections by default, which distort the
142 153
 # output of "size".  Inhibit this.
143 154
 #

Laddar…
Avbryt
Spara