Skip to content

Commit 70e7191

Browse files
committed
reuse gcc nf_rpathdir in clang tool
1 parent 252b7e5 commit 70e7191

File tree

1 file changed

+2
-20
lines changed

1 file changed

+2
-20
lines changed

xmake/modules/core/tools/clang.lua

+2-20
Original file line numberDiff line numberDiff line change
@@ -220,24 +220,6 @@ function _get_llvm_target_triple(self)
220220
return llvm_targettriple or nil
221221
end
222222

223-
-- make the rpathdir flag
224-
function _rpathdir(self, dir)
225-
dir = path.translate(dir)
226-
if self:has_flags("-Wl,-rpath=" .. dir, "ldflags") then
227-
local flags = {"-Wl,-rpath=" .. (dir:gsub("@[%w_]+", function (name)
228-
local maps = {["@loader_path"] = "$ORIGIN", ["@executable_path"] = "$ORIGIN"}
229-
return maps[name]
230-
end))}
231-
if self:is_plat("bsd") then
232-
-- FreeBSD ld must have "-zorigin" with "-rpath". Otherwise, $ORIGIN is not translated and it is literal.
233-
table.insert(flags, 1, "-Wl,-zorigin")
234-
end
235-
return flags
236-
elseif self:has_flags("-Xlinker -rpath -Xlinker " .. dir, "ldflags") then
237-
return {"-Xlinker", "-rpath", "-Xlinker", (dir:gsub("%$ORIGIN", "@loader_path"))}
238-
end
239-
end
240-
241223
-- make the runtime flag
242224
-- @see https://github.com/xmake-io/xmake/issues/3546
243225
function nf_runtime(self, runtime, opt)
@@ -309,9 +291,9 @@ function nf_runtime(self, runtime, opt)
309291
maps["c++_shared"] = table.join(maps["c++_shared"], "-L" .. triple_libdir)
310292
end
311293
-- add rpath to avoid the user need to set LD_LIBRARY_PATH by hand
312-
maps["c++_shared"] = table.join(maps["c++_shared"], _rpathdir(self, libdir))
294+
maps["c++_shared"] = table.join(maps["c++_shared"], nf_rpathdir(self, libdir))
313295
if triple_libdir then
314-
maps["c++_shared"] = table.join(maps["c++_shared"], _rpathdir(self, triple_libdir))
296+
maps["c++_shared"] = table.join(maps["c++_shared"], nf_rpathdir(self, triple_libdir))
315297
end
316298
if target:kind() == "shared" and self:is_plat("macosx", "iphoneos", "watchos") then
317299
maps["c++_shared"] = table.join(maps["c++_shared"], "-install_name")

0 commit comments

Comments
 (0)