[K/N] Fix for KT-48807

Make NS_FORMAT_ARGUMENT(A) a no-op in cinterop because our
Clang doesn't support it for NSAttributedString.
This commit is contained in:
Sergey Bogolepov
2021-09-23 12:32:42 +07:00
committed by Space
parent fd71520d6e
commit ed4fa2c391
3 changed files with 32 additions and 23 deletions
@@ -477,34 +477,14 @@ internal fun buildNativeLibrary(
val compilerOpts: List<String> = mutableListOf<String>().apply {
addAll(def.config.compilerOpts)
addAll(tool.getDefaultCompilerOptsForLanguage(language))
// 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")
// Allow throwing exceptions through generated stubs.
add("-fexceptions")
addAll(additionalCompilerOpts)
addAll(getCompilerFlagsForVfsOverlay(arguments.headerFilterPrefix.toTypedArray(), def))
addAll(when (language) {
Language.C -> emptyList()
Language.CPP -> emptyList()
Language.OBJECTIVE_C -> {
// "Objective-C" within interop means "Objective-C with ARC":
listOf("-fobjc-arc")
// Using this flag here has two effects:
// 1. The headers are parsed with ARC enabled, thus the API is visible correctly.
// 2. The generated Objective-C stubs are compiled with ARC enabled, so reference counting
// calls are inserted automatically.
}
})
}
val compilation = CompilationImpl(
includes = headerFiles,
additionalPreambleLines = def.defHeaderLines,
compilerArgs = compilerOpts + tool.platformCompilerOpts,
compilerArgs = defaultCompilerArgs(language) + compilerOpts + tool.platformCompilerOpts,
language = language
)