[build] Fix MacOS binary rpath generation (#4376)

For RPATH on MacOS use '@loader_path' instead of '$ORIGIN' to reference the directory where the executable is located. The latter is the mechanism used on Linux.

I think this was exposed due to newer OS X ignoring $DYLD_LIBRARY_PATH for security reasons.
This commit is contained in:
Brandon Parsons
2022-08-25 20:17:16 -05:00
committed by GitHub
parent ccf83c634a
commit eb08486039

View File

@@ -37,9 +37,11 @@ nativeUtils.platformConfigs.each {
if (it.name.contains('windows')) {
return
}
it.linker.args << '-Wl,-rpath,\'$ORIGIN\''
if (it.name.contains('osx')) {
it.linker.args << '-Wl,-rpath,\'@loader_path\''
it.linker.args << "-headerpad_max_install_names"
} else {
it.linker.args << '-Wl,-rpath,\'$ORIGIN\''
}
}