diff options
| author | Tiangang Song <[email protected]> | 2026-05-03 11:39:39 -0700 |
|---|---|---|
| committer | Tiangang Song <[email protected]> | 2026-05-04 20:30:55 -0700 |
| commit | bbcf7a801e637b89a005751c6bfdf7bfcaa48de8 (patch) | |
| tree | 3c6ded46cac4adfc188ee2b2cbe0816d309aa776 /xmake/rules/c++/config/optimization.lua | |
| parent | 931fce9c311f25aca6091d226b48f72b1dc548c9 (diff) | |
Fix lto with zig cc and clang_cl
Diffstat (limited to 'xmake/rules/c++/config/optimization.lua')
| -rw-r--r-- | xmake/rules/c++/config/optimization.lua | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/xmake/rules/c++/config/optimization.lua b/xmake/rules/c++/config/optimization.lua index d84515fd2..3df0be36c 100644 --- a/xmake/rules/c++/config/optimization.lua +++ b/xmake/rules/c++/config/optimization.lua @@ -33,20 +33,20 @@ function _add_lto_optimization(target, sourcekind) mxx = "mxxflags" } local cflag = flagnames[sourcekind] or (sourcekind == "cxx" and "cxxflags" or "cflags") - if cc == "cl" then + if cc == "cl" or cc == "clang_cl" then target:add(cflag, "-GL") - elseif cc == "clang" or cc == "clangxx" or cc == "clang_cl" then + elseif cc == "clang" or cc == "clangxx" or cc:startswith("zig") then target:add(cflag, "-flto=thin") elseif cc == "gcc" or cc == "gxx" then target:add(cflag, "-flto") end -- add ldflags and shflags - local program, ld = target:tool("ld") + local _, ld = target:tool("ld") if ld == "link" then target:add("ldflags", "-LTCG") target:add("shflags", "-LTCG") - elseif ld == "clang" or ld == "clangxx" then + elseif ld == "clang" or ld == "clangxx" or ld:startswith("zig") then target:add("ldflags", "-flto=thin") target:add("shflags", "-flto=thin") @@ -88,7 +88,7 @@ function _add_lto_optimization(target, sourcekind) end end - local program, ar = target:tool("ar") + local _, ar = target:tool("ar") if cc == "clang_cl" then if ld == "link" then wprint([[Unsupported toolset(%s) for lto, please use `set_toolset("ld", "lld-link")`]], ld) @@ -109,4 +109,3 @@ function main(target, sourcekind) _add_lto_optimization(target, sourcekind) end end - |
