diff --git a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt index 21d1a64e496..ecfc70fb0c9 100644 --- a/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt +++ b/Interop/StubGenerator/src/main/kotlin/org/jetbrains/kotlin/native/interop/gen/jvm/main.kt @@ -381,6 +381,12 @@ internal fun buildNativeLibrary( val compilerOpts: List = mutableListOf().apply { addAll(def.config.compilerOpts) addAll(tool.defaultCompilerOpts) + // We compile with -O2 because Clang may insert inline asm in bitcode at -O0. + // It is undesirable in case of watchos_arm64 since we target armv7k + // for this target instead of arm64_32 because it is not supported in LLVM 8. + // + // Note that PCH and the *.c file should be compiled with the same optimization level. + add("-O2") addAll(additionalCompilerOpts) addAll(getCompilerFlagsForVfsOverlay(arguments.headerFilterPrefix.toTypedArray(), def)) addAll(when (language) {