[v4,RESEND,2/2] libgcc: Dont use TARGET_SYSTEM_ROOT from gcc

Message ID 20251207050435.339616-2-git@JohnEricson.me
State New
Headers
Series [v4,RESEND,1/2] Move NO_PIE_CFLAGS logic from gcc to libgcc |

Commit Message

John Ericson Dec. 7, 2025, 5:04 a.m. UTC
  Following Andrew Pinski's suggestions in
https://gcc.gnu.org/pipermail/gcc-patches/2025-July/689683.html, just
use the output of:

   $(CC) -print-sysroot

It is just used in one spot, in an AIX code-path. I just made (within
make) a shell variable to use instead.

I don't have AIX on-hand to test this, however.

gcc/ChangeLog:

	* Makefile.in: No longer include TARGET_SYSTEM_ROOT in
	libgcc.mvars.

libgcc/ChangeLog:

	* config/rs6000/t-slibgcc-aix: Instead of using a
	TARGET_SYSTEM_ROOT make variable, just define a shell variable
	as part of the rule and use that.

Suggested-by: Andrew Pinski <quic_apinski@quicinc.com>
Signed-off-by: John Ericson <git@JohnEricson.me>
---
 gcc/Makefile.in                    | 1 -
 libgcc/config/rs6000/t-slibgcc-aix | 8 ++++++--
 2 files changed, 6 insertions(+), 3 deletions(-)
  

Comments

Joseph Myers Dec. 8, 2025, 11:40 p.m. UTC | #1
On Sun, 7 Dec 2025, John Ericson wrote:

> Following Andrew Pinski's suggestions in
> https://gcc.gnu.org/pipermail/gcc-patches/2025-July/689683.html, just
> use the output of:
> 
>    $(CC) -print-sysroot
> 
> It is just used in one spot, in an AIX code-path. I just made (within
> make) a shell variable to use instead.
> 
> I don't have AIX on-hand to test this, however.

This is another patch I already approved in July in the absence of more 
specific maintainer objections.
  

Patch

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index a9264bde9bc..d62314505c9 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2503,7 +2503,6 @@  libgcc.mvars: config.status Makefile specs xgcc$(exeext)
 	: > tmp-libgcc.mvars
 	echo GCC_CFLAGS = '$(GCC_CFLAGS)' >> tmp-libgcc.mvars
 	echo INHIBIT_LIBC_CFLAGS = '$(INHIBIT_LIBC_CFLAGS)' >> tmp-libgcc.mvars
-	echo TARGET_SYSTEM_ROOT = '$(TARGET_SYSTEM_ROOT)' >> tmp-libgcc.mvars
 
 	mv tmp-libgcc.mvars libgcc.mvars
 
diff --git a/libgcc/config/rs6000/t-slibgcc-aix b/libgcc/config/rs6000/t-slibgcc-aix
index 63336876e2a..4a3d624cfec 100644
--- a/libgcc/config/rs6000/t-slibgcc-aix
+++ b/libgcc/config/rs6000/t-slibgcc-aix
@@ -40,7 +40,9 @@  SHLIB_LINK = \
 	  -Wl,-bE:@shlib_map_file@ -o shr.o \
 	  @multilib_flags@ @shlib_objs@ -lc \
 	  `case @multilib_dir@ in \
-	  *pthread*) echo -L$(TARGET_SYSTEM_ROOT)/usr/lib/threads -lpthreads -lc_r $(TARGET_SYSTEM_ROOT)/usr/lib/libc.a ;; \
+	  *pthread*) \
+	    TARGET_SYSTEM_ROOT=\`$(CC) -print-sysroot\`; \
+	    echo -L$$TARGET_SYSTEM_ROOT/usr/lib/threads -lpthreads -lc_r $$TARGET_SYSTEM_ROOT/usr/lib/libc.a ;; \
 	  *) echo -lc ;; esac` ; \
 	  rm -f tmp-@shlib_base_name@.a ; \
 	  $(AR_CREATE_FOR_TARGET) tmp-@shlib_base_name@.a shr.o ; \
@@ -53,7 +55,9 @@  SHLIB_LINK = \
 	  -Wl,-bE:@shlib_map_file@ -o $$shr.o \
 	  @multilib_flags@ @shlib_objs@ -lc \
 	  `case @multilib_dir@ in \
-	  *pthread*) echo -L$(TARGET_SYSTEM_ROOT)/usr/lib/threads -lpthreads -lc_r $(TARGET_SYSTEM_ROOT)/usr/lib/libc.a ;; \
+	  *pthread*) \
+	    TARGET_SYSTEM_ROOT=\`$(CC) -print-sysroot\`; \
+	    echo -L$$TARGET_SYSTEM_ROOT/usr/lib/threads -lpthreads -lc_r $$TARGET_SYSTEM_ROOT/usr/lib/libc.a ;; \
 	  *) echo -lc ;; esac` ; \
 	  $(STRIP_FOR_TARGET) -X32_64 -e $$shr.o ; \
 	  { echo "\#! $(SHLIB_SONAME)($$shr.o)" ; \