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 b03dfae02ee..1d59eccff3a 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 @@ -205,7 +205,6 @@ class K2Native : CLICompiler() { }) put(STATIC_FRAMEWORK, selectFrameworkType(configuration, arguments, outputKind)) put(OVERRIDE_CLANG_OPTIONS, arguments.clangOptions.toNonNullList()) - put(ALLOCATION_MODE, arguments.allocator) put(EXPORT_KDOC, arguments.exportKDoc) @@ -340,6 +339,20 @@ class K2Native : CLICompiler() { false } }) + put(ALLOCATION_MODE, when (arguments.allocator) { + null -> { + when (memoryModel) { + MemoryModel.EXPERIMENTAL -> "mimalloc" + else -> "std" + } + } + "std" -> arguments.allocator!! + "mimalloc" -> arguments.allocator!! + else -> { + configuration.report(ERROR, "Expected 'std' or 'mimalloc' for allocator") + "std" + } + }) put(WORKER_EXCEPTION_HANDLING, when (arguments.workerExceptionHandling) { null -> if (memoryModel == MemoryModel.EXPERIMENTAL) WorkerExceptionHandling.USE_HOOK else WorkerExceptionHandling.LEGACY "legacy" -> WorkerExceptionHandling.LEGACY diff --git a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt index a93fd48a7c6..3b541bbe69b 100644 --- a/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt +++ b/kotlin-native/backend.native/cli.bc/src/org/jetbrains/kotlin/cli/bc/K2NativeCompilerArguments.kt @@ -289,7 +289,7 @@ class K2NativeCompilerArguments : CommonCompilerArguments() { var clangOptions: Array? = null @Argument(value="-Xallocator", valueDescription = "std | mimalloc", description = "Allocator used in runtime") - var allocator: String = "std" + var allocator: String? = null @Argument(value = "-Xmetadata-klib", description = "Produce a klib that only contains the declarations metadata") var metadataKlib: Boolean = false