[PATCH] Make clang-cl able to self host on Windows ✿ヾ╲(｡◕‿◕｡)╱✿
zturner at google.com
Sun Feb 22 23:08:44 PST 2015
Hi rnk, chandlerc, majnemer,
CMake 3.x adds the notion of "simulated compilers" [1, 2]. CMAKE_CXX_COMPILER_ID will still report the actual compiler you're using, but it will set additional variables CMAKE_CXX_SIMULATE_ID and CMAKE_CXX_SIMULATE_VERSION. So, for example, if you set CC and CXX to clang-cl and run CMake while MSVC in your path (for example you've run vcvarsall), then CMAKE_CXX_SIMULATE_ID will get set to "MSVC", and CMAKE_CXX_SIMULATE_VERSION will get set to the value of -fms-compatibility-version.
With this patch and one more patch on the clang side to get -fms-compatibility-version to default to 18.00 instead of 17.00, I was able to compile with clang-cl with the following CMake invocation:
cmake -G Ninja ..\..\llvm
I need to test this more exhaustively, and with CMake 2.8. I know CMake 2.8 doesn't support this, but I want to make sure it doesn't completely break the build. I also haven't completed a full build and run the test suite. But I was able to get ninja to [100/3000] with no major blowups before I stopped due to clang being so slow (I had installed a debug build). So this is promising, and I want to throw it up for discussion.
@@ -16,7 +16,7 @@
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
message(FATAL_ERROR "Host GCC version must be at least 4.7!")
- elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND NOT (CMAKE_CXX_SIMULATE_ID MATCHES "MSVC") )
if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.1)
message(FATAL_ERROR "Host Clang version must be at least 3.1!")
@@ -47,6 +47,10 @@
message(WARNING "Host Visual Studio should at least be 2013 Update 4 (MSVC 18.0.31101)"
" due to miscompiles from earlier versions")
+ elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_CXX_SIMULATE_ID MATCHES "MSVC")
+ if (CMAKE_CXX_SIMULATE_VERSION VERSION_LESS 18.0)
+ message(FATAL_ERROR "Host Clang must have at least -fms-compatibility-version=18.0")
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1090 bytes
Desc: not available
More information about the llvm-commits