Native: fix loading libllvmstubs.dylib on macOS 12.3 Beta
Link libllvmstubs.dylib to `$sysroot/usr/lib/libc++.1.dylib` instead of `$llvm/lib/libc++.1.dylib`. The latter has `@rpath/libc++.1.dylib` as install name, so the dynamic linker was unable to find it when loading libllvmstubs.dylib on macOS 12.3. ^KT-51359 Fixed
This commit is contained in:
committed by
Space
parent
4143df1c8f
commit
1fdb86d517
@@ -50,6 +50,17 @@ kotlinNativeInterop {
|
|||||||
dependsOn ":kotlin-native:llvmCoverageMappingC:${NativePluginKt.lib("coverageMapping")}"
|
dependsOn ":kotlin-native:llvmCoverageMappingC:${NativePluginKt.lib("coverageMapping")}"
|
||||||
defFile 'llvm.def'
|
defFile 'llvm.def'
|
||||||
compilerOpts "-I$llvmDir/include", "-I${rootProject.project(':kotlin-native:llvmDebugInfoC').projectDir}/src/main/include", "-I${rootProject.project(':kotlin-native:llvmCoverageMappingC').projectDir}/src/main/include"
|
compilerOpts "-I$llvmDir/include", "-I${rootProject.project(':kotlin-native:llvmDebugInfoC').projectDir}/src/main/include", "-I${rootProject.project(':kotlin-native:llvmCoverageMappingC').projectDir}/src/main/include"
|
||||||
|
if (isMac()) {
|
||||||
|
// $llvmDir/lib contains libc++.1.dylib too, and it seems to be preferred by the linker
|
||||||
|
// over the sysroot-provided one.
|
||||||
|
// As a result, libllvmstubs.dylib gets linked with $llvmDir/lib/libc++.1.dylib.
|
||||||
|
// It has install_name = @rpath/libc++.1.dylib, which won't work for us, because
|
||||||
|
// dynamic loader won't be able to find libc++ when loading libllvmstubs.
|
||||||
|
// For some reason, this worked fine before macOS 12.3.
|
||||||
|
//
|
||||||
|
// To enforce linking with proper libc++, pass the default path explicitly:
|
||||||
|
linkerOpts "-L${platformManager.hostPlatform.absoluteTargetSysRoot}/usr/lib"
|
||||||
|
}
|
||||||
linkerOpts "-L$llvmDir/lib", "-L${rootProject.project(':kotlin-native:llvmDebugInfoC').buildDir}", "-L${rootProject.project(':kotlin-native:llvmCoverageMappingC').buildDir}"
|
linkerOpts "-L$llvmDir/lib", "-L${rootProject.project(':kotlin-native:llvmDebugInfoC').buildDir}", "-L${rootProject.project(':kotlin-native:llvmCoverageMappingC').buildDir}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user