summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2024-03-07 11:36:26 +0100
committerArthur LAURENT <[email protected]>2024-03-07 11:36:26 +0100
commita6b26e0f93bfaa55ec6033501437df73efca1934 (patch)
tree48b74c4003ee81361002ac7f40c6f032226db7cd
parenta7a6202288ae1975bb2f9a710786912b7cceda84 (diff)
handle macOS with native clang driver rpath flag
-rw-r--r--xmake/modules/core/tools/clang.lua15
1 files changed, 12 insertions, 3 deletions
diff --git a/xmake/modules/core/tools/clang.lua b/xmake/modules/core/tools/clang.lua
index 79a274a21..78806fe13 100644
--- a/xmake/modules/core/tools/clang.lua
+++ b/xmake/modules/core/tools/clang.lua
@@ -291,11 +291,20 @@ function nf_runtime(self, runtime, opt)
maps["c++_shared"] = table.join(maps["c++_shared"], "-L" .. triple_libdir)
end
-- add rpath to avoid the user need to set LD_LIBRARY_PATH by hand
- if not self:is_plat("windows", "mingw") then
- maps["c++_shared"] = table.join(maps["c++_shared"], "-Wl,-rpath=" .. libdir)
+ local rpath_flags
+ if self:has_flags("-Wl,-rpath=" .. libdir, "ldflags") then
+ rpath_flags = {"-Wl,-rpath=" .. libdir}
if triple_libdir then
- maps["c++_shared"] = table.join(maps["c++_shared"], "-Wl,-rpath=" .. triple_libdir)
+ table.join2(rpath_flags, "-Wl,-rpath=" .. triple_libdir)
end
+ elseif self:has_flags("-Xlinker -rpath -Xlinker " .. libdir, "ldflags") then
+ rpath_flags = {"-Xlinker", "-rpath", "-Xlinker", (libdir:gsub("%$ORIGIN", "@loader_path"))}
+ if triple_libdir then
+ table.join2(rpath_flags, {"-Xlinker", "-rpath", "-Xlinker", (triple_libdir:gsub("%$ORIGIN", "@loader_path"))})
+ end
+ end
+ if rpath_flags then
+ maps["c++_shared"] = table.join(maps["c++_shared"], rpath_flags)
end
end
if runtime:endswith("_static") and _has_static_libstdcxx(self) then