Open ColinHexagon opened 6 months ago
@llvm/issue-subscribers-lld-coff
Author: None (ColinHexagon)
Are you able to test the link step with the latest LLD, see if the bug is still present?
Are you able to make a link reproducer? Add -reproduce:repro.tar
to the lld-link
command, and it will bundle up all relevant input files into a file, which can be shared with us, allowing anybody to reproduce the same error.
@mstorsjo I have run into this problem as well.
Reproducer attached. repro.zip
@mstorsjo I have run into this problem as well.
Thanks, I'm able to reproduce this error using this package.
@mstorsjo I have run into this problem as well.
Reproducer attached. repro.zip
While it's possible to reproduce the issue with this, it's a bit hard to get an overview of what's really happening...
Are you able to reduce the reproducer on a source level, so that you'd be able to share a minimal (or at least small) source level reproducer for the issue?
I had a quick look at this, and something goes wrong in some of the LTO optimization passes. If looking at the input file root/psinex/build/aarch64-win-rel/ext/catch2/CMakeFiles/ext.catch2.obj.dir/catch2/internal/catch_test_case_tracker.cpp.obj
, running llvm-dis
on it, I get IR that contains this:
$"??_7SectionTracker@TestCaseTracking@Catch@@6B@" = comdat any
[...]
@"??_7SectionTracker@TestCaseTracking@Catch@@6B@" = linkonce_odr unnamed_addr constant { [6 x ptr] } { [6 x ptr] [ptr @"??_GSectionTracker@TestCaseTracking@Catch@@UEAAPEAXI@Z", ptr @"?isComplete@SectionTracker@TestCaseTracking@Catch@@UEBA_NXZ", ptr @"?close@TrackerBase@TestCaseTracking@Catch@@UEAAXXZ", ptr @"?fail@TrackerBase@TestCaseTracking@Catch@@UEAAXXZ", ptr @"?isSectionTracker@SectionTracker@TestCaseTracking@Catch@@UEBA_NXZ", ptr @"?isGeneratorTracker@ITracker@TestCaseTracking@Catch@@UEBA_NXZ"] }, comdat, !type !0, !type !15, !type !31, !vcall_visibility !1
I.e. we have a declaration and a definition of this comdat object.
If I run the LTO compilation with lld-link @response.txt -lldemit:llvm -out:out.bc
, then convert the LTO output with llvm-dis out.bc
back into textual IR, I see this:
$"??_7SectionTracker@TestCaseTracking@Catch@@6B@" = comdat any
I only see a declaration of the comdat, but no definition. There's one reference to it elsewhere in the LTO output:
@"__typeid_?AVITracker@TestCaseTracking@Catch@@_32_unique_member" = hidden unnamed_addr constant { [6 x ptr] } { [6 x ptr] [ptr @"??_GSectionTracker@TestCaseTracking@Catch@@UEAAPEAXI@Z.llvm.merged", ptr @"?isComplete@SectionTracker@TestCaseTracking@Catch@@UEBA_NXZ.llvm.merged", ptr @"?close@TrackerBase@TestCaseTracking@Catch@@UEAAXXZ", ptr @"?fail@TrackerBase@TestCaseTracking@Catch@@UEAAXXZ", ptr @"?isSectionTracker@SectionTracker@TestCaseTracking@Catch@@UEBA_NXZ", ptr @"?isGeneratorTracker@ITracker@TestCaseTracking@Catch@@UEBA_NXZ"] }, comdat($"??_7SectionTracker@TestCaseTracking@Catch@@6B@"), !type !54728, !type !54729, !type !55527
So, during the LTO optimization phases, something optimizes out the definition of this comdat, even if it evidently still is needed somewhere.
@llvm/issue-subscribers-backend-x86
Author: None (ColinHexagon)
Could you please try 19 or main
branch?
Could you please try 19 or
main
branch?
The reproducer provided by @mizvekov above does reproduce the issue still on latest git main.
@mstorsjo
I have managed to produce a whole-project reduction. This became easier with recent non-released c-vise, which added support for recursively adding multiple test cases while keeping project structure intact.
So I am providing attached a cmake-project on zip file: test.zip
It needs access to windows sdk libraries. This is the command I use to generate the needed xwin
directory:
xwin --accept-license --manifest-version 17 --temp --arch aarch64 splat --preserve-ms-arch-notation --disable-symlinks --output xwin
Then edit CMakeUserConfig.json
to point to that xwin directory.
You can see the build instructions in the included interestingness test test.sh
.
These sources are as produced from c-vise reduction, I have not had time to manually reduce them.
If you need to further reduce them using c-vise, then grab c-vise from main branch and run:
cvise.py --tidy test.sh (find . -type f -not -name test.sh)
@mstorsjo
I have managed to produce a whole-project reduction. This became easier with recent non-released c-vise, which added support for recursively adding multiple test cases while keeping project structure intact.
So I am providing attached a cmake-project on zip file: test.zip It needs access to windows sdk libraries. This is the command I use to generate the needed
xwin
directory:xwin --accept-license --manifest-version 17 --temp --arch aarch64 splat --preserve-ms-arch-notation --disable-symlinks --output xwin
Thanks!
I managed to reproduce this (although I used tools installed with http://github.com/mstorsjo/msvc-wine/ so I had to tweak the paths a little bit).
I managed to detach the build procedure from CMake, so the issue can be reproduced with the source files you included, and the following commands:
clang++ -std=gnu++23 --target=aarch64-pc-windows-msvc -fwhole-program-vtables -flto=full -O -Wno-everything -x c++-module -fmodule-output=std.pcm -o std.cppm.obj -c std.cppm
clang++ -std=gnu++23 --target=aarch64-pc-windows-msvc -fwhole-program-vtables -flto=full -O -Wno-everything -fmodule-file=std.pcm -o catch2.cpp.obj -c catch2.cpp
lld-link std.cppm.obj catch2.cpp.obj -out:out.exe libcmt.lib
(Assuming that the right $INCLUDE
and $LIB
environment variables are set up.)
Hello,
While building a C++ project with clang (Release options, -fprofile-instr-generate -fcoverage-mapping -emit-llvm) on Windows, lld-link.exe crashed? and asked me to create a bug report here.
This following error is printed:
Followed by: