public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: libstdc++/9776: -static-libgcc does not produce a static link to libstdc++, instead always dynamic
@ 2003-02-20 16:46 Phil Edwards
  0 siblings, 0 replies; 3+ messages in thread
From: Phil Edwards @ 2003-02-20 16:46 UTC (permalink / raw)
  To: nobody; +Cc: gcc-prs

The following reply was made to PR libstdc++/9776; it has been noted by GNATS.

From: Phil Edwards <phil@jaj.com>
To: stew@tenbox.com
Cc: gcc-gnats@gcc.gnu.org
Subject: Re: libstdc++/9776: -static-libgcc does not produce a static link to libstdc++, instead always dynamic
Date: Thu, 20 Feb 2003 11:44:39 -0500

 On Thu, Feb 20, 2003 at 04:30:56PM -0000, stew@tenbox.com wrote:
 > 
 > I worry that maybe I am confused about what -static-libgcc does; maybe it
 > is not supposed to make the link to libstdc++ static.
 
 It isn't.  If you'll look at your ldd output, you'll see that no dependency
 on libgcc_s.so was recorded.  That's why the option is called -static-libgcc,
 not -static-libstdc++.
 
 > 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.
 
 There doesn't need to be a special switch for this.  The way to override
 the choice of libraries is somewhat linker-specific, but something like
 
     g++ .... -lfoo -lbar -Wl,-static -lstdc++ -lquux -Wl,-dynamic -lbaz
 
 will (assuming dynamic libs are the default choice) use libfoo.so, libbar.so,
 and libbaz.so, but libstdc++.a and libquux.a.  The spellings of "-static"
 and "-dynamic" are up to the linker you're using, so "man ld".  On Solaris
 it's something like -Bstatic and -Bdynamic.
 
 
 -- 
 I would therefore like to posit that computing's central challenge, viz. "How
 not to make a mess of it," has /not/ been met.
                                                  - Edsger Dijkstra, 1930-2002


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

* Re: libstdc++/9776: -static-libgcc does not produce a static link to libstdc++, instead always dynamic
@ 2003-02-20 18:23 bkoz
  0 siblings, 0 replies; 3+ messages in thread
From: bkoz @ 2003-02-20 18:23 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, nobody, stew

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

State-Changed-From-To: open->closed
State-Changed-By: bkoz
State-Changed-When: Thu Feb 20 18:23:19 2003
State-Changed-Why:
    Err, -static-libgcc is just for libgcc, not for libstdc++. If you are trying to statically link libstdc++, try:
    
    g++ -static
    
    You might find the on-line documentation for gcc helpful: please consult it.
    
    best
    -benjamin

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=9776


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

* libstdc++/9776: -static-libgcc does not produce a static link to libstdc++, instead always dynamic
@ 2003-02-20 16:36 stew
  0 siblings, 0 replies; 3+ messages in thread
From: stew @ 2003-02-20 16:36 UTC (permalink / raw)
  To: gcc-gnats


>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@tenbox.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@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@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@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@oppenheimer demostdlib]$ g++ main.cpp -static-libgcc
[stew@oppenheimer demostdlib]$ ./a.out
This program invokes the standard library!
[stew@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@tenbox.com


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

end of thread, other threads:[~2003-02-20 18:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-02-20 16:46 libstdc++/9776: -static-libgcc does not produce a static link to libstdc++, instead always dynamic Phil Edwards
  -- strict thread matches above, loose matches on Subject: below --
2003-02-20 18:23 bkoz
2003-02-20 16:36 stew

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).