Skip to content

[GR-66817] [GR-65404] Make --polyglot the default in AbstractLanguageLauncher and remove PolyglotLauncher #11906

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sdk/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ This changelog summarizes major changes between GraalVM SDK versions. The main f
## Version 26.0.0
* GR-65048: GR-65048: Introduced the `-Dpolyglot.engine.allowUnsupportedPlatform=true` system property to enable Truffle to run on unsupported platforms. If this property is enabled then the failure will be suppressed. Please see follow-up errors and warnings for instructions on how to continue. Note that using an unsupported platform will also force the fallback runtime without runtime optimization.
* GR-66515 If neither a log handler nor the `log.file` option is set on the `Engine.Builder` or `Context.Builder`, Truffle and language log messages will be written to the Context’s error output stream by default. The `log.file` option is now also supported on `Context.Builder`.
* GR-66817 Make `--polyglot` the default for language launchers, so there is no need to specify it anymore to use other languages in standalones. As a result, `AbstractLanguageLauncher#getDefaultLanguages()` and `Launcher#canPolyglot()` have been deprecated.
* GR-65404 Remove `PolyglotLauncher` as it is no longer used.

## Version 25.0.0
* GR-60636 Truffle now stops compiling when the code cache fills up on HotSpot. A warning is printed when that happens.
Expand Down
6 changes: 2 additions & 4 deletions sdk/mx.sdk/mx_sdk_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,13 @@


class AbstractNativeImageConfig(object, metaclass=ABCMeta):
def __init__(self, destination, jar_distributions, build_args, use_modules=None, links=None, is_polyglot=False, dir_jars=False, home_finder=False, build_time=1, build_args_enterprise=None): # pylint: disable=super-init-not-called
def __init__(self, destination, jar_distributions, build_args, use_modules=None, links=None, dir_jars=False, home_finder=False, build_time=1, build_args_enterprise=None): # pylint: disable=super-init-not-called
"""
:type destination: str
:type jar_distributions: list[str]
:type build_args: list[str]
:param str | None use_modules: Run (with 'launcher') or run and build image with module support (with 'image').
:type links: list[str] | None
:type is_polyglot: bool
:param bool dir_jars: If true, all jars in the component directory are added to the classpath.
:type home_finder: bool
:type build_time: int
Expand All @@ -100,7 +99,6 @@ def __init__(self, destination, jar_distributions, build_args, use_modules=None,
self.build_args = build_args
self.use_modules = use_modules
self.links = [mx_subst.path_substitutions.substitute(link) for link in links] if links else []
self.is_polyglot = is_polyglot
self.dir_jars = dir_jars
self.home_finder = home_finder
self.build_time = build_time
Expand Down Expand Up @@ -184,7 +182,7 @@ def __init__(self, destination, jar_distributions, main_class, build_args, langu
:param str language
"""
super(LanguageLauncherConfig, self).__init__(destination, jar_distributions, main_class, build_args,
is_sdk_launcher=is_sdk_launcher, is_polyglot=False, **kwargs)
is_sdk_launcher=is_sdk_launcher, **kwargs)
self.language = language

# Ensure the language launcher can always find the language home
Expand Down
4 changes: 1 addition & 3 deletions sdk/mx.sdk/mx_sdk_vm_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2015,7 +2015,7 @@ def _get_main_module():
def _get_extra_jvm_args():
image_config = self.subject.native_image_config
extra_jvm_args = mx.list_to_cmd_line(image_config.extra_jvm_args)
if isinstance(self.subject.component, mx_sdk.GraalVmTruffleComponent) or image_config.is_polyglot:
if isinstance(self.subject.component, mx_sdk.GraalVmTruffleComponent):
extra_jvm_args = ' '.join([extra_jvm_args, '--enable-native-access=org.graalvm.truffle'])
# GR-59703: Migrate sun.misc.* usages.
if mx.VersionSpec("23.0.0") <= mx.get_jdk(tag='default').version:
Expand Down Expand Up @@ -2194,8 +2194,6 @@ def get_build_args(self):
] + svm_experimental_options(experimental_build_args) + [
'--macro:' + GraalVmNativeProperties.macro_name(self.subject.native_image_config), # last to allow overrides
]
if self.subject.native_image_config.is_polyglot:
build_args += ["--macro:truffle", "--language:all"]
return build_args


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private static Constructor<AbstractLanguageLauncher> getLauncherCtor() {
protected final void launch(String[] args) {
try {
try {
launch(new ArrayList<>(Arrays.asList(args)), null, true);
launch(new ArrayList<>(Arrays.asList(args)));
} catch (AbortException e) {
throw e;
} catch (PolyglotException e) {
Expand Down Expand Up @@ -260,15 +260,12 @@ protected long getNativeArgv() {

protected static final boolean IS_LIBPOLYGLOT = Boolean.getBoolean("graalvm.libpolyglot");

final void launch(List<String> args, Map<String, String> defaultOptions, boolean doNativeSetup) {
final void launch(List<String> args) {
List<String> originalArgs = Collections.unmodifiableList(new ArrayList<>(args));

Map<String, String> polyglotOptions = defaultOptions;
if (polyglotOptions == null) {
polyglotOptions = new HashMap<>();
}
Map<String, String> polyglotOptions = new HashMap<>();

if (isAOT() && doNativeSetup) {
if (isAOT()) {
System.setProperty("org.graalvm.launcher.languageId", getLanguageId());
}

Expand All @@ -278,9 +275,9 @@ final void launch(List<String> args, Map<String, String> defaultOptions, boolean
validateVmArguments(originalArgs, unrecognizedArgs);
}

if (isAOT() && doNativeSetup && !IS_LIBPOLYGLOT) {
if (isAOT() && !IS_LIBPOLYGLOT) {
assert nativeAccess != null;
maybeExec(originalArgs, unrecognizedArgs, false, getDefaultVMType(), jniLaunch);
maybeExec(originalArgs, unrecognizedArgs, getDefaultVMType(), jniLaunch);
}

parseUnrecognizedOptions(getLanguageId(), polyglotOptions, unrecognizedArgs);
Expand All @@ -292,14 +289,7 @@ final void launch(List<String> args, Map<String, String> defaultOptions, boolean
validateArguments(polyglotOptions);
argumentsProcessingDone();

Context.Builder builder;
if (isPolyglot()) {
builder = Context.newBuilder().options(polyglotOptions);
} else {
builder = Context.newBuilder(getDefaultLanguages()).options(polyglotOptions);
}

builder.allowAllAccess(true);
Context.Builder builder = Context.newBuilder().allowAllAccess(true).options(polyglotOptions);
setupContextBuilder(builder);

launch(builder);
Expand All @@ -308,16 +298,16 @@ final void launch(List<String> args, Map<String, String> defaultOptions, boolean
/**
* Process command line arguments by either saving the necessary state or adding it to the
* {@code polyglotOptions}. Any unrecognized arguments should be accumulated and returned as a
* list. VM (--jvm/--native/--polyglot/--vm.*) and polyglot options (--language.option or
* --option) should be returned as unrecognized arguments to be automatically parsed and
* validated by {@link Launcher#parsePolyglotOption(String, Map, boolean, String)}.
*
* list. VM (--jvm/--native/--vm.*) and polyglot options (--language.option or --option) should
* be returned as unrecognized arguments to be automatically parsed and validated by
* {@link Launcher#parsePolyglotOption(String, Map, boolean, String)}.
* <p>
* The {@code arguments} should not be modified, but doing so also has no effect.
*
* <p>
* {@code polyglotOptions.put()} can be used to set launcher-specific default values when they
* do not match the OptionKey's default.
*
* The {@code preprocessArguments} implementations can use {@link Engine} to inspect the the
* <p>
* The {@code preprocessArguments} implementations can use {@link Engine} to inspect the
* installed {@link Engine#getLanguages() guest languages} and {@link Engine#getInstruments()
* instruments}. But creating a {@link Context} or inspecting {@link Engine#getOptions() engine
* options} is forbidden.
Expand Down Expand Up @@ -399,12 +389,15 @@ protected void runVersionAction(VersionAction action, Engine engine) {
}

/**
* The return value specifies what languages should be available by default when not using
* --polyglot. Note that TruffleLanguage.Registration#dependentLanguages() should be preferred
* in most cases.
* The return value used to specify what languages should be available by default when not using
* --polyglot. --polyglot is default since 26.0 so this is no longer used. Note that
* TruffleLanguage.Registration#dependentLanguages() should be preferred in most cases.
*
* @deprecated no longer has any effect, all languages are always available for
* AbstractLanguageLauncher.
* @return an array of required language ids
*/
@Deprecated(since = "26.0")
protected String[] getDefaultLanguages() {
return new String[]{getLanguageId()};
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2019, 2023, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2019, 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* The Universal Permissive License (UPL), Version 1.0
Expand Down Expand Up @@ -74,7 +74,6 @@ public abstract class LanguageLauncherBase extends Launcher {
private static final String WEBSITE_HEADER = "[website]";

private static Engine tempEngine;
private boolean seenPolyglot;
private VersionAction versionAction = VersionAction.None;

static Engine getTempEngine() {
Expand Down Expand Up @@ -167,14 +166,6 @@ static List<Instrument> sortedInstruments(Engine engine) {
return instruments;
}

final boolean isPolyglot() {
return seenPolyglot;
}

final void setPolyglot(boolean polyglot) {
seenPolyglot = polyglot;
}

final void setupContextBuilder(Context.Builder builder) {
Path logFile = getLogFile();
if (logFile != null) {
Expand Down Expand Up @@ -218,7 +209,7 @@ protected boolean runLauncherAction() {
protected boolean parseCommonOption(String defaultOptionPrefix, Map<String, String> polyglotOptions, boolean experimentalOptions, String arg) {
switch (arg) {
case "--polyglot":
seenPolyglot = true;
// the default, just ignore it
break;
case "--version:graalvm":
versionAction = VersionAction.PrintAndExit;
Expand Down
Loading
Loading