llvm / llvm-project

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

Windows 11 on ARM64: Clang Build Failure: function too large #88368

Open hmelder opened 5 months ago

hmelder commented 5 months ago

I am experiencing a build failure when trying to build clang on Windows 11 ARM64 using the Visual Studio Compiler.

Current head: 938a73422e0b964eba16f272acdfae1d0281772c

cmake ^
  -G Ninja ^
  -DLLVM_ENABLE_PROJECTS="clang;lld" ^
  -DCMAKE_BUILD_TYPE=Debug ^
  -DLLVM_HOST_TRIPLE=aarch64-windows-msvc ^
  -DLLVM_TARGET_ARCH=AArch64 ^
  -DCOMPILER_RT_BUILD_SANITIZERS=OFF ^
  -DCOMPILER_RT_BUILD_XRAY=OFF ^
  -DLLVM_TARGETS_TO_BUILD="AArch64" ^
  -DLLVM_BUILD_RUNTIME=OFF ^
  -DLLVM_INSTALL_UTILS=ON ^
  -DLLVM_USE_LINKER=lld -S llvm -B build
[2821/4070] Building CXX object tools\clang\lib\CodeGen\CMakeFiles\obj.clangCodeGen.dir\CGBuiltin.cpp.obj
FAILED: tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGBuiltin.cpp.obj
"C:\PROGRA~1\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33721\bin\Hostarm64\arm64\cl.exe"  /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I"C:\Users\Hugo Melder\Documents\llvm-project\build\tools\clang\lib\CodeGen" -I"C:\Users\Hugo Melder\Documents\llvm-project\clang\lib\CodeGen" -I"C:\Users\Hugo Melder\Documents\llvm-project\clang\include" -I"C:\Users\Hugo Melder\Documents\llvm-project\build\tools\clang\include" -I"C:\Users\Hugo Melder\Documents\llvm-project\build\include" -I"C:\Users\Hugo Melder\Documents\llvm-project\llvm\include" /DWIN32 /D_WINDOWS   /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -w14062 -we4238 /Ob0 /Od /RTC1 -std:c++17 -MDd -Zi  /EHs-c- /GR- /showIncludes /Fotools\clang\lib\CodeGen\CMakeFiles\obj.clangCodeGen.dir\CGBuiltin.cpp.obj /Fdtools\clang\lib\CodeGen\CMakeFiles\obj.clangCodeGen.dir\ /FS -c "C:\Users\Hugo Melder\Documents\llvm-project\clang\lib\CodeGen\CGBuiltin.cpp"
C:\Users\Hugo Melder\Documents\llvm-project\clang\lib\CodeGen\CGBuiltin.cpp(21555) : fatal error C1053: '?EmitRISCVBuiltinExpr@CodeGenFunction@CodeGen@clang@@QEAAPEAVValue@llvm@@IPEBVCallExpr@3@VReturnValueSlot@23@@Z': function too large

CMakeConfigureLog.yaml.txt

llvmbot commented 5 months ago

@llvm/issue-subscribers-backend-aarch64

Author: Hugo Melder (hmelder)

I am experiencing a build failure when trying to build clang on Windows 11 ARM64 using the Visual Studio Compiler. Current head: 938a73422e0b964eba16f272acdfae1d0281772c ```sh cmake ^ -G Ninja ^ -DLLVM_ENABLE_PROJECTS="clang;lld" ^ -DCMAKE_BUILD_TYPE=Debug ^ -DLLVM_HOST_TRIPLE=aarch64-windows-msvc ^ -DLLVM_TARGET_ARCH=AArch64 ^ -DCOMPILER_RT_BUILD_SANITIZERS=OFF ^ -DCOMPILER_RT_BUILD_XRAY=OFF ^ -DLLVM_TARGETS_TO_BUILD="AArch64" ^ -DLLVM_BUILD_RUNTIME=OFF ^ -DLLVM_INSTALL_UTILS=ON ^ -DLLVM_USE_LINKER=lld -S llvm -B build ``` ```powershell [2821/4070] Building CXX object tools\clang\lib\CodeGen\CMakeFiles\obj.clangCodeGen.dir\CGBuiltin.cpp.obj FAILED: tools/clang/lib/CodeGen/CMakeFiles/obj.clangCodeGen.dir/CGBuiltin.cpp.obj "C:\PROGRA~1\Microsoft Visual Studio\2022\Preview\VC\Tools\MSVC\14.40.33721\bin\Hostarm64\arm64\cl.exe" /nologo /TP -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_ASSERTIONS -D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I"C:\Users\Hugo Melder\Documents\llvm-project\build\tools\clang\lib\CodeGen" -I"C:\Users\Hugo Melder\Documents\llvm-project\clang\lib\CodeGen" -I"C:\Users\Hugo Melder\Documents\llvm-project\clang\include" -I"C:\Users\Hugo Melder\Documents\llvm-project\build\tools\clang\include" -I"C:\Users\Hugo Melder\Documents\llvm-project\build\include" -I"C:\Users\Hugo Melder\Documents\llvm-project\llvm\include" /DWIN32 /D_WINDOWS /Zc:inline /Zc:preprocessor /Zc:__cplusplus /Oi /bigobj /permissive- /W4 -wd4141 -wd4146 -wd4244 -wd4267 -wd4291 -wd4351 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706 -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091 -wd4592 -wd4319 -wd4709 -wd5105 -wd4324 -w14062 -we4238 /Ob0 /Od /RTC1 -std:c++17 -MDd -Zi /EHs-c- /GR- /showIncludes /Fotools\clang\lib\CodeGen\CMakeFiles\obj.clangCodeGen.dir\CGBuiltin.cpp.obj /Fdtools\clang\lib\CodeGen\CMakeFiles\obj.clangCodeGen.dir\ /FS -c "C:\Users\Hugo Melder\Documents\llvm-project\clang\lib\CodeGen\CGBuiltin.cpp" C:\Users\Hugo Melder\Documents\llvm-project\clang\lib\CodeGen\CGBuiltin.cpp(21555) : fatal error C1053: '?EmitRISCVBuiltinExpr@CodeGenFunction@CodeGen@clang@@QEAAPEAVValue@llvm@@IPEBVCallExpr@3@VReturnValueSlot@23@@Z': function too large ``` [CMakeConfigureLog.yaml.txt](https://github.com/llvm/llvm-project/files/14944186/CMakeConfigureLog.yaml.txt)
efriedma-quic commented 5 months ago

I assume you can work around this by enabling optimizations or building with clang.

I'm a little confused why MSVC is complaining; AArch64 functions can easily be up to 128MB without any significant difficulties generating code, and this function shouldn't be anywhere near that big. But probably the function can be made smaller.

CC @topperc @4vtomat for context about CodeGenFunction::EmitRISCVBuiltinExpr.

hmelder commented 5 months ago

building with clang

I ended up doing this