From ae8569a7f4eb3e25cba4f7e954e7a96618aeb580 Mon Sep 17 00:00:00 2001 From: John Leidegren Date: Sat, 11 Nov 2023 14:48:41 +0100 Subject: [PATCH] Adds basic support for using clang in-place of cl on Windows --- scripts/tundra/tools/msvc-clang.lua | 17 +++++++++++++++++ scripts/tundra/tools/msvc-latest.lua | 13 +++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 scripts/tundra/tools/msvc-clang.lua diff --git a/scripts/tundra/tools/msvc-clang.lua b/scripts/tundra/tools/msvc-clang.lua new file mode 100644 index 00000000..f38750b1 --- /dev/null +++ b/scripts/tundra/tools/msvc-clang.lua @@ -0,0 +1,17 @@ +module(..., package.seeall) + +local vslatest = require "tundra.tools.msvc-latest" + +function apply(env, options) + local extra = { + Clang = true + } + + vslatest.apply(env, options, extra) + + env:set_many{ + ["CC"] = "clang-cl", + ["CXX"] = "clang-cl", + ["LD"] = "lld-link" + } +end diff --git a/scripts/tundra/tools/msvc-latest.lua b/scripts/tundra/tools/msvc-latest.lua index e8e6612d..e5fed3a8 100644 --- a/scripts/tundra/tools/msvc-latest.lua +++ b/scripts/tundra/tools/msvc-latest.lua @@ -326,6 +326,19 @@ function apply(env, options, extra) env_lib[#env_lib + 1] = native_path.join(vc_tools_dir, "lib\\onecore\\" .. target_arch) end + if extra.Clang then + -- file:///C:/Program%20Files%20(x86)/Microsoft%20Visual%20Studio/2022/BuildTools/VC/Tools/Llvm + if target_arch == "x64" then + env_path[#env_path + 1] = native_path.join(vs_install_dir, "VC\\Tools\\Llvm\\x64\\bin") + elseif target_arch == "arm64" then + env_path[#env_path + 1] = native_path.join(vs_install_dir, "VC\\Tools\\Llvm\\ARM64\\bin") + elseif target_arch == "x86" then + env_path[#env_path + 1] = native_path.join(vs_install_dir, "VC\\Tools\\Llvm\\bin") + else + error("msvc-clang: target architecutre '" .. target_arch .. "' not supported") + end + end + -- Force MSPDBSRV.EXE (fix for issue with cl.exe running in parallel and otherwise corrupting PDB files) -- These options where added to Visual C++ in Visual Studio 2013. They do not exist in older versions. env:set("CCOPTS", "/FS")