Remove libgcc_s dependency from gcc

Viewed 2698

I have installed gcc-7.1.0 from source based on: https://gcc.gnu.org/install/index.html to use a newer gcc.

The compiled binaries have an extra dependency with libgcc:

$ ldd a.out
        linux-vdso.so.1 =>  (0x00007fffd85fd000)
        librt.so.1 => /lib64/librt.so.1 (0x000000365b400000)
        libdl.so.2 => /lib64/libdl.so.2 (0x000000365a800000)
        libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x000000301ae00000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x000000365b000000)
        libc.so.6 => /lib64/libc.so.6 (0x000000365a000000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003659c00000)

I didn't choose any particular configuration options (other than --prefix) and installed with defaults. Looking at the config.log, it appears that configuration decided it couldn't do so by default. Relevant parts:

configure:5038: checking whether g++ accepts -static-libstdc++ -static-libgcc
configure:5055: g++ -o conftest -g -O2   -static-libstdc++ -static-libgcc conftest.cpp  >&5
g++: unrecognized option '-static-libstdc++'
conftest.cpp:11:2: error: #error -static-libstdc++ not implemented
configure:5055: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
|
| #if (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
| #error -static-libstdc++ not implemented
| #endif
| int main() {}
configure:5059: result: no

(The g++ available - used above - is a bit old: g++ 4.1.2 if that's relevant).

I am compiling only C code. So, if there's no static linking support -static-libstdc++, that's not an issue. But I don't understand why libgcc is tied with -static-libstdc++.

libgcc_s.so.1 isn't always available on all machines. While I can install it, I don't want this extra requirement on my customers. Is there any way I can remove this dependency?

While using -static-libgcc switch does get remove libgcc_s.so.1, I am looking for a way to let gcc itself do this. If that means re-configuring and reinstalling gcc, it is fine by me.

P.S.: I also have to follow the workarounds from here: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61955 as the machine is a bit old.

2 Answers
Related