This is GCC Bugzilla
This is GCC Bugzilla Version 2.20+
View Bug Activity | Format For Printing | Clone This Bug
-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
Your self caused this regression.
A patch is posted at http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02141.html
Postponed until GCC 3.4.4.
An alternative is posted at http://gcc.gnu.org/ml/gcc-patches/2004-10/msg02209.html
An updated patch is posted at http://gcc.gnu.org/ml/gcc-patches/2004-12/msg00757.html
Mark, can you take a look at the patch? Thanks.
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.
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.
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.
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
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
Fixed.