Add a new CMake file to expand on for more problematic configurations
in the future.
Related to #54645
Differential D123777
[CMake] Check for problematic MSVC + /arch:AVX configuration thieta on Apr 14 2022, 3:23 AM. Authored by
Details Add a new CMake file to expand on for more problematic configurations Related to #54645
Diff Detail
Unit Tests Event TimelineComment Actions I'd like this to go in as we have so little control over the MSVC crash (and have struggled to even reduce the repro), but I'm not an expert on cmake or llvm's cmake style Comment Actions LGTM
Comment Actions In case it helps anyone in the future: I ran % /Applications/CMake.app/Contents/bin/cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DLLVM_ENABLE_PROJECTS='clang;lld' -DLLVM_ENABLE_RUNTIMES='compiler-rt' -DLLVM_APPEND_VC_REV=NO -DLLVM_TARGETS_TO_BUILD='X86' ../llvm-project/llvm followed by % ninja runtimes <y build eventually failed with: ... [2736/2740] Performing configure step for 'runtimes' -- Linker detection: ld64 CMake Error at /Users/thakis/src/llvm-project/llvm/cmake/modules/CheckProblematicConfigurations.cmake:14 (if): if given arguments: "STREQUAL" "MSVC" Unknown arguments specified Call Stack (most recent call first): /Users/thakis/src/llvm-project/llvm/cmake/modules/HandleLLVMOptions.cmake:10 (include) CMakeLists.txt:149 (include) That error went away with the obvious patch [1], but then things failed later like so: CMake Error at /Users/thakis/src/llvm-project/compiler-rt/CMakeLists.txt:450 (message): -g is not supported by host compiler The problem was that I'm on an arm64 system but didn't include AArch64 in LLVM_TARGETS_TO_BUILD, so runtimes/runtimes-bins/CMakeFiles/CMakeError.log ended up with lots of error: unable to create target: 'No available targets are compatible with triple "arm64-apple-macosx12.0.0"'. The fix, of course, was to add both ARM and AArch64 to LLVM_TARGETS_TO_BUILD in addition to X86 (-DLLVM_TARGETS_TO_BUILD='X86;ARM;AArch64'), and clobbering the "runtimes" dir in the build dir so that cmake picks it up. (Adding just AArch64 lead to error: unable to create target: 'No available targets are compatible with triple "thumbv7em-apple-unknown-macho"'). 1: % git diff diff --git a/llvm/cmake/modules/CheckProblematicConfigurations.cmake b/llvm/cmake/modules/CheckProblematicConfigurations.cmake index e133873d756c..71484172cfb6 100644 --- a/llvm/cmake/modules/CheckProblematicConfigurations.cmake +++ b/llvm/cmake/modules/CheckProblematicConfigurations.cmake @@ -11,7 +11,7 @@ endmacro() # MSVC and /arch:AVX is untested and have created problems before. See: # https://github.com/llvm/llvm-project/issues/54645 -if(${CMAKE_CXX_COMPILER_ID} STREQUAL MSVC) +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL MSVC) string(TOLOWER "${CMAKE_CXX_FLAGS} ${CMAKE_C_FLAGS}" _FLAGS) if(_FLAGS MATCHES "/arch:avx[0-9]*") log_problematic("Compiling LLVM with MSVC and the /arch:AVX flag is known to cause issues with parts of LLVM.\nSee https://github.com/llvm/llvm-project/issues/54645 for details.\nUse clang-cl if you want to enable AVX instructions.") (Posting this here since the first symptom of my mistake led me to this patch. It's innocent, but it's where I looked first, so maybe this helps someone else.) |
Maybe "allow" would be better than "force"? "force" kinda sounds like the build system will purposely use a problematic toolchain configuration if you turn the flag on.