@@ -385,13 +385,24 @@ function nf_linkdir(self, dir)
385
385
end
386
386
387
387
-- make the rpathdir flag
388
- function nf_rpathdir (self , dir )
388
+ function nf_rpathdir (self , dir , opt )
389
+ opt = opt or {}
389
390
dir = path .translate (dir )
390
391
if self :has_flags (" -Wl,-rpath=" .. dir , " ldflags" ) then
391
392
local flags = {" -Wl,-rpath=" .. (dir :gsub (" @[%w_]+" , function (name )
392
393
local maps = {[" @loader_path" ] = " $ORIGIN" , [" @executable_path" ] = " $ORIGIN" }
393
394
return maps [name ]
394
395
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
395
406
if self :is_plat (" bsd" ) then
396
407
-- FreeBSD ld must have "-zorigin" with "-rpath". Otherwise, $ORIGIN is not translated and it is literal.
397
408
table.insert (flags , 1 , " -Wl,-zorigin" )
0 commit comments