Bug 31982 - [2.43 Regression] mir 2.17 build failure during an LTO enabled build
Summary: [2.43 Regression] mir 2.17 build failure during an LTO enabled build
Status: NEW
Alias: None
Product: binutils
Classification: Unclassified
Component: ld (show other bugs)
Version: 2.43
: P2 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2024-07-17 15:32 UTC by Matthias Klose
Modified: 2024-08-29 14:54 UTC (History)
3 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments
log of the build (5.71 KB, text/plain)
2024-08-29 14:14 UTC, Matthias Klose
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Klose 2024-07-17 15:32:42 UTC
the trunk (upcoming 2.43) fails to link an LTO enabled build, which succeeded to link with 2.42.  The failure is architecture independent. first seen 20240618, still seen with 20240710.

the original bug report is from
https://bugs.launchpad.net/ubuntu/+source/binutils/+bug/2070302

collecting all the object files for a reproducer ...
Comment 1 H.J. Lu 2024-07-17 21:05:46 UTC
I can't reproduce it with GCC 14 and binutils master 20240713:

$ /usr/bin/g++ -O2 -flto=auto -ffat-lto-objects -fexceptions -g -grecord-gcc-switches -pipe -Wall -Werror=format-security -Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=3 -Wp,-D_GLIBCXX_ASSERTIONS -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -fstack-protector-strong -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -m64 -march=x86-64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fno-omit-frame-pointer -mno-omit-leaf-frame-pointer -pthread -g -Wall -fno-strict-aliasing  -Wnon-virtual-dtor -Wextra -fPIC  -Wno-mismatched-tags -Wno-psabi -flto -ffat-lto-objects -Wno-error=null-dereference -Wno-error=overloaded-virtual -Wno-sign-compare -Wno-error=maybe-uninitialized  -Wno-pedantic -Wl,-z,relro -Wl,--as-needed  -Wl,-z,pack-relative-relocs -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1  -Wl,--build-id=sha1 -specs=/usr/lib/rpm/redhat/redhat-package-notes -Wl,--as-needed    -Wl,--no-undefined tests/miral/CMakeFiles/miral-test.dir/external_client.cpp.o tests/miral/CMakeFiles/miral-test.dir/runner.cpp.o tests/miral/CMakeFiles/miral-test.dir/wayland_extensions.cpp.o tests/miral/CMakeFiles/miral-test.dir/zone.cpp.o tests/miral/CMakeFiles/miral-test.dir/server_example_decoration.cpp.o tests/miral/CMakeFiles/miral-test.dir/org_kde_kwin_server_decoration.c.o tests/miral/CMakeFiles/miral-test.dir/server-decoration_wrapper.cpp.o -o bin/miral-test.bin  tests/libmir-test-assist.a  lib/libmiral.so.7  lib/libmirserver.so.60  /usr/lib64/libuuid.so  src/platforms/common/server/libserver_platform_common.a  lib/libmirplatform.so.28  lib/libmirwayland.so.5  lib/libmircommon.so.10  /usr/lib64/libboost_filesystem.so.1.83.0  /usr/lib64/libboost_atomic.so.1.83.0  -ldl  /usr/lib64/libxkbcommon.so  /usr/lib64/libboost_program_options.so.1.83.0  /usr/lib64/libepoxy.so  lib/libmircore.so.2  /usr/lib64/libwayland-server.so  src/platforms/common/server/kms-utils/libkms_utils.a  /usr/lib64/libboost_iostreams.so.1.83.0  /usr/lib64/libdrm.so  /usr/lib64/libEGL.so  /usr/lib64/libGLESv2.so  /usr/lib64/libudev.so  /usr/lib64/libglib-2.0.so  /usr/lib64/libgobject-2.0.so  /usr/lib64/libgio-2.0.so  /usr/lib64/libxcb.so  /usr/lib64/libxcb-composite.so  /usr/lib64/libxcb-xfixes.so  /usr/lib64/libxcb-randr.so  /usr/lib64/libxcb-render.so  /usr/lib64/libXcursor.so  /usr/lib64/liblttng-ust.so  /usr/lib64/liblttng-ust-common.so  /usr/lib64/libdl.a  /usr/lib64/libfreetype.so  -latomic  /usr/lib64/libboost_system.so.1.83.0  -lgtest  -lgtest_main  -lgmock  -lgtest  -lgtest_main  -lgmock  /usr/lib64/libwayland-client.so
$
Comment 2 Matthias Klose 2024-07-18 06:57:04 UTC
when building with 14, I get different issues:

/usr/bin/ld: CMakeFiles/mir_unit_tests.dir/frontend_wayland/test_desktop_file_manager.cpp.o: in function `DesktopFileManager_can_resolve_from_valid_flatpak_info_Test::TestBody()':
Comment 3 Sam James 2024-07-19 05:12:52 UTC
I tried briefly with GCC trunk and it built OK here too.

Could you link to or attach a full build log here while you're working on gathering it into something standalone?
Comment 4 Matthias Klose 2024-08-28 15:22:47 UTC
still seen with the 2.43.1 releases with aarch64-linux-gnu and arm-linux-gnueabihf, object files for aarch64 are at
https://people.debian.org/~doko/tmp/pr31982.tar.xz
Comment 5 Matthias Klose 2024-08-28 15:23:45 UTC
fails with

/usr/bin/ld: /tmp/ccijjp3k.ltrans5.ltrans.o: in function `StaticDisplayConfig_nonexistent_config_file_is_no_error_Test::TestBody()':
/usr/src/mir-2.14.1-7/tests/miral/static_display_config.cpp:154:(.text+0x6d94): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
/usr/bin/ld: ../libmir-test-assist.a(mmap_wrapper.cpp.o): in function `std::literals::string_literals::operator"" s[abi:cxx11](char const*, unsigned long)':
/usr/include/c++/14/bits/basic_string.h:4694:(.text+0x6f8): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&)'
/usr/bin/ld: /usr/include/c++/14/bits/basic_string.h:4694:(.text+0xa64): undefined reference to `std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&)'
collect2: error: ld returned 1 exit status
Comment 6 H.J. Lu 2024-08-28 17:41:42 UTC
(In reply to Matthias Klose from comment #5)
> fails with
> 
> /usr/bin/ld: /tmp/ccijjp3k.ltrans5.ltrans.o: in function
> `StaticDisplayConfig_nonexistent_config_file_is_no_error_Test::TestBody()':
> /usr/src/mir-2.14.1-7/tests/miral/static_display_config.cpp:154:(.
> text+0x6d94): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
> /usr/bin/ld: ../libmir-test-assist.a(mmap_wrapper.cpp.o): in function
> `std::literals::string_literals::operator"" s[abi:cxx11](char const*,
> unsigned long)':
> /usr/include/c++/14/bits/basic_string.h:4694:(.text+0x6f8): undefined
> reference to `std::__cxx11::basic_string<char, std::char_traits<char>,
> std::allocator<char> >::basic_string(char const*, unsigned long,
> std::allocator<char> const&)'
> /usr/bin/ld: /usr/include/c++/14/bits/basic_string.h:4694:(.text+0xa64):
> undefined reference to `std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
> unsigned long, std::allocator<char> const&)'
> collect2: error: ld returned 1 exit status

On Fedora 40/x86-64, I got

[hjl@gnu-cfl-3 lib64]$ readelf --dyn-syms -W /usr/lib64/libstdc++.so.6.0.33 | grep 00000000000c1a20
  1727: 00000000000c1a20    42 FUNC    WEAK   DEFAULT    4 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2EPKcmRKS3_@@GLIBCXX_3.4.21
  4081: 00000000000c1a20    42 FUNC    WEAK   DEFAULT    4 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcmRKS3_@@GLIBCXX_3.4.21
[hjl@gnu-cfl-3 lib64]$ readelf --dyn-syms -W /usr/lib64/libstdc++.so.6.0.33 | grep 00000000000c1a20 | c++filt 
  1727: 00000000000c1a20    42 FUNC    WEAK   DEFAULT    4 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&)@@GLIBCXX_3.4.21
  4081: 00000000000c1a20    42 FUNC    WEAK   DEFAULT    4 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&)@@GLIBCXX_3.4.21
[hjl@gnu-cfl-3 lib64]$ 

What do you get?
Comment 7 Matthias Klose 2024-08-29 08:00:32 UTC
$ readelf --dyn-syms -W /lib/aarch64-linux-gnu/libstdc++.so.6.0.33 | grep _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC.EPKcmRKS3_
  1741: 0000000000167380    60 FUNC    WEAK   DEFAULT   13 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC2EPKcmRKS3_@@GLIBCXX_3.4.21
  4088: 0000000000167380    60 FUNC    WEAK   DEFAULT   13 _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC1EPKcmRKS3_@@GLIBCXX_3.4.21

$ readelf --dyn-syms -W /lib/aarch64-linux-gnu/libstdc++.so.6.0.33 | grep _ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEC.EPKcmRKS3_|c++filt
  1741: 0000000000167380    60 FUNC    WEAK   DEFAULT   13 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&)@@GLIBCXX_3.4.21
  4088: 0000000000167380    60 FUNC    WEAK   DEFAULT   13 std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >::basic_string(char const*, unsigned long, std::allocator<char> const&)@@GLIBCXX_3.4.21
Comment 8 H.J. Lu 2024-08-29 13:00:57 UTC
(In reply to Matthias Klose from comment #5)
> fails with
> 
> /usr/bin/ld: /tmp/ccijjp3k.ltrans5.ltrans.o: in function
> `StaticDisplayConfig_nonexistent_config_file_is_no_error_Test::TestBody()':
> /usr/src/mir-2.14.1-7/tests/miral/static_display_config.cpp:154:(.
> text+0x6d94): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
> /usr/bin/ld: ../libmir-test-assist.a(mmap_wrapper.cpp.o): in function
> `std::literals::string_literals::operator"" s[abi:cxx11](char const*,
> unsigned long)':
> /usr/include/c++/14/bits/basic_string.h:4694:(.text+0x6f8): undefined
> reference to `std::__cxx11::basic_string<char, std::char_traits<char>,
> std::allocator<char> >::basic_string(char const*, unsigned long,
> std::allocator<char> const&)'
> /usr/bin/ld: /usr/include/c++/14/bits/basic_string.h:4694:(.text+0xa64):
> undefined reference to `std::__cxx11::basic_string<char,
> std::char_traits<char>, std::allocator<char> >::basic_string(char const*,
> unsigned long, std::allocator<char> const&)'
> collect2: error: ld returned 1 exit status

I can't reproduce it on Fedora 40/x86-64.  It may have something to do
with how your GCC is configured and the command-line options passed to linker.
Please show the output of

# gcc -v

as well as pass -v to the final link command and show the full linker command
line.
Comment 9 Matthias Klose 2024-08-29 14:14:58 UTC
Created attachment 15688 [details]
log of the build
Comment 10 Matthias Klose 2024-08-29 14:16:15 UTC
$ gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-linux-gnu/14/lto-wrapper
OFFLOAD_TARGET_NAMES=nvptx-none
OFFLOAD_TARGET_DEFAULT=1
Target: aarch64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu 14.2.0-3ubuntu1' --with-bugurl=file:///usr/share/doc/gcc-14/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++,m2,rust --prefix=/usr --with-gcc-major-version-only --program-suffix=-14 --program-prefix=aarch64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/libexec --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-libstdcxx-backtrace --enable-gnu-unique-object --disable-libquadmath --disable-libquadmath-support --enable-plugin --enable-default-pie --with-system-zlib --enable-libphobos-checking=release --with-target-system-zlib=auto --enable-objc-gc=auto --enable-multiarch --enable-fix-cortex-a53-843419 --disable-werror --enable-offload-targets=nvptx-none=/build/gcc-14-3heZVg/gcc-14-14.2.0/debian/tmp-nvptx/usr --enable-offload-defaulted --without-cuda-driver --enable-checking=release --build=aarch64-linux-gnu --host=aarch64-linux-gnu --target=aarch64-linux-gnu --with-build-config=bootstrap-lto-lean --enable-link-serialization=2
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 14.2.0 (Ubuntu 14.2.0-3ubuntu1)
Comment 11 H.J. Lu 2024-08-29 14:26:02 UTC
(In reply to Matthias Klose from comment #9)
> Created attachment 15688 [details]
> log of the build

Does it fail on x86-64?
Comment 12 Matthias Klose 2024-08-29 14:47:44 UTC
sorry, I didn't mention the architectures. It fails on aarch64-linux-gnu, arm-linux-gnueabihf, arm-linux-gnueabi, alpha-linux-gnu, powerpc-linux-gnu and sparc64-linux-gnu. Other architectures work ok, see
https://buildd.debian.org/status/package.php?p=mir
Comment 13 H.J. Lu 2024-08-29 14:54:39 UTC
(In reply to Matthias Klose from comment #12)
> sorry, I didn't mention the architectures. It fails on aarch64-linux-gnu,
> arm-linux-gnueabihf, arm-linux-gnueabi, alpha-linux-gnu, powerpc-linux-gnu
> and sparc64-linux-gnu. Other architectures work ok, see
> https://buildd.debian.org/status/package.php?p=mir

Can you bisect which commit caused this? Some bugs may be only fixed on x86.
If you have a self-contained test for aarch64-linux-gnu cross compiler, I
can take a look.