diff options
| author | ruki <[email protected]> | 2025-11-17 20:36:46 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-11-17 20:36:46 +0800 |
| commit | 71f48dd028d6a6ca0149784577b2c76d55af7871 (patch) | |
| tree | 2f7de64ff790cf776ab369a1ec80bd30b73d4e05 /xmake/rules | |
| parent | 1122dba23f4d74a6be13a23ecd96fa458b9b5813 (diff) | |
| parent | 6d5be3643ae0f62095a7f5c589f09ad4c482a19b (diff) | |
Merge pull request #7032 from xmake-io/extract
improve to extract symbols
Diffstat (limited to 'xmake/rules')
| -rw-r--r-- | xmake/rules/c++/build_optimization/config.lua | 15 | ||||
| -rw-r--r-- | xmake/rules/utils/symbols/extract/xmake.lua | 2 |
2 files changed, 16 insertions, 1 deletions
diff --git a/xmake/rules/c++/build_optimization/config.lua b/xmake/rules/c++/build_optimization/config.lua index 0f79a909b..686ef76c5 100644 --- a/xmake/rules/c++/build_optimization/config.lua +++ b/xmake/rules/c++/build_optimization/config.lua @@ -44,6 +44,21 @@ function _add_lto_optimization(target, sourcekind) elseif ld == "clang" or ld == "clangxx" then target:add("ldflags", "-flto=thin") target:add("shflags", "-flto=thin") + + -- On Darwin, when using -flto along with -g and compiling and linking in separate steps, + -- you also need to pass -Wl,-object_path_lto,<lto-filename>.o at the linking step to instruct + -- the ld64 linker not to delete the temporary object file generated during Link Time Optimization + -- (this flag is automatically passed to the linker by Clang if compilation and linking are done in a single step). + -- + -- This allows debugging the executable as well as generating the .dSYM bundle using dsymutil(1). + -- + -- @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) + end elseif ld == "gcc" or ld == "gxx" then target:add("ldflags", "-flto") target:add("shflags", "-flto") diff --git a/xmake/rules/utils/symbols/extract/xmake.lua b/xmake/rules/utils/symbols/extract/xmake.lua index b9fd816eb..92abd3df3 100644 --- a/xmake/rules/utils/symbols/extract/xmake.lua +++ b/xmake/rules/utils/symbols/extract/xmake.lua @@ -103,7 +103,7 @@ rule("utils.symbols.extract") -- strip it local strip_argv = {} - if target:is_plat("macosx", "iphoneos", "watchos") then + if target:is_plat("macosx", "iphoneos", "watchos") and not strip:find("llvm-strip", 1, true) then -- do not support `-s`, we can only strip debug symbols local arch = target:arch() if arch then |
