diff options
| author | ruki <[email protected]> | 2017-08-18 21:45:21 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2017-08-18 21:45:21 +0800 |
| commit | b068f28c48cb6cd7246dcfeaff648327decb3101 (patch) | |
| tree | e4bbd04a5064e9b775635f807daa766bb817b066 /xmake/modules/core/tools/gcc.lua | |
| parent | b714bf39904f7425a32d5238d0737239a6e5d045 (diff) | |
add rpath for macho
Diffstat (limited to 'xmake/modules/core/tools/gcc.lua')
| -rw-r--r-- | xmake/modules/core/tools/gcc.lua | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/xmake/modules/core/tools/gcc.lua b/xmake/modules/core/tools/gcc.lua index 96413b718..ddfc264cc 100644 --- a/xmake/modules/core/tools/gcc.lua +++ b/xmake/modules/core/tools/gcc.lua @@ -234,9 +234,12 @@ end -- make the rpathdir flag function nf_rpathdir(self, dir) - local flag = "-Wl,-rpath=" .. dir - if self:has_flags(flag) then - return flag + local flag_elf = "-Wl,-rpath=" .. dir + local flag_macho = "-Xlinker -rpath -Xlinker " .. dir + if self:has_flags(flag_elf) then + return flag_elf + elseif self:has_flags(flag_macho) then + return flag_macho end end @@ -274,6 +277,12 @@ end -- make the link arguments list function linkargv(self, objectfiles, targetkind, targetfile, flags) + + -- add rpath for dylib (macho), .e.g -install_name @rpath/file.dylib + if targetkind == "shared" and targetfile:endswith(".dylib") then + table.insert(flags, "-install_name") + table.insert(flags, "@rpath/" .. path.filename(targetfile)) + end return self:program(), table.join("-o", targetfile, objectfiles, flags) end |
