Skip to content

Commit 453abf9

Browse files
committed
Ensure mx_substratevm.graal_compiler_flags() defaults to exports with ALL-UNNAMED
1 parent 41902fa commit 453abf9

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

substratevm/mx.substratevm/mx_substratevm.py

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,18 +76,13 @@ def svm_java_compliance():
7676
def svm_java8():
7777
return svm_java_compliance() <= mx.JavaCompliance('1.8')
7878

79-
def graal_compiler_flags(version_tag=None):
80-
version_tag = version_tag or svm_java_compliance().value
81-
config_path = mx.dependency('substratevm:svm-compiler-flags-builder').result_file_path(version_tag)
82-
if not exists(config_path):
83-
missing_flags_message = '''
84-
Missing graal-compiler-flags config-file {0}. Possible causes:
85-
* Forgot to run "mx build" before using SubstrateVM.
86-
* Generating config-file for Java {1} missing in SubstrateCompilerFlagsBuilder.compute_graal_compiler_flags_map().
87-
'''
88-
mx.abort(missing_flags_message.format(config_path, version_tag))
89-
with open(config_path, 'r') as config_file:
90-
return config_file.read().splitlines()
79+
def graal_compiler_flags(all_unnamed=True):
80+
version_tag = svm_java_compliance().value
81+
compiler_flags = mx.dependency('substratevm:svm-compiler-flags-builder').compute_graal_compiler_flags_map(all_unnamed=all_unnamed)
82+
if version_tag not in compiler_flags:
83+
missing_flags_message = 'Missing graal-compiler-flags for {0}.\n Did you forget to run "mx build"?'
84+
mx.abort(missing_flags_message.format(version_tag))
85+
return compiler_flags[version_tag]
9186

9287
def svm_unittest_config_participant(config):
9388
vmArgs, mainClass, mainClassArgs = config
@@ -1490,7 +1485,7 @@ def config_file_update(self, file_path, lines, file_paths):
14901485

14911486
# If renaming or moving this method, please update the error message in
14921487
# com.oracle.svm.driver.NativeImage.BuildConfiguration.getBuilderJavaArgs().
1493-
def compute_graal_compiler_flags_map(self):
1488+
def compute_graal_compiler_flags_map(self, all_unnamed=not USE_NI_JPMS):
14941489
graal_compiler_flags_map = dict()
14951490
graal_compiler_flags_map[8] = [
14961491
'-d64',
@@ -1507,7 +1502,7 @@ def compute_graal_compiler_flags_map(self):
15071502
distributions_transitive = mx.classpath_entries(self.deps)
15081503
jdk = mx.get_jdk(tag='default')
15091504
required_exports = mx_javamodules.requiredExports(distributions_transitive, jdk)
1510-
target_module = None if USE_NI_JPMS else 'ALL-UNNAMED'
1505+
target_module = 'ALL-UNNAMED' if all_unnamed else None
15111506
exports_flags = mx_sdk_vm.AbstractNativeImageConfig.get_add_exports_list(required_exports, target_module)
15121507
graal_compiler_flags_map[11].extend(exports_flags)
15131508

0 commit comments

Comments
 (0)