This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: g++ 8.1, AIX, std::thread::_State linking
- From: Jonathan Wakely <jwakely dot gcc at gmail dot com>
- To: Brian Groose <brian at groose dot com>
- Cc: gcc-help <gcc-help at gcc dot gnu dot org>
- Date: Thu, 24 May 2018 11:01:10 +0100
- Subject: Re: g++ 8.1, AIX, std::thread::_State linking
- References: <CAKMEP22K0aOY1WhgYNhm1GRnc3wvA0vG-e3db0HWFLC2yQ=nug@mail.gmail.com>
On 24 May 2018 at 02:44, Brian Groose wrote:
> I'm moving from g++ 5.3.0 to 8.1.0 at the moment, and bumped into an
> unexpected linker failure on AIX. I don't currently have a small
> piece of code that reproduces the issue, but I'm working on narrowing
> it down. Hopefully someone can make a suggestion without code,
> though. I've build gcc 8.1.0 from source with no special options
> except --prefix and --enable-languages=c,c++
>
> These are the AIX linker errors using g++ 8.1.0:
> ld: 0711-317 ERROR: Undefined symbol: typeinfo for std::thread::_State
> ld: 0711-317 ERROR: Undefined symbol: .std::thread::_State::~_State()
> ld: 0711-317 ERROR: Undefined symbol:
> .std::thread::_M_start_thread(std::unique_ptr<std::thread::_State,
> std::default_delete<std::thread::_State> >, void (*)())
> ld: 0711-317 ERROR: Undefined symbol: vtable for std::thread::_State
>
> This worked fine, the same code, on g++ 5.3.0.
>
> This looks similar to
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=52887 except for
> std::thread. It seems to happen when std::thread is used to call a
> member function, though a simple test case worked fine.
That bug was fixed by adding explicit instantiations to the library,
but the undefined symbols you're seeing are not templates, and are
defined in libstdc++.so
The only way those symbols would not be in libstdc++.so is if this
condition is false when building libstdc++.so but true when compiling
your own code:
#if defined(_GLIBCXX_HAS_GTHREADS) && defined(_GLIBCXX_USE_C99_STDINT_TR1)
Alternatively, you're simply not linking to libstdc++ correctly (or at
all). What is your linker command that fails?