From 5bdfa14a374644c01d2fc49e4b985895a2587760 Mon Sep 17 00:00:00 2001 From: Svyatoslav Scherbina Date: Sat, 28 Aug 2021 02:00:38 +0300 Subject: [PATCH] Native: make -Xbinary=memoryModel= equivalent to -memory-model= In particular, the former now enables lazy initialization and hook-based worker exception handling too, as intended. --- .../src/org/jetbrains/kotlin/cli/bc/K2Native.kt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt index 23eca4feda6..b03dfae02ee 100644 --- a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt +++ b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2Native.kt @@ -130,6 +130,11 @@ class K2Native : CLICompiler() { with(KonanConfigKeys) { with(configuration) { + // Can be overwritten by explicit arguments below. + parseBinaryOptions(arguments, configuration).forEach { optionWithValue -> + configuration.put(optionWithValue) + } + arguments.kotlinHome?.let { put(KONAN_HOME, it) } put(NODEFAULTLIBS, arguments.nodefaultlibs || !arguments.libraryToAddToCache.isNullOrEmpty()) @@ -227,7 +232,7 @@ class K2Native : CLICompiler() { put(ENABLE_ASSERTIONS, arguments.enableAssertions) - val memoryModel = when (arguments.memoryModel) { + val memoryModelFromArgument = when (arguments.memoryModel) { "relaxed" -> { configuration.report(STRONG_WARNING, "Relaxed memory model is not yet fully functional") MemoryModel.RELAXED @@ -240,7 +245,8 @@ class K2Native : CLICompiler() { } } - // Can be overwritten after [parseBinaryOptions] below. + // TODO: revise priority and/or report conflicting values. + val memoryModel = get(BinaryOptions.memoryModel) ?: memoryModelFromArgument put(BinaryOptions.memoryModel, memoryModel) when { @@ -360,10 +366,6 @@ class K2Native : CLICompiler() { } }) putIfNotNull(RUNTIME_LOGS, arguments.runtimeLogs) - - parseBinaryOptions(arguments, configuration).forEach { optionWithValue -> - configuration.put(optionWithValue) - } } } }