https://gcc.gnu.org/bugzilla/show_bug.cgi?id=59768
cctsai57 <cctsai57 at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |cctsai57 at gmail dot com --- Comment #6 from cctsai57 <cctsai57 at gmail dot com> --- Hi, Use 'configure CXXFLAGS=-O0' and make gcc successfully, but the generated libstdc++.so has the following problem: ~~~~~ BEGIN ~~~~~ $ cat test.cc int main() { return 0; } $ g++ test.cc /work2/gcc-x86_64/local/lib/gcc/x86_64-pc-linux-gnu/6.0.0/../../../../lib64/libstdc++.so: undefined reference to `std::_Unwrap<std::reference_wrapper<std::thread>, std::decay<std::reference_wrapper<std::thread> >::type>::type std::__invfwd<std::reference_wrapper<std::thread> >(std::remove_reference<std::reference_wrapper<std::thread> >::type&)' collect2: error: ld returned 1 exit status $ g++ -v Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/work2/gcc-x86_64/local/libexec/gcc/x86_64-pc-linux-gnu/6.0.0/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /work2/gcc-x86_64/gcc-src/configure --enable-languages=c,c++ --prefix=/work2/gcc-x86_64/local --disable-bootstrap CXXFLAGS=-O0 Thread model: posix gcc version 6.0.0 20151222 (experimental) (GCC) $ ld -v GNU ld version 2.25-9.fc22 ~~~~~END~~~~~ I guess that '-O0' causes the '__invfwd' not inlined, and the libstdc++.so building option '-fno-implicit-templates' causes the '__invfwd' template not instantiated. I add 'inline' to '__invfwd' to solve this problem, but I'm not sure if it's right or not: diff --git a/libstdc++-v3/include/std/functional b/libstdc++-v3/include/std/functional index b994df4..9b853e8 100644 --- a/libstdc++-v3/include/std/functional +++ b/libstdc++-v3/include/std/functional @@ -207,7 +207,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Used by __invoke_impl instead of std::forward<_Tp> so that a // reference_wrapper is converted to an lvalue-reference. template<typename _Tp> - typename _Unwrap<_Tp>::type + inline typename _Unwrap<_Tp>::type __invfwd(typename remove_reference<_Tp>::type& __t) noexcept { return _Unwrap<_Tp>::_S_fwd(__t); }