소스 검색

[build] Apply the "-fno-PIE -nopie" workaround only to i386 builds

Hardened versions of gcc default to building position-independent
code, which breaks our i386 build.  Our build process therefore
detects such platforms and automatically adds "-fno-PIE -nopie" to the
gcc command line.

On x86_64, we choose to build position-independent code (in order to
reduce the final binary size and, in particular, the number of
relocations required for UEFI binaries).  The workaround therefore
breaks the build process for x86_64 binaries on such platforms.

Fix by moving the workaround to the i386-specific portion of the
Makefile.

Reported-by: Jan Kundrát <jkt@kde.org>
Debugged-by: Jan Kundrát <jkt@kde.org>
Debugged-by: Marin Hannache <git@mareo.fr>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 년 전
부모
커밋
5de134662d
2개의 변경된 파일11개의 추가작업 그리고 11개의 파일을 삭제
  1. 0
    11
      src/Makefile.housekeeping
  2. 11
    0
      src/arch/i386/Makefile

+ 0
- 11
src/Makefile.housekeeping 파일 보기

@@ -157,17 +157,6 @@ SP_FLAGS := $(shell $(SP_TEST) && $(ECHO) '-fno-stack-protector')
157 157
 WORKAROUND_CFLAGS += $(SP_FLAGS)
158 158
 endif
159 159
 
160
-# Some widespread patched versions of gcc include -fPIE -Wl,-pie by
161
-# default.  Note that gcc will exit *successfully* if it fails to
162
-# recognise an option that starts with "no", so we have to test for
163
-# output on stderr instead of checking the exit status.
164
-#
165
-ifeq ($(CCTYPE),gcc)
166
-PIE_TEST = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ]
167
-PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie')
168
-WORKAROUND_CFLAGS += $(PIE_FLAGS)
169
-endif
170
-
171 160
 # gcc 4.4 generates .eh_frame sections by default, which distort the
172 161
 # output of "size".  Inhibit this.
173 162
 #

+ 11
- 0
src/arch/i386/Makefile 파일 보기

@@ -69,6 +69,17 @@ CFLAGS		+= -fshort-wchar
69 69
 #
70 70
 CFLAGS			+= -Ui386
71 71
 
72
+# Some widespread patched versions of gcc include -fPIE -Wl,-pie by
73
+# default.  Note that gcc will exit *successfully* if it fails to
74
+# recognise an option that starts with "no", so we have to test for
75
+# output on stderr instead of checking the exit status.
76
+#
77
+ifeq ($(CCTYPE),gcc)
78
+PIE_TEST = [ -z "`$(CC) -fno-PIE -nopie -x c -c /dev/null -o /dev/null 2>&1`" ]
79
+PIE_FLAGS := $(shell $(PIE_TEST) && $(ECHO) '-fno-PIE -nopie')
80
+WORKAROUND_CFLAGS += $(PIE_FLAGS)
81
+endif
82
+
72 83
 # Define version string for lkrnprefix.S
73 84
 #
74 85
 CFLAGS_lkrnprefix	+= -DVERSION="\"$(VERSION)\""

Loading…
취소
저장