d8307d
commit e30fb31c0ad8d31babd1d0d0f05e37c6579a870b
d8307d
Author: Florian Weimer <fweimer@redhat.com>
d8307d
Date:   Fri Apr 26 07:16:47 2019 +0200
d8307d
d8307d
    Makeconfig: Move $(CC) to +link command variables
d8307d
    
d8307d
    This change is needed to add linker flags which come very early in the
d8307d
    command linke (before LDFLAGS) and are not applied to test programs
d8307d
    (only to installed programs).
d8307d
d8307d
diff --git a/Makeconfig b/Makeconfig
d8307d
index 742c0c0783a14bfa..1ad25fc5a7251aea 100644
d8307d
--- a/Makeconfig
d8307d
+++ b/Makeconfig
d8307d
@@ -415,7 +415,7 @@ link-extra-libs-tests = $(libsupport)
d8307d
 
d8307d
 # Command for linking PIE programs with the C library.
d8307d
 ifndef +link-pie
d8307d
-+link-pie-before-libc = $(CC) $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
d8307d
++link-pie-before-libc = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
d8307d
 	     -Wl,-O1 -nostdlib -nostartfiles -o $@ \
d8307d
 	     $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
d8307d
 	     $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
d8307d
@@ -428,23 +428,24 @@ ifndef +link-pie
d8307d
 	     $(link-extra-libs)
d8307d
 +link-pie-after-libc = $(+postctorS) $(+postinit)
d8307d
 define +link-pie
d8307d
-$(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) $(+link-pie-after-libc)
d8307d
+$(CC) $(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) \
d8307d
+  $(link-libc) $(+link-pie-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 define +link-pie-tests
d8307d
-$(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
d8307d
-			 $(+link-pie-after-libc)
d8307d
+$(CC) $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
d8307d
+  $(+link-pie-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 define +link-pie-printers-tests
d8307d
-$(+link-pie-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
d8307d
-			 $(+link-pie-after-libc)
d8307d
+$(CC) $(+link-pie-before-libc) $(built-rtld-LDFLAGS) \
d8307d
+  $(link-libc-printers-tests) $(+link-pie-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 endif
d8307d
 # Command for statically linking programs with the C library.
d8307d
 ifndef +link-static
d8307d
-+link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
d8307d
++link-static-before-libc = -nostdlib -nostartfiles -static -o $@ \
d8307d
 	      $(if $($(@F)-no-pie),$(no-pie-ldflag),$(default-pie-ldflag)) \
d8307d
 	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
d8307d
 	      $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
d8307d
@@ -456,11 +457,13 @@ ifndef +link-static
d8307d
 	      $(link-extra-libs-static)
d8307d
 +link-static-after-libc = $(+postctorT) $(+postinit)
d8307d
 define +link-static
d8307d
-$(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) $(+link-static-after-libc)
d8307d
+$(CC) $(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) \
d8307d
+  $(+link-static-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 define +link-static-tests
d8307d
-$(+link-static-before-libc) $(link-libc-static-tests) $(+link-static-after-libc)
d8307d
+$(CC) $(+link-static-before-libc) $(link-libc-static-tests) \
d8307d
+  $(+link-static-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 endif
d8307d
@@ -475,7 +478,7 @@ ifeq (yes,$(build-pie-default))
d8307d
 +link-tests = $(+link-pie-tests)
d8307d
 +link-printers-tests = $(+link-pie-printers-tests)
d8307d
 else  # not build-pie-default
d8307d
-+link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
d8307d
++link-before-libc = -nostdlib -nostartfiles -o $@ \
d8307d
 	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
d8307d
 	      $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
d8307d
 	      $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
d8307d
@@ -487,16 +490,17 @@ else  # not build-pie-default
d8307d
 	      $(link-extra-libs)
d8307d
 +link-after-libc = $(+postctor) $(+postinit)
d8307d
 define +link
d8307d
-$(+link-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) $(+link-after-libc)
d8307d
+$(CC) $(+link-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) \
d8307d
+  $(+link-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 define +link-tests
d8307d
-$(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
d8307d
+$(CC) $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
d8307d
 		     $(+link-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef
d8307d
 define +link-printers-tests
d8307d
-$(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
d8307d
+$(CC) $(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
d8307d
 		     $(+link-after-libc)
d8307d
 $(call after-link,$@)
d8307d
 endef