[PATCH, regression?] Support --static-libstdc++ with native AIX ld

Michael Haubenwallner michael.haubenwallner@salomon.at
Fri Jan 25 13:56:00 GMT 2013


On 01/24/2013 06:45 PM, David Edelsohn wrote:
>> Since switching to C++ inside gcc, it isn't possible to get working gcc/g++
>> binaries installed using native ld on AIX without this patch, as these need
>> dynamic libstdc++.a from builddir(!). Even after successful build with the
>> workaround from PR55105[1], installed binaries break when removing builddir.
> 
> I build GCC almost daily on AIX and test installation and do not have
> this problem.

Hmm - which "oslevel -s" do you use?

Here I've tried on 7100-01-05-1228.
Also available are 5300-08-09-1013 and 6100-07-05-1228.

According to http://www.ibm.com/developerworks/aix/library/au-aix5l-me.html
AIX does listen to LD_LIBRARY_PATH since 5.3 now.

In case you do have an AIX 5.2 or older, or some other AIX TechLevel that does
not use LD_LIBRARY_PATH for whatever reason, to trigger the same problem this
patch to toplevel configure should work I guess:

--- a/configure
+++ b/configure
@@ -6978,6 +6978,7 @@ rm -f conftest*
 
 # Decide which environment variable is used to find dynamic libraries.
 case "${host}" in
+  *-*-aix*) RPATH_ENVVAR=LIBPATH ;;
   *-*-hpux*) RPATH_ENVVAR=SHLIB_PATH ;;
   *-*-darwin*) RPATH_ENVVAR=DYLD_LIBRARY_PATH ;;
   *-*-mingw* | *-*-cygwin ) RPATH_ENVVAR=PATH ;;

Actually, I'm wondering why this shouldn't go in anyway for consistency across platforms.

> Are you configuring GCC in a special way? Do you set the installation
> directory prefix when you configure?

I don't believe what I do is something really special.

> I build GCC with GCC and have an older version of GCC (including libstdc++) already installed.

Same here, building everything out-of-source. The prerequisites used are:
* CONFIG_SHELL=/usr/local/bin/bash 4.1.7 from bullfreeware (symlinks to /opt/freeware/bin/)
* /usr/bin/{gcc,g++} 4.6.1 from bullfreeware (symlinks to /opt/freeware/bin/)
* /usr/bin/gmake 3.82 from bullfreeware (symlinks to /opt/freeware/bin/)
* gmp-5.0.4: as shared library, configured with --prefix=/prereq ABI=32
* mpfr-3.1.1: as shared library, configured with --prefix=/prereq --with-gmp=/prereq
* mpfr-3.1.1: as shared library, configured with --prefix=/prereq --with-{gmp,mpfr}=/prereq
* gawk-3.1.7, flex-2.5.35, m4-1.4.13 from some Gentoo Prefix instance, nowhere in PATH,
  thus: export {AWK,FLEX}=/gentoo/prefix/usr/bin/{awk,flex} and this patch:
  http://gcc.gnu.org/ml/gcc-patches/2013-01/msg00960.html

For gcc:
* $CONFIG_SHELL configure --prefix=/does/not/exist/yet --with-{gmp,mpfr,mpc}=/prereq \
    --enable--languages=c,c++ --disable-werror --disable-nls
* gmake bootstrap

But unlike you, I do not use --with-boot-ldflags.

> I do not understand why you refer to native ld on AIX and what that
> has to do with any problem.

AIX ld does not understand the -Bstatic/-Bdynamic flags. According to where this very
patch adds -bstatic/-bdynamic for AIX ld, the -Bstatic/-Bdymamic flags will be used
with GNU ld for -static-libstdc++. So I'm guessing that libstdc++ will be statically
linked into gcc,g++,cc1(?) with GNU ld. However, must admit that I've never tried
hard enough to get GNU binutils working.

> $ dump -H cc1
> 
>                         ***Import File Strings***
> INDEX  PATH                          BASE                MEMBER
> 0      /tmp/20130123/prev-powerpc-ibm-aix7.1.0.0/libstdc++-v3/src/.libs:/tmp/20130123/prev-powerpc-ibm-aix7.1.0.0/libstdc++-v3/libsupc++/.libs:/usr/gnu/lib:../zlib:/tmp/20130123/./prev-gcc:/usr/lib:/lib

> Yes, it refers to the build directory, but it also include
> /usr/gnu/lib on the path and a copy of libstdc++.a is in /usr/gnu/lib.

Feels like this is because of --with-boot-ldflags=-L/usr/gnu/lib only, or because
of gmp,mpfr,mpc being found there.

> I often re-link the executable and add -Wl,-blibpath: to set a
> narrower search path.

Do you do run these re-link steps manually?

> With your patch do you configure with any additional options to cause
> the libraries to be linked statically?

Nope.

> The values you set in the patch are correct, but something still does
> not make sense with the problem.

All things considered, simply feels like your AIX doesn't listen to LD_LIBRARY_PATH.

/haubi/



More information about the Gcc-patches mailing list