[PL] Disallow partial linkage when compiler is configured to produce KLIB

Partial linkage is intended for producing binaries, not libraries.
This commit is contained in:
Dmitriy Dolovov
2023-03-30 15:41:41 +02:00
committed by Space Team
parent 1fef48bb60
commit b7d0209e4b
3 changed files with 36 additions and 12 deletions
@@ -172,10 +172,6 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
configuration.put(JSConfigurationKeys.WASM_ENABLE_ARRAY_RANGE_CHECKS, arguments.wasmEnableArrayRangeChecks)
configuration.put(JSConfigurationKeys.WASM_ENABLE_ASSERTS, arguments.wasmEnableAsserts)
configuration.put(JSConfigurationKeys.WASM_GENERATE_WAT, arguments.wasmGenerateWat)
configuration.setupPartialLinkageConfig(arguments.partialLinkageMode, arguments.partialLinkageLogLevel) { errorMessage ->
messageCollector.report(ERROR, errorMessage, null)
return COMPILATION_ERROR
}
val commonSourcesArray = arguments.commonSources
val commonSources = commonSourcesArray?.toSet() ?: emptySet()
@@ -262,6 +258,14 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
mainCallArguments = mainCallArguments
)
configuration.setupPartialLinkageConfig(
mode = arguments.partialLinkageMode,
logLevel = arguments.partialLinkageLogLevel,
compilerModeAllowsUsingPartialLinkage = arguments.includes != null, // Don't run PL when producing KLIB.
onWarning = { messageCollector.report(WARNING, it) },
onError = { messageCollector.report(ERROR, it) }
)
// Run analysis if main module is sources
var sourceModule: ModulesStructure? = null
val includes = arguments.includes