diff mbox

support --without-multilib --with-specs=-pthread on AIX

Message ID 54E2F5EF.3030209@ssi-schaefer.com
State New
Headers show

Commit Message

Michael Haubenwallner Feb. 17, 2015, 8:03 a.m. UTC
Hi David,

according to LIB_SPEC found in config/rs6000/aix*.h, pthread linking was done with
"-lpthreads -lc_r libc.a" for aix43, which simplified to "-lpthreads -lc" with aix51.

But libgcc_s still is linked the aix43 way with "-lpthreads -lc_r libc.a".

As libc_r.a is a symlink to libc.a now, do you know if its shared objects are loaded
both as "libc.a(shr.o)" and "libc_r.a(shr.o)", or as "libc.a(shr.o)" only?
Can this be a problem worth a bug entry?

Anyway, this patch allows me to configure --without-multilib --with-specs=-pthread

Thanks!
/haubi/

Comments

David Edelsohn Feb. 17, 2015, 2:57 p.m. UTC | #1
On Tue, Feb 17, 2015 at 3:03 AM, Michael Haubenwallner
<michael.haubenwallner@ssi-schaefer.com> wrote:
> Hi David,
>
> according to LIB_SPEC found in config/rs6000/aix*.h, pthread linking was done with
> "-lpthreads -lc_r libc.a" for aix43, which simplified to "-lpthreads -lc" with aix51.
>
> But libgcc_s still is linked the aix43 way with "-lpthreads -lc_r libc.a".
>
> As libc_r.a is a symlink to libc.a now, do you know if its shared objects are loaded
> both as "libc.a(shr.o)" and "libc_r.a(shr.o)", or as "libc.a(shr.o)" only?
> Can this be a problem worth a bug entry?

What do you mean by "loaded as"?  There is only one shared object
loaded into the shared library segment.

> Anyway, this patch allows me to configure --without-multilib --with-specs=-pthread

libgcc build does not distinguish between different releases of AIX.
This patch will break AIX 4.3.  There apparently are people using
current GCC on AIX.  Why are you submitting a patch that explicitly
reverts AIX 4.3 support?

Thanks, David
Michael Haubenwallner Feb. 17, 2015, 4:13 p.m. UTC | #2
Am 2015-02-17 um 15:57 schrieb David Edelsohn:
> On Tue, Feb 17, 2015 at 3:03 AM, Michael Haubenwallner
> <michael.haubenwallner@ssi-schaefer.com> wrote:
>> Hi David,
>>
>> according to LIB_SPEC found in config/rs6000/aix*.h, pthread linking was done with
>> "-lpthreads -lc_r libc.a" for aix43, which simplified to "-lpthreads -lc" with aix51.
>>
>> But libgcc_s still is linked the aix43 way with "-lpthreads -lc_r libc.a".
>>
>> As libc_r.a is a symlink to libc.a now, do you know if its shared objects are loaded
>> both as "libc.a(shr.o)" and "libc_r.a(shr.o)", or as "libc.a(shr.o)" only?
>> Can this be a problem worth a bug entry?
> 
> What do you mean by "loaded as"?  There is only one shared object
> loaded into the shared library segment.

What I mean with "loaded as" is that the runtime loader does encounter both names
"libc.a(shr.o)" and "libc_r.a(shr.o)" in the loader sections of various dependant
shared libs for one executable - and has to detect them as the same shared object.

>> Anyway, this patch allows me to configure --without-multilib --with-specs=-pthread
> 
> libgcc build does not distinguish between different releases of AIX.
> This patch will break AIX 4.3.  There apparently are people using
> current GCC on AIX.  Why are you submitting a patch that explicitly
> reverts AIX 4.3 support?

Erm, this patch is meant to make use of LIB_SPEC found in config/rs6000/aixXY.h even for
libgcc_s, and with config/rs6000/aix43.h the linked pthread libraries would not change.

Or do these people on AIX 4.3 use gcc-binaries built on some AIX 5/6/7?

Thanks!
/haubi/
David Edelsohn Feb. 18, 2015, 12:28 a.m. UTC | #3
On Tue, Feb 17, 2015 at 11:13 AM, Michael Haubenwallner
<michael.haubenwallner@ssi-schaefer.com> wrote:
>
> Am 2015-02-17 um 15:57 schrieb David Edelsohn:
>> On Tue, Feb 17, 2015 at 3:03 AM, Michael Haubenwallner
>> <michael.haubenwallner@ssi-schaefer.com> wrote:
>>> Hi David,
>>>
>>> according to LIB_SPEC found in config/rs6000/aix*.h, pthread linking was done with
>>> "-lpthreads -lc_r libc.a" for aix43, which simplified to "-lpthreads -lc" with aix51.
>>>
>>> But libgcc_s still is linked the aix43 way with "-lpthreads -lc_r libc.a".
>>>
>>> As libc_r.a is a symlink to libc.a now, do you know if its shared objects are loaded
>>> both as "libc.a(shr.o)" and "libc_r.a(shr.o)", or as "libc.a(shr.o)" only?
>>> Can this be a problem worth a bug entry?
>>
>> What do you mean by "loaded as"?  There is only one shared object
>> loaded into the shared library segment.
>
> What I mean with "loaded as" is that the runtime loader does encounter both names
> "libc.a(shr.o)" and "libc_r.a(shr.o)" in the loader sections of various dependant
> shared libs for one executable - and has to detect them as the same shared object.

$ genkld

lists the shared libraries loaded in memory.

Also, if you look at the dependencies of the libgcc_s.a shared object,
it only depends on libc.a

$ dump -H libgcc_s.a

Thanks, David
David Edelsohn Feb. 18, 2015, 3:44 a.m. UTC | #4
On Tue, Feb 17, 2015 at 11:13 AM, Michael Haubenwallner
<michael.haubenwallner@ssi-schaefer.com> wrote:

>>> Anyway, this patch allows me to configure --without-multilib --with-specs=-pthread
>>
>> libgcc build does not distinguish between different releases of AIX.
>> This patch will break AIX 4.3.  There apparently are people using
>> current GCC on AIX.  Why are you submitting a patch that explicitly
>> reverts AIX 4.3 support?
>
> Erm, this patch is meant to make use of LIB_SPEC found in config/rs6000/aixXY.h even for
> libgcc_s, and with config/rs6000/aix43.h the linked pthread libraries would not change.

Other than multilib configure options, what is the advantage of this?

AIX has enough other gratuitous differences, I'm loath to use this
libgcc specs trick.

Thanks, David
diff mbox

Patch

From cee852b7e80f15474187673926c4e0a96d454cac Mon Sep 17 00:00:00 2001
From: Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
Date: Tue, 3 Feb 2015 12:56:53 +0100
Subject: [PATCH] support --without-multilib --with-specs=-pthread on AIX

2015-02-17  Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>

	* config/rs6000/t-slibgcc-aix (SHLIB_LINK): Link libgcc_s with
	empty nolibgcc.specs, do not use -nodefaultlibs.
---
 libgcc/config/rs6000/t-slibgcc-aix | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

diff --git a/libgcc/config/rs6000/t-slibgcc-aix b/libgcc/config/rs6000/t-slibgcc-aix
index 61853e0..b89e9e0 100644
--- a/libgcc/config/rs6000/t-slibgcc-aix
+++ b/libgcc/config/rs6000/t-slibgcc-aix
@@ -35,13 +35,11 @@  SHLIB_EXT = $(SHLIB_EXT_$(with_aix_soname))
 SHLIB_SOVERSION = 1
 SHLIB_SONAME = @shlib_base_name@.so.$(SHLIB_SOVERSION)
 SHLIB_LINK = \
+	{ echo '*libgcc:'; echo; echo; } > nolibgcc.specs ; \
 	if test svr4 != $(with_aix_soname) ; then \
-	  $(CC) $(LIBGCC2_CFLAGS) -shared -Wl,-bnortl -nodefaultlibs \
+	  $(CC) $(LIBGCC2_CFLAGS) -shared -Wl,-bnortl -specs=nolibgcc.specs \
 	  -Wl,-bE:@shlib_map_file@ -o @multilib_dir@/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 ;; \
-	  *) echo -lc ;; esac` ; \
+	  @multilib_flags@ @shlib_objs@ ; \
 	  rm -f @multilib_dir@/tmp-@shlib_base_name@.a ; \
 	  $(AR_CREATE_FOR_TARGET) @multilib_dir@/tmp-@shlib_base_name@.a \
 	    @multilib_dir@/shr.o ; \
@@ -51,12 +49,9 @@  SHLIB_LINK = \
 	fi ; \
 	if test aix != $(with_aix_soname) ; then \
 	  case @multilib_dir@ in *64*) shr='shr_64' ;; *) shr='shr' ;; esac ; \
-	  $(CC) $(LIBGCC2_CFLAGS) -shared -Wl,-G -nodefaultlibs \
+	  $(CC) $(LIBGCC2_CFLAGS) -shared -Wl,-G -specs=nolibgcc.specs \
 	  -Wl,-bE:@shlib_map_file@ -o @multilib_dir@/$$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 ;; \
-	  *) echo -lc ;; esac` ; \
+	  @multilib_flags@ @shlib_objs@ ; \
 	  $(STRIP_FOR_TARGET) -X32_64 -e @multilib_dir@/$$shr.o ; \
 	  { echo "\#! $(SHLIB_SONAME)($$shr.o)" ; \
 	    case @multilib_dir@ in *64*) echo '\# 64' ;; *) echo '\# 32' ;; esac ; \
@@ -70,7 +65,8 @@  SHLIB_LINK = \
 	  rm -f @multilib_dir@/@shlib_base_name@.so ; \
 	  $(LN_S) $(SHLIB_SONAME) @multilib_dir@/@shlib_base_name@.so ; \
 	  rm -f @multilib_dir@/$$shr.imp @multilib_dir@/$$shr.o ; \
-	fi
+	fi ; \
+	rm -f nolibgcc.specs
 SHLIB_INSTALL = \
 	$(mkinstalldirs) $(DESTDIR)$(slibdir)@shlib_slibdir_qual@; \
 	if test svr4 != $(with_aix_soname) ; then \
-- 
2.0.5