Comment 3 for bug 1958984

Revision history for this message
Chris Halse Rogers (raof) wrote :

Ok. This would appear to be a ld bug. In a partially built tree, I get:

> /usr/bin/c++ -g -O2 -ffile-prefix-map=/home/chris/Canonical/Mir/mir/main/cmake-build-debug=. -flto=auto -ffat-lto-objects -flto=auto -ffat-lto-objects -fstack-protector-strong -Wformat -Werror=format-security -pthread -g -Wall -fno-strict-aliasing -pedantic -Wnon-virtual-dtor -Wextra -fPIC -Werror -Wno-mismatched-tags -Wno-psabi -g -Wl,-Bsymbolic-functions -flto=auto -ffat-lto-objects -flto=auto -Wl,-z,relro -Wl,--as-needed -Wl,--no-undefined examples/miral-system-compositor/CMakeFiles/miral-system-compositor.dir/system_compositor_main.cpp.o -o bin/miral-system-compositor.bin lib/libmiral.so.4 lib/libmircommon.so.8 lib/libmircookie.so.2 -lnettle /usr/lib/x86_64-linux-gnu/libboost_date_time.so.1.74.0 /usr/lib/x86_64-linux-gnu/libboost_program_options.so.1.74.0 /usr/lib/x86_64-linux-gnu/libboost_filesystem.so.1.74.0 /usr/lib/x86_64-linux-gnu/libboost_iostreams.so.1.74.0 -ldl /usr/lib/x86_64-linux-gnu/libxkbcommon.so lib/libmircore.so.1 /usr/lib/x86_64-linux-gnu/libboost_system.so.1.74.0 -L/usr/lib/x86_64-linux-gnu -Wl,-rpath-link,/home/chris/Canonical/Mir/mir/main/cmake-build-debug/lib
/usr/bin/ld: /lib/x86_64-linux-gnu/libyaml-cpp.so.0.7: undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)@GLIBCXX_3.4.21'
collect2: error: ld returned 1 exit status

This symbol, with correct version, is defined in libstdc++.so.6:
objdump -T -C /lib/x86_64-linux-gnu/libstdc++.so.6 | rg "std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create"
0000000000146910 w DF .text 000000000000005c GLIBCXX_3.4.21 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::_M_create(unsigned long&, unsigned long)

Adding -fuse-ld=gold or -fuse-ld=lld to the command line results in a successful link.

It doesn't seem to be a problem of the /usr/bin/c++ driver failing to add libstdc++ to the link args, as manually adding -lstdc++ to the end of the command doesn't change the output.