Bug 18153 - [3.4/4.0 Regression] -static-libgcc links in libunwind.so.7
Summary: [3.4/4.0 Regression] -static-libgcc links in libunwind.so.7
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.4.3
: P2 critical
Target Milestone: 3.4.4
Assignee: H.J. Lu
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2004-10-26 00:43 UTC by H.J. Lu
Modified: 2004-12-16 00:19 UTC (History)
2 users (show)

See Also:
Host: ia64-unknown-linux-gnu
Target: ia64-unknown-linux-gnu
Build: ia64-unknown-linux-gnu
Known to work:
Known to fail:
Last reconfirmed: 2004-10-26 00:49:47


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description H.J. Lu 2004-10-26 00:43:12 UTC
-static-libgcc links in libunwind.so.7 even if it isn't used at all:

[hjl@gnu-4 tmp]$ cat f.c
int
main ()
{
  return 0;
}
[hjl@gnu-4 tmp]$ /usr/gcc-3.4/bin/gcc -static-libgcc f.c
[hjl@gnu-4 tmp]$ ./a.out
./a.out: error while loading shared libraries: libunwind.so.7: cannot open 
shared object file: No such file or directory
Comment 1 Andrew Pinski 2004-10-26 00:49:47 UTC
Your self caused this regression.
Comment 2 H.J. Lu 2004-10-26 01:07:09 UTC
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02141.html
Comment 3 Mark Mitchell 2004-11-01 00:45:46 UTC
Postponed until GCC 3.4.4.
Comment 4 H.J. Lu 2004-11-01 16:29:51 UTC
An alternative is posted at

http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02209.html
Comment 5 H.J. Lu 2004-12-10 17:11:36 UTC
An updated patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00757.html
Comment 6 H.J. Lu 2004-12-14 17:52:35 UTC
Mark, can you take a look at the patch? Thanks.
Comment 7 Mark Mitchell 2004-12-15 19:54:49 UTC
Why would we want to link libunwind statically?  I don't see why it shouldn't be
a shared library just like everything else.

In fact, I don't see this as a bug at all.  Binaries depend on libgcc already;
so, now they depend on libunwind too.
Comment 8 H.J. Lu 2004-12-15 22:54:47 UTC
We tried very hard to provide -static-libgcc which links against
libgcc.a and libgcc_eh.a instead of libgcc.a and libgcc_s.so.1.
The main purpose of -static-libgcc is to link in the copy of
the unwind stuff. Introduction of libunwind moved the unwind
stuff from libgcc_s.so.1/libgcc_eh.a into libunwind.so.7/libunwind.a.
With libunwind, -static-libgcc should still link in the copy of
the unwind stuff, instead of from a shared library. Otherwise,
applications which expect that behavior of -static-libgcc won't
work correctly.
Comment 9 Mark Mitchell 2004-12-15 23:30:49 UTC
Subject: Re:  [3.4/4.0 Regression] -static-libgcc links
 in libunwind.so.7

hjl at lucon dot org wrote:
> ------- Additional Comments From hjl at lucon dot org  2004-12-15 22:54 -------
> We tried very hard to provide -static-libgcc which links against
> libgcc.a and libgcc_eh.a instead of libgcc.a and libgcc_s.so.1.
> The main purpose of -static-libgcc is to link in the copy of
> the unwind stuff. Introduction of libunwind moved the unwind
> stuff from libgcc_s.so.1/libgcc_eh.a into libunwind.so.7/libunwind.a.
> With libunwind, -static-libgcc should still link in the copy of
> the unwind stuff, instead of from a shared library. Otherwise,
> applications which expect that behavior of -static-libgcc won't
> work correctly.

OK.  I understand now that your patch is just modifying the static 
linking case.  In that case, your change is OK.

Comment 10 CVS Commits 2004-12-15 23:50:39 UTC
Subject: Bug 18153

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	hjl@gcc.gnu.org	2004-12-15 23:50:30

Modified files:
	gcc            : ChangeLog config.in configure configure.ac 
	                 gcc.c 

Log message:
	2004-12-15  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR target/18153
	* configure.ac: Define HAVE_LD_STATIC_DYNAMIC if linker supports
	-Bstatic/-Bdynamic option.
	* config.in: Regenerated.
	* configure: Likewise.
	
	* gcc.c (init_spec): Pass -Bstatic/-Bdynamic to ld for static
	-lunwind if possible.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6847&r2=2.6848
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config.in.diff?cvsroot=gcc&r1=1.201&r2=1.202
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/configure.diff?cvsroot=gcc&r1=1.880&r2=1.881
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/configure.ac.diff?cvsroot=gcc&r1=2.89&r2=2.90
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gcc.c.diff?cvsroot=gcc&r1=1.441&r2=1.442

Comment 11 CVS Commits 2004-12-16 00:17:39 UTC
Subject: Bug 18153

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	hjl@gcc.gnu.org	2004-12-16 00:15:07

Modified files:
	gcc            : ChangeLog config.in configure configure.ac 
	                 gcc.c 

Log message:
	2004-12-15  H.J. Lu  <hongjiu.lu@intel.com>
	
	PR target/18153
	* configure.ac: Define HAVE_LD_STATIC_DYNAMIC if linker supports
	-Bstatic/-Bdynamic option.
	* config.in: Regenerated.
	* configure: Likewise.
	
	* gcc.c (init_spec): Pass -Bstatic/-Bdynamic to ld for static
	-lunwind if possible.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.739&r2=2.2326.2.740
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config.in.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.181.4.4&r2=1.181.4.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/configure.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.794.2.19&r2=1.794.2.20
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/configure.ac.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.6.2.17&r2=2.6.2.18
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gcc.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.403.4.9&r2=1.403.4.10

Comment 12 H.J. Lu 2004-12-16 00:19:24 UTC
Fixed.