Skip to content

Commit 641df34

Browse files
committed
make jdk.graal.nativeimage and org.graalvm.nativebridge optional dependencies of jdk.graal.compiler
1 parent 94b2b1b commit 641df34

File tree

4 files changed

+19
-12
lines changed

4 files changed

+19
-12
lines changed

compiler/mx.compiler/suite.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,13 @@
597597
# This distribution defines a module.
598598
"moduleInfo" : {
599599
"name" : "jdk.graal.compiler",
600+
"requires" : [
601+
# These dependencies are only required when building libgraal.
602+
# Running jargraal works without them so make them optional
603+
# (i.e., "static") dependencies.
604+
"static jdk.graal.nativeimage",
605+
"static org.graalvm.nativebridge"
606+
],
600607
"exports" : [
601608
"""* to com.oracle.graal.graal_enterprise,
602609
org.graalvm.nativeimage.pointsto,

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/options/OptionsParser.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
import org.graalvm.collections.EconomicMap;
4343
import org.graalvm.collections.EconomicSet;
4444
import org.graalvm.collections.MapCursor;
45+
import org.graalvm.nativeimage.ImageInfo;
4546

4647
/**
4748
* This class contains methods for parsing Graal options and matching them against a set of
@@ -66,9 +67,11 @@ public static LibGraalOptionsInfo create() {
6667

6768
/**
6869
* Compiler options info available in libgraal. This field is only non-null when
69-
* {@link OptionsParser} is loaded by a {@link jdk.graal.nativeimage.LibGraalLoader}.
70+
* {@link OptionsParser} is loaded by a {@link jdk.graal.nativeimage.LibGraalLoader} and
71+
* {@linkplain ImageInfo#inImageBuildtimeCode libgraal is being built}.
7072
*/
71-
public static final LibGraalOptionsInfo libgraalOptions = OptionsParser.class.getClassLoader() instanceof LibGraalLoader ? LibGraalOptionsInfo.create() : null;
73+
public static final LibGraalOptionsInfo libgraalOptions = inImageBuildtimeCode() &&
74+
OptionsParser.class.getClassLoader() instanceof LibGraalLoader ? LibGraalOptionsInfo.create() : null;
7275

7376
/**
7477
* Gets an iterable of available {@link OptionDescriptors}.
@@ -79,10 +82,10 @@ public static Iterable<OptionDescriptors> getOptionsLoader() {
7982
return List.of(new OptionDescriptorsMap(Objects.requireNonNull(libgraalOptions.descriptors, "missing options")));
8083
}
8184
boolean inLibGraal = libgraalOptions != null;
82-
if (inLibGraal && inImageBuildtimeCode()) {
85+
if (inLibGraal) {
8386
/*
84-
* Graal code is being run is loaded by a LibGraalLoader while building libgraal so use
85-
* the loader to load the OptionDescriptors.
87+
* Graal code being run is loaded by a LibGraalLoader while building libgraal so use the
88+
* loader to load the OptionDescriptors.
8689
*/
8790
ClassLoader myCL = OptionsParser.class.getClassLoader();
8891
return ServiceLoader.load(OptionDescriptors.class, myCL);

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/serviceprovider/GraalServices.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ private static void addProviders(String arch, Class<?> service) {
114114

115115
static {
116116
ClassLoader cl = GraalServices.class.getClassLoader();
117-
if (cl instanceof LibGraalLoader libgraalLoader) {
117+
if (inImageBuildtimeCode() && cl instanceof LibGraalLoader libgraalLoader) {
118118
libgraalServices = new HashMap<>();
119119
Set<String> libgraalServicesModules = libgraalLoader.getServicesModules();
120120
Map<String, String> modules = libgraalLoader.getModuleMap();

truffle/mx.truffle/mx_truffle.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -735,15 +735,12 @@ def _sl_jvm_compiler_on_upgrade_module_path_gate_tests(jdk):
735735
# Ignore tests for Truffle LTS gate using GraalVM as a base JDK
736736
mx.log(f'Ignoring SL JVM Optimized with Compiler on Upgrade Module Path on {jdk.home} because JDK is GraalVM')
737737
return
738-
compiler_cp = os.pathsep.join((mx.distribution(name).classpath_repr() for name in (
739-
'compiler:GRAAL',
740-
'compiler:GRAAL_NATIVEIMAGE',
741-
'sdk:NATIVEBRIDGE'
742-
)))
738+
compiler = mx.distribution('compiler:GRAAL')
743739
vm_args = [
744740
'-XX:+UnlockExperimentalVMOptions',
745741
'-XX:+EnableJVMCI',
746-
f'--upgrade-module-path={compiler_cp}',
742+
'-Djdk.graal.CompilationFailureAction=ExitVM',
743+
f'--upgrade-module-path={compiler.classpath_repr()}',
747744
]
748745

749746
def run_jvm_optimized(test_file):

0 commit comments

Comments
 (0)