summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2024-05-18 22:15:38 +0800
committerruki <[email protected]>2024-05-18 22:15:38 +0800
commit008d6a92e171d9ef1d8a62fca1e4900ed5faa48f (patch)
tree668c11078ff9c6a2e84db5cf3cc34139d1e04644
parente1f3dc9aa95397f1aa707f043000e0f4346fdaa2 (diff)
improve rpathdirs #5109
-rw-r--r--xmake/modules/core/tools/gcc.lua13
1 files changed, 12 insertions, 1 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua
index f51a088bf..e1d77f1a4 100644
--- a/xmake/modules/core/tools/gcc.lua
+++ b/xmake/modules/core/tools/gcc.lua
@@ -385,13 +385,24 @@ function nf_linkdir(self, dir)
end
-- make the rpathdir flag
-function nf_rpathdir(self, dir)
+function nf_rpathdir(self, dir, opt)
+ opt = opt or {}
dir = path.translate(dir)
if self:has_flags("-Wl,-rpath=" .. dir, "ldflags") then
local flags = {"-Wl,-rpath=" .. (dir:gsub("@[%w_]+", function (name)
local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"}
return maps[name]
end))}
+ -- add_rpathdirs("...", {runpath = false})
+ -- https://github.com/xmake-io/xmake/issues/5109
+ local extra = opt.extra
+ if extra then
+ if extra.runpath == false and self:has_flags("-Wl,-rpath=" .. dir .. ",--disable-new-dtags", "ldflags") then
+ flags[1] = flags[1] .. ",--disable-new-dtags"
+ elseif extra.runpath == true and self:has_flags("-Wl,-rpath=" .. dir .. ",--enable-new-dtags", "ldflags") then
+ flags[1] = flags[1] .. ",--enable-new-dtags"
+ end
+ end
if self:is_plat("bsd") then
-- FreeBSD ld must have "-zorigin" with "-rpath". Otherwise, $ORIGIN is not translated and it is literal.
table.insert(flags, 1, "-Wl,-zorigin")