Add install_name when build libcast on macos. (#332)

Gradle won't pass absolute path when build libcast. We need to set install_name manually otherwise `dyld` would not able to find libcast at runtime.

This is only needed on macos since `ld` will look up all runtime search path automatically.
This commit is contained in:
Leo Li 2018-07-21 17:42:19 -07:00 committed by Manu Sridharan
parent bc3ea1a777
commit d15f49bd90
2 changed files with 3 additions and 13 deletions

View File

@ -36,15 +36,6 @@ def addCastRpath(currentJvm, targetPlatform, linker) {
}
}
static final def addCastEnvironment(task, xlatorLibrary) {
final def castLibrary = xlatorLibrary.libs[2]
if (castLibrary == null) return
final def castLibraryFile = castLibrary.linkFiles.singleFile
final def castLibraryDirectory = castLibraryFile.parent
assert castLibraryDirectory.endsWith('/com.ibm.wala.cast/build/libs/cast/shared')
task.environment 'DYLD_LIBRARY_PATH', castLibraryDirectory
}
model {
components {
xlator_test(JniNativeLibrarySpec) {
@ -92,8 +83,6 @@ model {
def lib = linkXlator_testSharedLibrary
dependsOn lib
systemProperty 'java.library.path', lib.destinationDirectory.get().asFile
addCastEnvironment(it, $.binaries.xlator_testSharedLibrary)
}
checkSmoke_main(Exec) {
@ -122,8 +111,6 @@ model {
// all combined as a colon-delimited path list
args pathElements.join(':')
addCastEnvironment(it, $.binaries.xlator_testSharedLibrary)
}
check.dependsOn checkSmoke_main

View File

@ -82,6 +82,9 @@ model {
.find { it.targetPlatform.name == targetPlatform.name }
.sharedLibraryLinkFile.parent
linker.args "-Wl,-rpath,$libDir"
if (targetPlatform.operatingSystem.name == 'osx') {
linker.args "-Wl,-install_name,@rpath/$sharedLibraryFile.name"
}
}
}
}