Skip to content

Commit

Permalink
Merge pull request #4327 from wsw0108/soname-rpath
Browse files Browse the repository at this point in the history
add @rpath to link flags when soname enabled
  • Loading branch information
waruqi authored Oct 27, 2023
2 parents 1f3b314 + 30b8576 commit a5ed7b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions xmake/modules/core/tools/gcc.lua
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,10 @@ function linkargv(self, objectfiles, targetkind, targetfile, flags, opt)
-- add rpath for dylib (macho), e.g. -install_name @rpath/file.dylib
local flags_extra = {}
if targetkind == "shared" and self:is_plat("macosx", "iphoneos", "watchos") then
table.insert(flags_extra, "-install_name")
table.insert(flags_extra, "@rpath/" .. path.filename(targetfile))
if not table.contains(flags, "-install_name") then
table.insert(flags_extra, "-install_name")
table.insert(flags_extra, "@rpath/" .. path.filename(targetfile))
end
end

-- add `-Wl,--out-implib,outputdir/libxxx.a` for xxx.dll on mingw/gcc
Expand Down
4 changes: 2 additions & 2 deletions xmake/rules/linker/soname/xmake.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ rule("linker.soname")
if target:is_shared() and soname then
if target:has_tool("sh", "gcc", "gxx", "clang", "clangxx") then
if target:is_plat("macosx", "iphoneos", "watchos", "appletvos") then
target:add("shflags", "-Wl,-install_name," .. soname, {force = true})
target:add("shflags", "-Wl,-install_name,@rpath/" .. soname, {force = true})
else
target:add("shflags", "-Wl,-soname," .. soname, {force = true})
target:add("shflags", "-Wl,-soname,@rpath/" .. soname, {force = true})
end
target:data_set("soname.enabled", true)
end
Expand Down

0 comments on commit a5ed7b6

Please sign in to comment.