Initial work on building Windows compiler runtimes under Linux.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
clang/cmake/caches/Fuchsia-stage2.cmake | ||
---|---|---|
73 | I'd drop this part altogether, let's build these anytime when WINDOWS_SDK_DIR is set. | |
96–99 | I think we should introduce a new LLVM CMake option for setting this akin to LLVM_WINSYSROOT (for example LLVM_VFSOVERLAY). | |
100–101 | Can we instead set BUILTINS_${target}_LLVM_WINSYSROOT to ${WINDOWS_SDK_DIR}? | |
105–108 | These should be set automatically if you set /winsysroot (through LLVM_WINSYSROOT), see https://github.com/llvm/llvm-project/blob/a64846bee0bb4b4912c8cf6bf018ba5d892065d1/clang/lib/Driver/ToolChains/MSVC.cpp#L107. | |
142–143 | Can we instead set RUNTIMES_${target}_LLVM_WINSYSROOT to ${WINDOWS_SDK_DIR}? | |
llvm/cmake/modules/LLVMExternalProjectUtils.cmake | ||
172 | This should be in a separate block just like other tools below guarded by a llvm-rc IN_LIST TOOLCHAIN_TOOLS condition. | |
173 | This should be in a separate block just like other tools below guarded by a llvm-mt IN_LIST TOOLCHAIN_TOOLS condition. | |
llvm/runtimes/CMakeLists.txt | ||
359 | We should fix the build so that this isn't needed, it should be possible to use LLVM_USE_LINKER=lld when targeting Windows. |
clang/cmake/caches/Fuchsia-stage2.cmake | ||
---|---|---|
73 | We need to do a soft transition if we drop the "WIN32" since the bots are not passing the WINSYSROOT flag yet. Let's keep the WIN32 here. | |
105–108 | There is an issue that "CLANG_CL" variable is not correctly set when clang kicks runtime build. When CLANG_CL is not set, the /winsysroot will not be added by the LLVM_WINSYSROOT flag. I have some thoughts about it and prefer to address this issue in a follow up patch instead of put everything here. | |
142–143 | As stated in an earlier comment, this will require fixing the setting the "CLANG_CL" variable in compiler version detection. | |
llvm/runtimes/CMakeLists.txt | ||
359 | I made some other changes and now the /fuse-ld=lld will be passed to lld-link.exe if we leave this line unchanged. |
clang/cmake/caches/Fuchsia-stage2.cmake | ||
---|---|---|
79 | I think we'll want to use these flags even when not cross-compiling so I'd change the name to reflect that. | |
81–115 | You can set these unconditionally (unset variables in CMake evaluate to empty string). | |
90 | I think we'll want to use these flags even when not cross-compiling so I'd change the name to reflect that. | |
123–132 | You can set these unconditionally. |
clang/cmake/caches/Fuchsia-stage2.cmake | ||
---|---|---|
95 | You can tell cmake to invoke lld-link, which has a /winsysroot: flag. |
clang/cmake/caches/Fuchsia-stage2.cmake | ||
---|---|---|
95 | What would be a good way to make CMake invoke lld-link (or through clang-cl) instead of using cmake vs_link in this situation? set(CMAKE_${LANG}_SIMULATE_ID "MSVC") set(CMAKE_${LANG}_COMPILER_FRONTEND_VARIANT "GNU") but I don't feel great about changing variables that are not suppose to change. |
clang/cmake/caches/Fuchsia-stage2.cmake | ||
---|---|---|
95 | Wouldn't CMake use lld-link if you set CMAKE_LINKER=lld-link. We already do this in https://github.com/llvm/llvm-project/blob/0e09bb8b143c80426c497a924ee4fa57a26af6b5/llvm/cmake/modules/LLVMExternalProjectUtils.cmake#L179 which is used by the bootstrapping build so you should be able to use /winsysroot: here. |
clang/cmake/caches/Fuchsia-stage2.cmake | ||
---|---|---|
95 | I tried: FAILED: runtimes/runtimes-x86_64-pc-windows-msvc-stamps/runtimes-x86_64-pc-windows-msvc-configure /mnt/nvme_sec/SRC/llvm-project/build-lldlink/runtimes/runtimes-x86_64-pc-windows-msvc-stamps/runtimes-x86_64-pc-windows-msvc-configure cd /mnt/nvme_sec/SRC/llvm-project/build-lldlink/runtimes/runtimes-x86_64-pc-windows-msvc-bins && /mnt/nvme_sec/SRC/llvm-prebuilts/cmake/linux-amd64/bin/cmake \ -DCMAKE_C_COMPILER=/mnt/nvme_sec/SRC/llvm-project/build-lldlink/./bin/clang-cl \ -DCMAKE_CXX_COMPILER=/mnt/nvme_sec/SRC/llvm-project/build-lldlink/./bin/clang-cl \ -DCMAKE_ASM_COMPILER=/mnt/nvme_sec/SRC/llvm-project/build-lldlink/./bin/clang-cl \ -DCMAKE_LINKER=/mnt/nvme_sec/SRC/llvm-project/build-lldlink/./bin/lld-link \ .... But cmake is still using vs_link, see: FAILED: cmTC_a05d1.exe : && /mnt/nvme_sec/SRC/llvm-prebuilts/cmake/linux-amd64/bin/cmake -E vs_link_exe --intdir=CMakeFiles/cmTC_a05d1.dir --rc=/mnt/nvme_sec/SRC/llvm-project/build-lldlink/./bin/llvm-rc --mt=/mnt/nvme_sec/SRC/llvm-project/build-lldlink/bin/llvm-mt --manifests -- /mnt/nvme_sec/SRC/llvm-project/build-lldlink/bin/lld-link /nologo CMakeFiles/cmTC_a05d1.dir/CMakeCCompilerABI.c.obj /out:cmTC_a05d1.exe /implib:cmTC_a05d1.lib /pdb:cmTC_a05d1.pdb /version:0.0 /vfsoverlay:/mnt/nvme_sec/SRC/WinSDK/winsdk-cipd/llvm-vfsoverlay.yaml /debug /INCREMENTAL /subsystem:console |
LGTM
clang/cmake/caches/Fuchsia-stage2.cmake | ||
---|---|---|
95 | Thanks for checking, we should investigate this further and perhaps reach out to CMake maintainers but that can be done separately. |
I'd drop this part altogether, let's build these anytime when WINDOWS_SDK_DIR is set.