public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Makeconfig: Move $(CC) to +link command variables
@ 2019-04-25 12:36 Florian Weimer
  2019-04-25 21:26 ` Carlos O'Donell
  0 siblings, 1 reply; 2+ messages in thread
From: Florian Weimer @ 2019-04-25 12:36 UTC (permalink / raw)
  To: libc-alpha

This change is needed to add linker flags which come very early in the
command linke (before LDFLAGS) and are not applied to test programs
(only to installed programs).

2019-04-25  Florian Weimer  <fweimer@redhat.com>

	* Makeconfig (+link-pie-before-libc): Remove $(CC).
	(+link-pie, +link-pie-tests, +link-pie-printers-tests): Add $(CC).
	(+link-static-before-libc): Remove $(CC).
	(+link-static, +link-static-tests): Add $(CC).
	(+link-before-libc): Remove $(CC).
	(+link, +link-pie, +link-pie-printers): Add $(CC).

diff --git a/Makeconfig b/Makeconfig
index 89443e9a90..92c9b59bb5 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -415,7 +415,7 @@ link-extra-libs-tests = $(libsupport)
 
 # Command for linking PIE programs with the C library.
 ifndef +link-pie
-+link-pie-before-libc = $(CC) $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
++link-pie-before-libc = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
 	     -Wl,-O1 -nostdlib -nostartfiles -o $@ \
 	     $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
 	     $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
@@ -428,23 +428,24 @@ ifndef +link-pie
 	     $(link-extra-libs)
 +link-pie-after-libc = $(+postctorS) $(+postinit)
 define +link-pie
-$(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) $(+link-pie-after-libc)
+$(CC) $(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) \
+  $(link-libc) $(+link-pie-after-libc)
 $(call after-link,$@)
 endef
 define +link-pie-tests
-$(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
-			 $(+link-pie-after-libc)
+$(CC) $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
+  $(+link-pie-after-libc)
 $(call after-link,$@)
 endef
 define +link-pie-printers-tests
-$(+link-pie-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
-			 $(+link-pie-after-libc)
+$(CC) $(+link-pie-before-libc) $(built-rtld-LDFLAGS) \
+  $(link-libc-printers-tests) $(+link-pie-after-libc)
 $(call after-link,$@)
 endef
 endif
 # Command for statically linking programs with the C library.
 ifndef +link-static
-+link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
++link-static-before-libc = -nostdlib -nostartfiles -static -o $@ \
 	      $(if $($(@F)-no-pie),$(no-pie-ldflag),$(default-pie-ldflag)) \
 	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
 	      $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
@@ -456,11 +457,13 @@ ifndef +link-static
 	      $(link-extra-libs-static)
 +link-static-after-libc = $(+postctorT) $(+postinit)
 define +link-static
-$(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) $(+link-static-after-libc)
+$(CC) $(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) \
+  $(+link-static-after-libc)
 $(call after-link,$@)
 endef
 define +link-static-tests
-$(+link-static-before-libc) $(link-libc-static-tests) $(+link-static-after-libc)
+$(CC) $(+link-static-before-libc) $(link-libc-static-tests) \
+  $(+link-static-after-libc)
 $(call after-link,$@)
 endef
 endif
@@ -475,7 +478,7 @@ ifeq (yes,$(build-pie-default))
 +link-tests = $(+link-pie-tests)
 +link-printers-tests = $(+link-pie-printers-tests)
 else  # not build-pie-default
-+link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
++link-before-libc = -nostdlib -nostartfiles -o $@ \
 	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
 	      $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
 	      $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
@@ -487,16 +490,17 @@ else  # not build-pie-default
 	      $(link-extra-libs)
 +link-after-libc = $(+postctor) $(+postinit)
 define +link
-$(+link-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) $(+link-after-libc)
+$(CC) $(+link-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) \
+  $(+link-after-libc)
 $(call after-link,$@)
 endef
 define +link-tests
-$(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
+$(CC) $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
 		     $(+link-after-libc)
 $(call after-link,$@)
 endef
 define +link-printers-tests
-$(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
+$(CC) $(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
 		     $(+link-after-libc)
 $(call after-link,$@)
 endef

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] Makeconfig: Move $(CC) to +link command variables
  2019-04-25 12:36 [PATCH] Makeconfig: Move $(CC) to +link command variables Florian Weimer
@ 2019-04-25 21:26 ` Carlos O'Donell
  0 siblings, 0 replies; 2+ messages in thread
From: Carlos O'Donell @ 2019-04-25 21:26 UTC (permalink / raw)
  To: Florian Weimer, libc-alpha

On 4/25/19 8:33 AM, Florian Weimer wrote:
> This change is needed to add linker flags which come very early in the
> command linke (before LDFLAGS) and are not applied to test programs
> (only to installed programs).

Thank you for working on this kind of cleanup.

> 2019-04-25  Florian Weimer  <fweimer@redhat.com>
> 
> 	* Makeconfig (+link-pie-before-libc): Remove $(CC).
> 	(+link-pie, +link-pie-tests, +link-pie-printers-tests): Add $(CC).
> 	(+link-static-before-libc): Remove $(CC).
> 	(+link-static, +link-static-tests): Add $(CC).
> 	(+link-before-libc): Remove $(CC).
> 	(+link, +link-pie, +link-pie-printers): Add $(CC).

This looks good to me.

Reviewed-by: Carlos O'Donell <carlos@redhat.com>

> 
> diff --git a/Makeconfig b/Makeconfig
> index 89443e9a90..92c9b59bb5 100644
> --- a/Makeconfig
> +++ b/Makeconfig
> @@ -415,7 +415,7 @@ link-extra-libs-tests = $(libsupport)
>   
>   # Command for linking PIE programs with the C library.
>   ifndef +link-pie
> -+link-pie-before-libc = $(CC) $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \
> ++link-pie-before-libc = $(if $($(@F)-no-pie),$(no-pie-ldflag),-pie) \

OK, remove $(CC).

>   	     -Wl,-O1 -nostdlib -nostartfiles -o $@ \
>   	     $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
>   	     $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
> @@ -428,23 +428,24 @@ ifndef +link-pie
>   	     $(link-extra-libs)
>   +link-pie-after-libc = $(+postctorS) $(+postinit)
>   define +link-pie
> -$(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) $(+link-pie-after-libc)
> +$(CC) $(+link-pie-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) \
> +  $(link-libc) $(+link-pie-after-libc)

OK, put $(CC) ahead of everything else.

>   $(call after-link,$@)
>   endef
>   define +link-pie-tests
> -$(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
> -			 $(+link-pie-after-libc)
> +$(CC) $(+link-pie-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
> +  $(+link-pie-after-libc)

OK, likewise.

>   $(call after-link,$@)
>   endef
>   define +link-pie-printers-tests
> -$(+link-pie-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
> -			 $(+link-pie-after-libc)
> +$(CC) $(+link-pie-before-libc) $(built-rtld-LDFLAGS) \
> +  $(link-libc-printers-tests) $(+link-pie-after-libc)

OK, likewise.

>   $(call after-link,$@)
>   endef
>   endif
>   # Command for statically linking programs with the C library.
>   ifndef +link-static
> -+link-static-before-libc = $(CC) -nostdlib -nostartfiles -static -o $@ \
> ++link-static-before-libc = -nostdlib -nostartfiles -static -o $@ \

OK, remove $(CC).

>   	      $(if $($(@F)-no-pie),$(no-pie-ldflag),$(default-pie-ldflag)) \
>   	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
>   	      $(firstword $(CRT-$(@F)) $(csu-objpfx)$(real-static-start-installed-name)) \
> @@ -456,11 +457,13 @@ ifndef +link-static
>   	      $(link-extra-libs-static)
>   +link-static-after-libc = $(+postctorT) $(+postinit)
>   define +link-static
> -$(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) $(+link-static-after-libc)
> +$(CC) $(+link-static-before-libc) $(link-extra-flags) $(link-libc-static) \
> +  $(+link-static-after-libc)

OK, put $(CC) ahead of everything else.

>   $(call after-link,$@)
>   endef
>   define +link-static-tests
> -$(+link-static-before-libc) $(link-libc-static-tests) $(+link-static-after-libc)
> +$(CC) $(+link-static-before-libc) $(link-libc-static-tests) \
> +  $(+link-static-after-libc)

OK, likewise.

>   $(call after-link,$@)
>   endef
>   endif
> @@ -475,7 +478,7 @@ ifeq (yes,$(build-pie-default))
>   +link-tests = $(+link-pie-tests)
>   +link-printers-tests = $(+link-pie-printers-tests)
>   else  # not build-pie-default
> -+link-before-libc = $(CC) -nostdlib -nostartfiles -o $@ \
> ++link-before-libc = -nostdlib -nostartfiles -o $@ \

OK, remove $(CC).

>   	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
>   	      $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \
>   	      $(firstword $(CRT-$(@F)) $(csu-objpfx)$(start-installed-name)) \
> @@ -487,16 +490,17 @@ else  # not build-pie-default
>   	      $(link-extra-libs)
>   +link-after-libc = $(+postctor) $(+postinit)
>   define +link
> -$(+link-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) $(+link-after-libc)
> +$(CC) $(+link-before-libc) $(rtld-LDFLAGS) $(link-extra-flags) $(link-libc) \
> +  $(+link-after-libc)

OK, put $(CC) ahead of everything else.

>   $(call after-link,$@)
>   endef
>   define +link-tests
> -$(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \
> +$(CC) $(+link-before-libc) $(rtld-tests-LDFLAGS) $(link-libc-tests) \


OK, likewise.

>   		     $(+link-after-libc)
>   $(call after-link,$@)
>   endef
>   define +link-printers-tests
> -$(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \
> +$(CC) $(+link-before-libc) $(built-rtld-LDFLAGS) $(link-libc-printers-tests) \

OK, likewise.

>   		     $(+link-after-libc)
>   $(call after-link,$@)
>   endef
> 


-- 
Cheers,
Carlos.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-04-25 21:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-25 12:36 [PATCH] Makeconfig: Move $(CC) to +link command variables Florian Weimer
2019-04-25 21:26 ` Carlos O'Donell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).