summaryrefslogtreecommitdiff
path: root/Makeconfig
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2015-03-02 14:53:11 -0800
committerH.J. Lu <hjl.tools@gmail.com>2015-05-28 06:08:28 -0700
commitca1f728cbefd6955735087e45d80620113623b3b (patch)
treeba764e7f0391b93777d90d6a08a24695c2037634 /Makeconfig
parent1ea33bb5517516d1d1005b953c92a071454e66d5 (diff)
downloadglibc-hjl/pr17841/master.tar.gz
Compile archives with -fno-piehjl/pr17841/master
When compiler defaults to PIE, we compile archives with -fno-pie. Since archives won't be used with PIE, compile them with -fpie isn't necessary. [BZ #17841] * Makeconfig (no-pie-ccflag): New. Set to -fno-pie. (pic-default): Don't define if $(no-pie-ccflag) is -fno-pie. (test-object-suffix): New. * Makerules (archive-objects): New. Set before including extra-lib.mk. ($(archive-objects)): New. New rule to append $(no-pie-ccflag) to CFLAGS. * extra-lib.mk (archive-objects): New. * crypt/Makefile ($(objpfx)md5test): Replace ".o" with $(test-object-suffix). ($(objpfx)md5test-giant): Likewise. ($(objpfx)sha256test): Likewise. ($(objpfx)sha512test): Likewise. * math/Makefile (LDFLAGS-atest-exp): New. (LDFLAGS-atest-sincos): Likewise. (LDFLAGS-atest-exp2): Likewise.
Diffstat (limited to 'Makeconfig')
-rw-r--r--Makeconfig15
1 files changed, 14 insertions, 1 deletions
diff --git a/Makeconfig b/Makeconfig
index 831604a050..f9c3b5e7d1 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -891,11 +891,15 @@ override CXXFLAGS = $(c++-sysincludes) \
$(filter-out %frame-pointer,$(+cflags)) $(sysdep-CFLAGS) \
$(CFLAGS-$(suffix $@)) $(CFLAGS-$(<F)) $(CFLAGS-$(@F))
+# This can be changed by a sysdep makefile
+no-pie-ccflag = -fno-pie
# If everything is compiled with -fPIC (implicitly) we must tell this by
-# defining the PIC symbol.
+# defining the PIC symbol unless -fno-pie is used to compile archives.
ifeq (yes,$(build-pic-default))
+ifneq (-fno-pie,$(no-pie-ccflag))
pic-default = -DPIC
endif
+endif
# Enable object files for different versions of the library.
# Various things use $(object-suffixes) to know what all to make.
@@ -951,6 +955,15 @@ CPPFLAGS-.oS = $(CPPFLAGS-.o) -DPIC -DLIBC_NONSHARED=1
libtype.oS = lib%_nonshared.a
endif
+# When compiler defaults to PIE, we compile archives with -fno-pie and
+# we can't link tests against .o files for archives. We need to link
+# against .os files for shared libraries.
+ifeq (yes,$(build-pie-default))
+test-object-suffix := .os
+else
+test-object-suffix := .o
+endif
+
# The assembler can generate debug information too.
ifndef ASFLAGS
ASFLAGS := $(filter -g% -fdebug-prefix-map=%,$(CFLAGS))