From 178ba2944bde38e72e044d66cfe2f53c8ea430d6 Mon Sep 17 00:00:00 2001 From: Sergey Bogolepov Date: Wed, 18 Dec 2019 18:16:56 +0700 Subject: [PATCH] [Interop][watchos_arm64] Fix platform libs generation Pass -O2 flag to Clang to avoid inline asm in wrappers. --- .../org/jetbrains/kotlin/native/interop/gen/jvm/main.kt | 6 ++++++ 1 file changed, 6 insertions(+) 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) {