This is the mail archive of the gcc-patches@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]

Re: [PATCH] Add --with-static-standard-libraries to the top level


Jonathan> What I don't understand is why GDB crashes. It should still be able to
Jonathan> catch exceptions from a shared library even if linked to libstdc++.a,
Jonathan> unless the static libstdc++.a is somehow incompatible with the shared
Jonathan> libstdc++.so the shared lib linked to.

Jonathan> Is this on GNU/Linux, or something with a different linking model?

GNU/Linux, Fedora 29 in particular.  I didn't look into why it fails but
the gcc docs specifically mention this problem:

'-static-libgcc'
[...]
     There are several situations in which an application should use the
     shared 'libgcc' instead of the static version.  The most common of
     these is when the application wishes to throw and catch exceptions
     across different shared libraries.  In that case, each of the
     libraries as well as the application itself should use the shared
     'libgcc'.


I was able to reproduce it with a simple test program:

    $ cd /tmp
    $ cat t.cc 
    void thrower() {
      throw 23;
    }
    $ g++ -fPIC -shared -o libt.so t.cc
    $ cat a.cc
    extern void thrower ();

    int main () {
      try {
        thrower ();
      } catch (...) {
      }
      return 0;
    }
    $ g++ -o a -static-libgcc -static-libstdc++ a.cc -L$(pwd) -lt
    $ LD_LIBRARY_PATH=$(pwd) ./a
    Aborted (core dumped)

thanks,
Tom


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