https://gcc.gnu.org/bugzilla/show_bug.cgi?id=124238

--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
We do instantiate stdio_filebuf<char> in the library, but then we only export
the RTTI symbols:

00000000000861c0 t
_ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC1EP8_IO_FILESt13_Ios_Openmodem
00000000000860f0 t
_ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC1EiSt13_Ios_Openmodem
00000000000861c0 t
_ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC2EP8_IO_FILESt13_Ios_Openmodem
00000000000860f0 t
_ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEC2EiSt13_Ios_Openmodem
0000000000086060 t _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEED0Ev
0000000000086010 t _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEED1Ev
0000000000086010 t _ZN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEED2Ev
00000000000863a0 t
_ZN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEEC1EP8_IO_FILESt13_Ios_Openmodem
00000000000863a0 t
_ZN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEEC2EP8_IO_FILESt13_Ios_Openmodem
00000000000860d0 t _ZN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEED0Ev
0000000000086080 t _ZN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEED1Ev
0000000000086080 t _ZN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEED2Ev
000000000027d8e8 V _ZTIN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEE
000000000027d900 V _ZTIN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEEE
00000000001f13a0 V _ZTSN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEE
00000000001f13e0 V _ZTSN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEEE
000000000027da18 d _ZTVN9__gnu_cxx13stdio_filebufIcSt11char_traitsIcEEE
000000000027da98 d _ZTVN9__gnu_cxx13stdio_filebufIwSt11char_traitsIwEEE

The code that uses stdio_filebuf has its own comdat copies of all the symbols,
implicitly instantiated from the function definitions in the header.

It looks like when linking with LTO the linker decides it can discard those
implicitly instantiated copies of the symbols, because there are copies in the
libstdc++ library. But then the copies in the shared library aren't exported so
they can't be found.

Except that doesn't make sense, because the error shows that the undefined
reference is coming from the static lib:  libstdc++.a(ext11-inst.o): 

And the exported symbols shouldn't matter for the static lib, everything is
visible.

Reply via email to