From e23ba1229f3efe827bfb5c9d6cb7042665b507de Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 14 Jan 2026 22:56:44 +0800 Subject: fix lto flags --- xmake/rules/c++/config/optimization.lua | 9 ++++++--- 1 file 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") -- cgit v1.3.1