Skip to content

Commit 008d6a9

Browse files
committed
improve rpathdirs #5109
1 parent e1f3dc9 commit 008d6a9

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

xmake/modules/core/tools/gcc.lua

+12-1
Original file line numberDiff line numberDiff line change
@@ -385,13 +385,24 @@ function nf_linkdir(self, dir)
385385
end
386386

387387
-- make the rpathdir flag
388-
function nf_rpathdir(self, dir)
388+
function nf_rpathdir(self, dir, opt)
389+
opt = opt or {}
389390
dir = path.translate(dir)
390391
if self:has_flags("-Wl,-rpath=" .. dir, "ldflags") then
391392
local flags = {"-Wl,-rpath=" .. (dir:gsub("@[%w_]+", function (name)
392393
local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"}
393394
return maps[name]
394395
end))}
396+
-- add_rpathdirs("...", {runpath = false})
397+
-- https://github.com/xmake-io/xmake/issues/5109
398+
local extra = opt.extra
399+
if extra then
400+
if extra.runpath == false and self:has_flags("-Wl,-rpath=" .. dir .. ",--disable-new-dtags", "ldflags") then
401+
flags[1] = flags[1] .. ",--disable-new-dtags"
402+
elseif extra.runpath == true and self:has_flags("-Wl,-rpath=" .. dir .. ",--enable-new-dtags", "ldflags") then
403+
flags[1] = flags[1] .. ",--enable-new-dtags"
404+
end
405+
end
395406
if self:is_plat("bsd") then
396407
-- FreeBSD ld must have "-zorigin" with "-rpath". Otherwise, $ORIGIN is not translated and it is literal.
397408
table.insert(flags, 1, "-Wl,-zorigin")

0 commit comments

Comments
 (0)