[K/N] Prohibit -Xcompile-from-bitcode when producing library

This commit is contained in:
Sergey Bogolepov
2023-03-06 15:34:32 +02:00
committed by Space Team
parent 0e721c8fc2
commit bba7e9e395
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.getModuleNameForSource
import org.jetbrains.kotlin.konan.file.File
import org.jetbrains.kotlin.konan.target.CompilerOutputKind
import org.jetbrains.kotlin.konan.util.visibleName
fun CompilerConfiguration.setupFromArguments(arguments: K2NativeCompilerArguments) = with(KonanConfigKeys) {
val commonSources = arguments.commonSources?.toSet().orEmpty().map { it.absoluteNormalizedFile() }
@@ -262,7 +263,7 @@ fun CompilerConfiguration.setupFromArguments(arguments: K2NativeCompilerArgument
arguments.testDumpOutputPath?.let { put(TEST_DUMP_OUTPUT_PATH, it) }
put(PARTIAL_LINKAGE, arguments.partialLinkage)
put(OMIT_FRAMEWORK_BINARY, arguments.omitFrameworkBinary)
putIfNotNull(COMPILE_FROM_BITCODE, arguments.compileFromBitcode)
putIfNotNull(COMPILE_FROM_BITCODE, parseCompileFromBitcode(arguments, this@setupFromArguments, outputKind))
putIfNotNull(SERIALIZED_DEPENDENCIES, parseSerializedDependencies(arguments, this@setupFromArguments))
putIfNotNull(SAVE_DEPENDENCIES_PATH, arguments.saveDependenciesPath)
putIfNotNull(SAVE_LLVM_IR_DIRECTORY, arguments.saveLlvmIrDirectory)
@@ -517,4 +518,16 @@ private fun parseSerializedDependencies(
"Providing serialized dependencies only works in conjunction with a bitcode file to compile.")
}
return arguments.serializedDependencies
}
private fun parseCompileFromBitcode(
arguments: K2NativeCompilerArguments,
configuration: CompilerConfiguration,
outputKind: CompilerOutputKind,
): String? {
if (!arguments.compileFromBitcode.isNullOrEmpty() && !outputKind.involvesBitcodeGeneration) {
configuration.report(ERROR,
"Compilation from bitcode is not available when producing ${outputKind.visibleName}")
}
return arguments.compileFromBitcode
}