From 10b48296e82362cd8c4e83b69b3f014d7a2cd3b1 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Mon, 29 Nov 2021 19:17:06 +0300 Subject: [PATCH] [K/N] Fix FrameworkTest in case of simulator target As of Xcode 13.1 Swift 5.5 passes wrong libclang_rt to simulator targets (similar to ours KT-47333). To workaround this problem, we explicitly provide the correct one. --- .../main/kotlin/org/jetbrains/kotlin/FrameworkTest.kt | 11 ++++++++++- .../org/jetbrains/kotlin/konan/target/Linker.kt | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) 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 }