This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

libstdc++/9776: -static-libgcc does not produce a static link to libstdc++, instead always dynamic


>Number:         9776
>Category:       libstdc++
>Synopsis:       -static-libgcc does not produce a static link to libstdc++, instead always dynamic
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Feb 20 16:36:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Stewart Loving-Gibbard (stew at tenbox dot com)
>Release:        unknown-1.0
>Organization:
>Environment:
Mandrake 9.0 & Solaris 2.7/2.8, GCC 3.2
>Description:
-static-libgcc does not produce a static link to libstdc++; see attached file.
>How-To-Repeat:
See attached file
>Fix:
See attached file
>Release-Note:
>Audit-Trail:
>Unformatted:
----gnatsweb-attachment----
Content-Type: text/plain; name="LinuxBugReportGCC.txt"
Content-Disposition: inline; filename="LinuxBugReportGCC.txt"





I believe the -static-libgcc option does not work properly
under GCC 3.2. It always produces a *dynamic* link to 
/usr/lib/libstdc++.so.5, instead of /usr/lib/libstdc++.a.

I'll demonstrate:

GCC 3.2:

[stew at oppenheimer demostdlib]$ g++ -v
Reading specs from /usr//bin/../lib/gcc-lib/i586-mandrake-linux-gnu/3.2/specs
Configured with: ../configure --prefix=/usr --libdir=/usr/lib --with-slibdir=/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --enable-long-long --enable-__cxa_atexit --enable-languages=c,c++,ada,f77,objc,java --host=i586-mandrake-linux-gnu --with-system-zlib
Thread model: posix
gcc version 3.2 (Mandrake Linux 9.0 3.2-1mdk)

libstdc++.a is available:

[stew at oppenheimer Linux]$ ls -alg /usr/lib/libstdc++.a
lrwxrwxrwx    1 root           56 Feb 18 16:54 /usr/lib/libstdc++.a -> /usr/lib/gcc-lib/i586-mandrake-linux-gnu/3.2/libstdc++.a

But I always get a dynamic link:

[stew at oppenheimer demostdlib]$ cat main.cpp
#include <string>
#include <iostream>

using namespace std;

int main()
{
    const string thisProgram = "This program";
    cout << thisProgram << " invokes the standard library!" << endl;
    return 0;
}
[stew at oppenheimer demostdlib]$ g++ main.cpp -static-libgcc
[stew at oppenheimer demostdlib]$ ./a.out
This program invokes the standard library!
[stew at oppenheimer demostdlib]$ ldd ./a.out
        libstdc++.so.5 => /usr/lib/libstdc++.so.5 (0x40020000)
        libm.so.6 => /lib/i686/libm.so.6 (0x400e4000)
        libc.so.6 => /lib/i686/libc.so.6 (0x40107000)
        libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x40227000)
        /lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

The example was run on Linux, but I've had the same problem with Solaris.

The only way I've found to get a proper static link on /usr/lib/libstdc++.a
is to catch the collect2 command (g++ main.cpp -static-libgcc -v),
then modify the -lstdc++ to /usr/lib/libstdc++.a. Figuring out how to
do this took many confusing hours.

I worry that maybe I am confused about what -static-libgcc does; maybe it
is not supposed to make the link to libstdc++ static. If not, then I
would suggest that such an option is very needed - it is not often
reasonable that the user have the precise same version of the C++ runtime
library as you.

Thank you. I hope I was clear. If not, please write.

Stewart Loving-Gibbard
stew at tenbox dot com


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]