From 7d8f71d1075857d96db0563b740fd0af99017bdb Mon Sep 17 00:00:00 2001 From: Roman Artemev Date: Tue, 16 Nov 2021 13:28:28 +0300 Subject: [PATCH] [JS IR] Add CLI flag and configuration key about partial linkage - make possible to turn on/off linkage if klib contains unbound symbols - update jsExtraHelp test data --- .../kotlin/cli/common/arguments/K2JSCompilerArguments.kt | 3 +++ .../cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt | 2 ++ compiler/testData/cli/js/jsExtraHelp.out | 1 + .../org/jetbrains/kotlin/js/config/JSConfigurationKeys.java | 3 +++ 4 files changed, 9 insertions(+) diff --git a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt index 428c0be0b9b..58aab7bd326 100644 --- a/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt +++ b/compiler/cli/cli-common/src/org/jetbrains/kotlin/cli/common/arguments/K2JSCompilerArguments.kt @@ -235,6 +235,9 @@ class K2JSCompilerArguments : CommonCompilerArguments() { @Argument(value = "-Xerror-tolerance-policy", description = "Set up error tolerance policy (NONE, SEMANTIC, SYNTAX, ALL)") var errorTolerancePolicy: String? by NullableStringFreezableVar(null) + @Argument(value = "-Xpartial-linkage", description = "Allow unlinked symbols") + var partialLinkage: Boolean by FreezableVar(false) + @Argument(value = "-Xwasm", description = "Use experimental WebAssembly compiler backend") var wasm: Boolean by FreezableVar(false) diff --git a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt index cbdd988186d..2a985e188e7 100644 --- a/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt +++ b/compiler/cli/cli-js/src/org/jetbrains/kotlin/cli/js/K2JsIrCompiler.kt @@ -136,6 +136,8 @@ class K2JsIrCompiler : CLICompiler() { configuration.put(JSConfigurationKeys.TRANSITIVE_LIBRARIES, libraries) configuration.put(JSConfigurationKeys.REPOSITORIES, repositories) + configuration.put(JSConfigurationKeys.PARTIAL_LINKAGE, arguments.partialLinkage) + val commonSourcesArray = arguments.commonSources val commonSources = commonSourcesArray?.toSet() ?: emptySet() for (arg in arguments.freeArgs) { diff --git a/compiler/testData/cli/js/jsExtraHelp.out b/compiler/testData/cli/js/jsExtraHelp.out index fd5916c22c3..24c50dbd337 100644 --- a/compiler/testData/cli/js/jsExtraHelp.out +++ b/compiler/testData/cli/js/jsExtraHelp.out @@ -34,6 +34,7 @@ where advanced options include: -Xir-safe-external-boolean-diagnostic={log|exception} Enable runtime diagnostics when access safely to boolean in external declarations -Xmetadata-only Generate *.meta.js and *.kjsm files only + -Xpartial-linkage Allow unlinked symbols -Xrepositories= Paths to additional places where libraries could be found -Xtyped-arrays Translate primitive arrays to JS typed arrays -Xwasm Use experimental WebAssembly compiler backend diff --git a/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java b/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java index b127f71d639..f3ca1418723 100644 --- a/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java +++ b/js/js.frontend/src/org/jetbrains/kotlin/js/config/JSConfigurationKeys.java @@ -93,4 +93,7 @@ public class JSConfigurationKeys { public static final CompilerConfigurationKey> REPOSITORIES = CompilerConfigurationKey.create("set up additional repository paths"); + + public static final CompilerConfigurationKey PARTIAL_LINKAGE = + CompilerConfigurationKey.create("allows some symbols in klibs be missed"); }