summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2023-10-27 07:30:59 -0500
committerGitHub <[email protected]>2023-10-27 07:30:59 -0500
commita5ed7b6144d1a6318e25e044dc60a391a317470b (patch)
treeb3f0aa984d4e204c315d142c65d8a3855ab8fd32
parent1f3b3148942aa52a0467a5433d85304df0b936f5 (diff)
parent30b8576c2930cb1d188c92aed4d6bd74dbd2f644 (diff)
Merge pull request #4327 from wsw0108/soname-rpath
add @rpath to link flags when soname enabled
-rw-r--r--xmake/modules/core/tools/gcc.lua6
-rw-r--r--xmake/rules/linker/soname/xmake.lua4
2 files changed, 6 insertions, 4 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index 1d4a9e8f9..15ce30280 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -494,8 +494,10 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
-- add rpath for dylib (macho), e.g. -install_name @rpath/file.dylib
local flags_extra = {}
if targetkind == "shared" and self:is_plat("macosx", "iphoneos", "watchos") then
- table.insert(flags_extra, "-install_name")
- table.insert(flags_extra, "@rpath/" .. path.filename(targetfile))
+ if not table.contains(flags, "-install_name") then
+ table.insert(flags_extra, "-install_name")
+ table.insert(flags_extra, "@rpath/" .. path.filename(targetfile))
+ end
end
-- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc
diff --git a/xmake/rules/linker/soname/xmake.lua b/xmake/rules/linker/soname/xmake.lua
index 8bb160b64..34179f858 100644
--- a/xmake/rules/linker/soname/xmake.lua
+++ b/xmake/rules/linker/soname/xmake.lua
@@ -24,9 +24,9 @@ rule("linker.soname")
if target:is_shared() and soname then
if target:has_tool("sh", "gcc", "gxx", "clang", "clangxx") then
if target:is_plat("macosx", "iphoneos", "watchos", "appletvos") then
- target:add("shflags", "-Wl,-install_name," .. soname, {force = true})
+ target:add("shflags", "-Wl,-install_name,@rpath/" .. soname, {force = true})
else
- target:add("shflags", "-Wl,-soname," .. soname, {force = true})
+ target:add("shflags", "-Wl,-soname,@rpath/" .. soname, {force = true})
end
target:data_set("soname.enabled", true)
end