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

            Bug ID: 103400
           Summary: src/c++98/*_allocator.cc symbols not exported
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Keywords: link-failure
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: redi at gcc dot gnu.org
  Target Milestone: ---

When GCC is configured with --enable-libstdcxx-allocator=pool we get this test
failure:

FAIL: 27_io/manipulators/standard/wchar_t/2.cc (test for excess errors)
Excess errors:
/usr/bin/ld: Dwarf Error: Can't find .debug_ranges section.
2.cc:(.text._ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED2Ev[_ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED5Ev]+0x44):
undefined reference to `__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*,
unsigned long)'
2.cc:(.text._ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED0Ev[_ZNSt7__cxx1115basic_stringbufIwSt11char_traitsIwESaIwEED5Ev]+0x44):
undefined reference to `__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*,
unsigned long)'
2.cc:(.text._Z6test01v+0x464): undefined reference to
`__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*, unsigned long)'
2.cc:(.text._Z6test01v+0x4c4): undefined reference to
`__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*, unsigned long)'
2.cc:(.text._Z6test01v+0x51c): undefined reference to
`__gnu_cxx::__pool_alloc<wchar_t>::deallocate(wchar_t*, unsigned long)'
collect2: error: ld returned 1 exit status

The specialization is explicitly instantiated in src/c++98/pool_allocator.cc:

  // Instantiations.
  template class __pool_alloc<char>;
  template class __pool_alloc<wchar_t>;

But the symbols have never been exported, so dynamic link fails (static linking
works though).

Similarly, when built with --enable-libstdcxx-allocator=mt lots of tests fail,
because the __gnu_cxx::__common_pool<__gnu_cxx::__pool,
true>::_S_get_pool()::_S_pool static variable and its guard variable are not
exported. That means the linker cannot combine the definition in libstdc++.so
with the one in user code, and we get two copies of it. This means allocations
and deallocations might happen in different pools, and so segfault.

And --enable-libstdcxx-allocator=bitmap is completely broken, see PR 103381.

it's not clear whether it's worth salvaging these extensions, or if we should
just deprecate and them remove them.

Reply via email to