This is the mail archive of the 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> 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:

     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

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

    $ cd /tmp
    $ cat 
    void thrower() {
      throw 23;
    $ g++ -fPIC -shared -o
    $ cat
    extern void thrower ();

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


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