From what I gather from the specs files from g++5 and 7 (from g++ -dumpspecs),
g++5:
*libgcc:
%{static|static-libgcc:-lgcc}%{!static:%{!static-libgcc:--as-needed -lgcc_s --no-as-needed -lgcc}}
g++7:
*libgcc:
%{static|static-libgcc:-lgcc -lgcc_eh}%{!static:%{!static-libgcc:%{!shared-libgcc:-lgcc --as-needed -lgcc_s --no-as-needed}%{shared-libgcc:-lgcc_s%{!shared: -lgcc}}}}
it is the intention that when a shared library is created, it used a
shared version of libgcc (named libgcc_s.so). Gcc 7 does not seem to
install such a file, but there is one in the base system:
/lib/libgcc_s.so.
Unfortunately it does not define `__divmodti4' (unlike gcc7's libgcc.a).
So even if gcc7 did install libgcc_s.so, then it would be a version
incompatible with the base system (and all potential issues following
from that).
(This doesn't quite explain why C includes -lgcc anyway)
The option -static-libgcc turns on the use of libgcc.a:
$P/g++ -v -shared -static-libgcc c.c
/usr/pkg/gcc7/libexec/gcc/x86_64--netbsd/7.4.0/collect2 -plugin
/usr/pkg/gcc7/libexec/gcc/x86_64--netbsd/7.4.0/liblto_plugin.so
-plugin-opt=/usr/pkg/gcc7/libexec/gcc/x86_64--netbsd/7.4.0/lto-wrapper
-plugin-opt=-fresolution=/var/tmp//ccoG70VY.res
-plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_eh -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc
-plugin-opt=-pass-through=-lgcc_eh --eh-frame-hdr -shared
/usr/lib/crti.o /usr/lib/crtbeginS.o
-L/usr/pkg/gcc7/lib/gcc/x86_64--netbsd/7.4.0
-L/usr/pkg/gcc7/lib/gcc/x86_64--netbsd/7.4.0/../../../../x86_64--netbsd/lib
-L/usr/pkg/gcc7/lib/gcc/x86_64--netbsd/7.4.0/../../..
-R/usr/pkg/gcc7/x86_64--netbsd/lib/. -R/usr/pkg/gcc7/lib/.
/var/tmp//cciw8us0.o -lstdc++ -lm -lgcc -lgcc_eh -lc -lgcc
-lgcc_eh /usr/lib/crtendS.o /usr/lib/crtn.o
so either this option can to be inserted somewhere appropriate, or the
spec file could be rewritten. Or gcc7 could install its own libgcc_s, if
we somehow avoid any troubles from that.
-Olaf.
--
Olaf 'Rhialto' Seibert -- rhialto at falu dot nl
___ Anyone who is capable of getting themselves made President should on
\X/ no account be allowed to do the job. --Douglas Adams, "THGTTG"
Attachment:
signature.asc
Description: PGP signature