Clang-14.0.6+ld.ldd linking fails with undefined symbols throw_bad_array_new_length() / libc_single_threaded

Dear Team,

Clang-14.0.6 compilation of source code (c files) fails during linking using ld.lld with below undefined symbols. This issue is observed with glibc-2.35 version.
{{
ld.lld: error: undefined symbol: std::__throw_bad_array_new_length()

referenced by new_allocator.h:125 (/x86_64-linux-gnu/include/c++/12.1.0/bits/new_allocator.h:125)
compiler.cpp.o:(ue2::buildGraph(ue2::ReportManager&, ue2::CompileContext const&, ue2::ParsedExpression const&)) in archive …/…/cooked/lib/libhs.a
referenced by new_allocator.h:125 (/x86_64-linux-gnu/include/c++/12.1.0/bits/new_allocator.h:125)
ng_calc_components.cpp.o:(std::deque<ue2::graph_detail::vertex_descriptor<ue2::ue2_graph<ue2::NGHolder, ue2::NFAGraphVertexProps, ue2::NFAGraphEdgeProps> >, std::allocator<ue2::graph_detail::vertex_descriptor<ue2::ue2_graph<ue2::NGHolder, ue2::NFAGraphVertexProps, ue2::NFAGraphEdgeProps> > > >::_M_reallocate_map(unsigned long, bool)) in archive …/…/cooked/lib/libhs.a
referenced by new_allocator.h:125 (/x86_64-linux-gnu/include/c++/12.1.0/bits/new_allocator.h:125)
ng_calc_components.cpp.o:(std::deque<std::unique_ptr<ue2::NGHolder, std::default_deleteue2::NGHolder >, std::allocator<std::unique_ptr<ue2::NGHolder, std::default_deleteue2::NGHolder > > >::_M_reallocate_map(unsigned long, bool)) in archive …/…/cooked/lib/libhs.a
referenced 416 more times

ld.lld: error: undefined symbol: __libc_single_threaded

referenced by atomicity.h:108 (/x86_64-linux-gnu/include/c++/12.1.0/ext/atomicity.h:108)
ng_cyclic_redundancy.cpp.o:(bool ue2::removeCyclicPathRedundancyue2::NGHolder(ue2::NGHolder&, ue2::NGHolder::vertex_descriptor, ue2::NGHolder&) (.isra.0)) in archive …/…/cooked/lib/libhs.a
referenced by atomicity.h:98 (/x86_64-linux-gnu/include/c++/12.1.0/ext/atomicity.h:98)
ng_cyclic_redundancy.cpp.o:(bool ue2::removeCyclicPathRedundancyue2::NGHolder(ue2::NGHolder&, ue2::NGHolder::vertex_descriptor, ue2::NGHolder&) (.isra.0)) in archive …/…/cooked/lib/libhs.a
referenced by atomicity.h:98 (/x86_64-linux-gnu/include/c++/12.1.0/ext/atomicity.h:98)
ng_cyclic_redundancy.cpp.o:(bool ue2::removeCyclicPathRedundancyue2::NGHolder(ue2::NGHolder&, ue2::NGHolder::vertex_descriptor, ue2::NGHolder&) (.isra.0)) in archive …/…/cooked/lib/libhs.a
referenced 818 more times
clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
}}
Please let me know if any input in handling above error?

Regards
koti

Hi,

passed libstdc++ path to resolve throw_bad_array_new_length() to LDFLAGS.
But passing libc.so.6 (glibc-2.35) path to LDFLAGS is not resolving below error
{{
ld.lld: error: undefined symbol: __libc_single_threaded
}}

Rgds

Hi,

gcc-12 linker is not reporting any undefined symbol mentioned in previous comment but clang (ld.lld) only reporting “undefined symbol: __libc_single_threaded” issue with glibc-2.35 installed to toolchain.