'subpress gcc_s with static compilation

When running a static comile (in this example with clang but it's also happening with gcc) the linker adds a gcc_s. Is this avoidable? gcc packages don't seem to deliver a static gcc_s and recompiling gcc_s is not an option.

The clang line:

clang -pthread -Wl,-L/code/vendor/lib,-static -o "/code/mruby/build/host/bin/etl-runner" "/code/mruby/build/host/mrbgems/etl-runner/tools/etl-runner/etl-runner.o" "/code/mruby/build/host/lib/libmruby.a"  -lm -lpthread -lc -lgcc -lgcc_eh -lcurl -lbrotlidec -lbrotlicommon -lidn2 -lunistring -llber -lnghttp2 -lldap_r -lpthread -lc -lgcc -lgcc_eh -llber -lsasl2 -ldb -lpthread -ldl -lcrypto -ldl -lgnutls -lidn2 -lunistring -lp11-kit-internal -lffi -lp11-library -lp11-common -ltasn1 -lhogweed -lnettle -lgmp -lz -lpq -lpthread -lpgport -lpgcommon -lc -lgcc -lgcc_eh

the resulting ld call:

"/usr/bin/ld" --hash-style=both --build-id --eh-frame-hdr -m elf_x86_64 -dynamic-linker /lib64/ld-linux-x86-64.so.2 -o /code/mruby/build/host/bin/etl-runner /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crt1.o /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crti.o /usr/bin/../lib/gcc/x86_64-linux-gnu/10/crtbegin.o -L/usr/bin/../lib/gcc/x86_64-linux-gnu/10 -L/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu -L/lib/x86_64-linux-gnu -L/lib/../lib64 -L/usr/lib/x86_64-linux-gnu -L/usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../.. -L/usr/lib/llvm-11/bin/../lib -L/lib -L/usr/lib -L/code/vendor/lib -static /code/mruby/build/host/mrbgems/etl-runner/tools/etl-runner/etl-runner.o /code/mruby/build/host/lib/libmruby.a -lm -lpthread -lc -lgcc -lgcc_eh -lcurl -lbrotlidec -lbrotlicommon -lidn2 -lunistring -llber -lnghttp2 -lldap_r -lpthread -lc -lgcc -lgcc_eh -llber -lsasl2 -ldb -lpthread -ldl -lcrypto -ldl -lgnutls -lidn2 -lunistring -lp11-kit-internal -lffi -lp11-library -lp11-common -ltasn1 -lhogweed -lnettle -lgmp -lz -lpq -lpthread -lpgport -lpgcommon -lc -lgcc -lgcc_eh -lgcc --as-needed -lgcc_s --no-as-needed -lpthread -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/bin/../lib/gcc/x86_64-linux-gnu/10/crtend.o /usr/bin/../lib/gcc/x86_64-linux-gnu/10/../../../x86_64-linux-gnu/crtn.o

the resulting ld call works if the --as-needed --no-as-needed parts are removed.

Any hints?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source