llvm / llvm-project

The LLVM Project is a collection of modular and reusable compiler and toolchain technologies.
http://llvm.org
Other
28.59k stars 11.82k forks source link

[lld] build failure #107511

Closed trcrsired closed 1 month ago

trcrsired commented 1 month ago
[6/1027] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj
FAILED: tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj 
/home/cqwrteur/toolchains/llvm/x86_64-generic-linux-gnu/llvm/bin/clang++ --target=x86_64-windows-gnu --sysroot=/home/cqwrteur/toolchains/llvm/x86_64-windows-gnu/x86_64-windows-gnu -DGTEST_HAS_RTTI=0 -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/cqwrteur/toolchains_build/toolchainbuildscripts/llvm/.llvmartifacts/x86_64-windows-gnu/llvm/tools/lld/MachO -I/home/cqwrteur/toolchains_build/llvm-project/lld/MachO -I/home/cqwrteur/toolchains_build/llvm-project/lld/include -I/home/cqwrteur/toolchains_build/toolchainbuildscripts/llvm/.llvmartifacts/x86_64-windows-gnu/llvm/tools/lld/include -I/home/cqwrteur/toolchains_build/toolchainbuildscripts/llvm/.llvmartifacts/x86_64-windows-gnu/llvm/include -I/home/cqwrteur/toolchains_build/llvm-project/llvm/include -I/home/cqwrteur/toolchains_build/llvm-project/llvm/../libunwind/include -rtlib=compiler-rt -fuse-ld=lld -stdlib=libc++ -lc++abi -Wno-unused-command-line-argument -lunwind -stdlib=libc++ -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -flto=thin -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -MD -MT tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj -MF tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj.d -o tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj -c /home/cqwrteur/toolchains_build/llvm-project/lld/MachO/Symbols.cpp
/home/cqwrteur/toolchains_build/llvm-project/lld/MachO/Symbols.cpp:24:15: error: static assertion failed due to requirement 'sizeof(void *) != 8 || sizeof(lld::macho::Defined) == 88': Try to minimize Defined's size; we create many instances
   24 | static_assert(sizeof(void *) != 8 || sizeof(Defined) == 88,
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
[15/1027] Linking CXX shared library bin/libLLVMX86CodeGen.dll
ninja: build stopped: subcommand failed.
trcrsired commented 1 month ago

@BertalanD @alx32

alx32 commented 1 month ago

@trcrsired thanks for reporting. This is probably because of https://github.com/llvm/llvm-project/pull/106573. Do you happen to have repro steps for this - i.e the OS and command that sets up this build environment ?

trcrsired commented 1 month ago

@trcrsired thanks for reporting. This is probably because of #106573. Do you happen to have repro steps for this - i.e the OS and command that sets up this build environment ?

i do canadian compilation for windows on linux. cross compile windows clang on linux

llvmbot commented 1 month ago

@llvm/issue-subscribers-lld-macho

Author: cqwrteur (trcrsired)

``` [6/1027] Building CXX object tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj FAILED: tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj /home/cqwrteur/toolchains/llvm/x86_64-generic-linux-gnu/llvm/bin/clang++ --target=x86_64-windows-gnu --sysroot=/home/cqwrteur/toolchains/llvm/x86_64-windows-gnu/x86_64-windows-gnu -DGTEST_HAS_RTTI=0 -D_FILE_OFFSET_BITS=64 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/cqwrteur/toolchains_build/toolchainbuildscripts/llvm/.llvmartifacts/x86_64-windows-gnu/llvm/tools/lld/MachO -I/home/cqwrteur/toolchains_build/llvm-project/lld/MachO -I/home/cqwrteur/toolchains_build/llvm-project/lld/include -I/home/cqwrteur/toolchains_build/toolchainbuildscripts/llvm/.llvmartifacts/x86_64-windows-gnu/llvm/tools/lld/include -I/home/cqwrteur/toolchains_build/toolchainbuildscripts/llvm/.llvmartifacts/x86_64-windows-gnu/llvm/include -I/home/cqwrteur/toolchains_build/llvm-project/llvm/include -I/home/cqwrteur/toolchains_build/llvm-project/llvm/../libunwind/include -rtlib=compiler-rt -fuse-ld=lld -stdlib=libc++ -lc++abi -Wno-unused-command-line-argument -lunwind -stdlib=libc++ -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -ffunction-sections -fdata-sections -flto=thin -O3 -DNDEBUG -std=c++17 -fno-exceptions -funwind-tables -fno-rtti -MD -MT tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj -MF tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj.d -o tools/lld/MachO/CMakeFiles/lldMachO.dir/Symbols.cpp.obj -c /home/cqwrteur/toolchains_build/llvm-project/lld/MachO/Symbols.cpp /home/cqwrteur/toolchains_build/llvm-project/lld/MachO/Symbols.cpp:24:15: error: static assertion failed due to requirement 'sizeof(void *) != 8 || sizeof(lld::macho::Defined) == 88': Try to minimize Defined's size; we create many instances 24 | static_assert(sizeof(void *) != 8 || sizeof(Defined) == 88, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated. [15/1027] Linking CXX shared library bin/libLLVMX86CodeGen.dll ninja: build stopped: subcommand failed. ```
trcrsired commented 1 month ago

https://github.com/llvm/llvm-project/blob/main/lld/MachO/Symbols.cpp#L23 @alx32 this is wrong. I use windows-gnu, so _MSC_VER is not defined. Plus i guess cygwin does not work either.

trcrsired commented 1 month ago

@alx32 can we remove this static_assert? A lot of platforms do not work correctly. x86_64-windows-gnu, x86_64-windows-msvc, x86_64-cygwin, UEFI etc they all fail to work

alx32 commented 1 month ago

Sure, I will submit a patch soon

trcrsired commented 1 month ago

ty

alx32 commented 1 month ago

https://github.com/llvm/llvm-project/pull/107514

mstorsjo commented 1 month ago

FWIW, the reason why d1756165a9066f907b88d51dd8e3ffee15a8cc1e breaks things, is probably because of the change at https://github.com/llvm/llvm-project/commit/d1756165a9066f907b88d51dd8e3ffee15a8cc1e#diff-1d1c93151f6708c960053c32c0dc1fda887d546d9aa9a86387936f3e640c9d2dR155 :

-  bool wasIdenticalCodeFolded : 1;
+  ICFFoldKind identicalCodeFoldingKind : 2;

Under the MS struct packing rules, the ICFFoldKind can't be packed tightly with bool - MS only packs bitfield members tightly if they have they same underlying type - look up docs for -mms-bitfields. https://developercommunity.visualstudio.com/t/Non-conforming-bit-field-packing-in-C/10641514 is a very concise example of this issue.

@alx32 can we remove this static_assert? A lot of platforms do not work correctly. x86_64-windows-gnu, x86_64-windows-msvc

To be clear here - this change wasn't a build break for x86_64-windows-msvc as the static assert was already ifdeffed out.

But changing the ifdef to #ifndef _WIN32 also should work, then you could add a comment about the bitfield packing issue as reference for mingw. I guess extending it to cover cygwin also could work.

I don't know about UEFI targets though (does anybody compile LLD to run in UEFI?)