summaryrefslogtreecommitdiff
path: root/xmake/rules/c++/config/optimization.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2026-01-14 22:56:44 +0800
committerruki <[email protected]>2026-01-14 22:56:44 +0800
commite23ba1229f3efe827bfb5c9d6cb7042665b507de (patch)
tree3234b4c73b510af6070d2e0f59d5b487fc9ccf4f /xmake/rules/c++/config/optimization.lua
parent930765d9108cb2b0bb6e50812b45b04b6319ba10 (diff)
fix lto flags
Diffstat (limited to 'xmake/rules/c++/config/optimization.lua')
-rw-r--r--xmake/rules/c++/config/optimization.lua9
1 files changed, 6 insertions, 3 deletions
diff --git a/xmake/rules/c++/config/optimization.lua b/xmake/rules/c++/config/optimization.lua
index 4332bd833..d84515fd2 100644
--- a/xmake/rules/c++/config/optimization.lua
+++ b/xmake/rules/c++/config/optimization.lua
@@ -60,9 +60,12 @@ function _add_lto_optimization(target, sourcekind)
-- @see https://github.com/xmake-io/xmake/issues/7029
-- https://clang.llvm.org/docs/CommandGuide/clang.html
if target:is_plat("macosx", "iphoneos", "watchos") then
- local lto_objectfile = target:objectfile(target:targetfile() .. ".lto")
- target:add("ldflags", "-Wl,-object_path_lto," .. lto_objectfile)
- target:add("shflags", "-Wl,-object_path_lto," .. lto_objectfile)
+ local targetfile = target:targetfile()
+ if targetfile then
+ local lto_objectfile = target:objectfile(targetfile .. ".lto")
+ target:add("ldflags", "-Wl,-object_path_lto," .. lto_objectfile)
+ target:add("shflags", "-Wl,-object_path_lto," .. lto_objectfile)
+ end
end
elseif ld == "gcc" or ld == "gxx" then
target:add("ldflags", "-flto")