Issue 244572
Summary [cmake] CLANG_CL is not set in the runtimes build
Labels cmake
Assignees
Reporter zmodem
    This came up in https://github.com/llvm/llvm-project/pull/174947#issuecomment-6797483572 where some cmake code like:

```
if (NOT CLANG_CL)
  message(FATAL_ERROR "LLVM_WINSYSROOT requires clang-cl")
```

casued builds to fail even though they were in fact using clang-cl.

I think we've hit this before too, but I didn't find any bug filed about it so here we go.

One way to reproduce is to apply something like:

```
diff --git a/llvm/cmake/modules/HandleLLVMOptions.cmake b/llvm/cmake/modules/HandleLLVMOptions.cmake
index 9970150d4e1f..d9d32227acc2 100644
--- a/llvm/cmake/modules/HandleLLVMOptions.cmake
+++ b/llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -597,6 +597,9 @@ option(LLVM_ENABLE_WARNINGS "Enable compiler warnings." ON)
 option(LLVM_ENABLE_WARNING_SUPPRESSIONS "Suppress compiler warnings." ON)

 if( MSVC )
+  if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT CLANG_CL)
+    message(FATAL_ERROR "Expected CLANG_CL!")
+  endif()

 # Add definitions that make MSVC much less annoying.
 add_compile_definitions(
```

and then building like this (in a VS Native Tools Command Prompt for example):

```
cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_PROJECTS=clang -DCLANG_ENABLE_CIR=OFF -DLLVM_ENABLE_RUNTIMES=compiler-rt -DLLVM_TARGETS_TO_BUILD=X86 -DLLVM_RUNTIME_TARGETS=x86_64-pc-windows-msvc ../llvm
ninja runtimes-x86_64-pc-windows-msvc

...
[3877/3881] Performing configure step for 'runtimes-x86_64-pc-windows-msvc'Not searching for unused variables given on the command line.
loading initial cache file C:/src/llvm-project/build.456/projects/runtimes-x86_64-pc-windows-msvc/tmp/runtimes-x86_64-pc-windows-msvc-cache-Release.cmake
-- Performing bootstrapping runtimes build.
-- The C compiler identification is Clang 24.0.0 with MSVC-like command-line
-- The CXX compiler identification is Clang 24.0.0 with MSVC-like command-line
-- The ASM compiler identification is Clang with MSVC-like command-line
-- Found assembler: C:/src/llvm-project/build.456/bin/clang-cl.exe
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: C:/src/llvm-project/build.456/bin/clang-cl.exe - skipped
...
CMake Error at C:/src/llvm-project/llvm/cmake/modules/HandleLLVMOptions.cmake:601 (message):
  Expected CLANG_CL!
Call Stack (most recent call first):
 CMakeLists.txt:220 (include)
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to