From e65101c6c6a4a26f2c6188816008ee4993062dea Mon Sep 17 00:00:00 2001 From: Dmitry Malakhov Date: Sat, 13 Sep 2025 16:13:39 +0300 Subject: Change compilers priority for gcc and clang Before this change xmake preferred to use clang and gcc for c++ code which caused build to fail with clang in my current setup --- xmake/toolchains/clang/xmake.lua | 4 ++-- xmake/toolchains/gcc/xmake.lua | 4 ++-- xmake/toolchains/llvm/xmake.lua | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xmake/toolchains/clang/xmake.lua b/xmake/toolchains/clang/xmake.lua index 321a0a7dc..bafffd95d 100644 --- a/xmake/toolchains/clang/xmake.lua +++ b/xmake/toolchains/clang/xmake.lua @@ -31,7 +31,7 @@ toolchain("clang" .. suffix) set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared") set_toolset("cc", "clang" .. suffix) - set_toolset("cxx", "clang" .. suffix, "clang++" .. suffix) + set_toolset("cxx", "clang++" .. suffix, "clang" .. suffix) set_toolset("ld", "clang++" .. suffix, "clang" .. suffix) set_toolset("sh", "clang++" .. suffix, "clang" .. suffix) set_toolset("ar", "ar", "llvm-ar" .. suffix) @@ -39,7 +39,7 @@ toolchain("clang" .. suffix) set_toolset("ranlib", "ranlib", "llvm-ranlib" .. suffix) set_toolset("objcopy", "objcopy", "llvm-objcopy" .. suffix) set_toolset("mm", "clang" .. suffix) - set_toolset("mxx", "clang" .. suffix, "clang++" .. suffix) + set_toolset("mxx", "clang++" .. suffix, "clang" .. suffix) set_toolset("as", "clang" .. suffix) set_toolset("mrc", "llvm-rc" .. suffix) set_toolset("dlltool", "llvm-dlltool" .. suffix) diff --git a/xmake/toolchains/gcc/xmake.lua b/xmake/toolchains/gcc/xmake.lua index aa4688abb..31954ad79 100644 --- a/xmake/toolchains/gcc/xmake.lua +++ b/xmake/toolchains/gcc/xmake.lua @@ -31,7 +31,7 @@ toolchain("gcc" .. suffix) set_runtimes("stdc++_static", "stdc++_shared") set_toolset("cc", "gcc" .. suffix) - set_toolset("cxx", "gcc" .. suffix, "g++" .. suffix) + set_toolset("cxx", "g++" .. suffix, "gcc" .. suffix) set_toolset("ld", "g++" .. suffix, "gcc" .. suffix) set_toolset("sh", "g++" .. suffix, "gcc" .. suffix) set_toolset("ar", "ar") @@ -39,7 +39,7 @@ toolchain("gcc" .. suffix) set_toolset("objcopy", "objcopy") set_toolset("ranlib", "ranlib") set_toolset("mm", "gcc" .. suffix) - set_toolset("mxx", "gcc" .. suffix, "g++" .. suffix) + set_toolset("mxx", "g++" .. suffix, "gcc" .. suffix) set_toolset("as", "gcc" .. suffix) on_check(function (toolchain) diff --git a/xmake/toolchains/llvm/xmake.lua b/xmake/toolchains/llvm/xmake.lua index 2a4643ec6..de2e775d7 100644 --- a/xmake/toolchains/llvm/xmake.lua +++ b/xmake/toolchains/llvm/xmake.lua @@ -25,8 +25,8 @@ toolchain("llvm") set_runtimes("c++_static", "c++_shared", "stdc++_static", "stdc++_shared") set_toolset("cc", "clang") - set_toolset("cxx", "clang", "clang++") - set_toolset("mxx", "clang", "clang++") + set_toolset("cxx", "clang++", "clang") + set_toolset("mxx", "clang++", "clang") set_toolset("mm", "clang") set_toolset("cpp", "clang -E") set_toolset("as", "clang") -- cgit v1.3.1 From 64102cce59a2b26908cb11964897a13add8cf2ce Mon Sep 17 00:00:00 2001 From: ruki Date: Mon, 15 Sep 2025 23:28:17 +0800 Subject: Change clang check to use startswith method --- xmake/modules/core/tools/gcc.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index e27fb3401..5824ae40d 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -841,7 +841,7 @@ function nf_pcheader(self, pcheaderfile, opt) if self:kind() == "cc" then local target = opt.target local pcoutputfile = target:pcoutputfile("c") - if self:name() == "clang" then + if self:name():startswith("clang") then return {"-include", pcheaderfile, "-include-pch", pcoutputfile} else return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)} @@ -854,7 +854,7 @@ function nf_pcxxheader(self, pcheaderfile, opt) if self:kind() == "cxx" then local target = opt.target local pcoutputfile = target:pcoutputfile("cxx") - if self:name() == "clang" then + if self:name():startswith("clang") then return {"-include", pcheaderfile, "-include-pch", pcoutputfile} else return {"-I", path.directory(pcoutputfile), "-include", path.filename(pcheaderfile)} -- cgit v1.3.1