diff --git a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt index a7031a4aad0..34bc5d74eec 100644 --- a/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt +++ b/kotlin-native/build-tools/src/main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt @@ -169,7 +169,16 @@ open class FrameworkTest : DefaultTask(), KonanTestExecutable { "-F", frameworkParentDirPath, "-Xcc", "-Werror" // To fail compilation on warnings in framework header. ) - compileSwift(project, project.testTarget, sources, options + swiftExtraOpts, Paths.get(executable), fullBitcode) + // As of Xcode 13.1 swift passes wrong libclang_rt to simulator targets (similar to KT-47333). + // To workaround this problem, we explicitly provide the correct one. + val simulatorHack = if (project.testTargetConfigurables.targetTriple.isSimulator) { + project.platformManager.platform(project.testTarget).linker.provideCompilerRtLibrary("")?.let { + listOf("-Xlinker", it) + } ?: emptyList() + } else { + emptyList() + } + compileSwift(project, project.testTarget, sources, options + simulatorHack + swiftExtraOpts, Paths.get(executable), fullBitcode) } @TaskAction diff --git a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt index 48fca7b9827..f3ca9d72e30 100644 --- a/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt +++ b/kotlin-native/shared/src/main/kotlin/org/jetbrains/kotlin/konan/target/Linker.kt @@ -94,7 +94,7 @@ abstract class LinkerFlags(val configurables: Configurables) { return libraries } - protected open fun provideCompilerRtLibrary(libraryName: String, isDynamic: Boolean = false): String? { + open fun provideCompilerRtLibrary(libraryName: String, isDynamic: Boolean = false): String? { System.err.println("Can't provide $libraryName.") return null }