Skip to content

Commit

Permalink
Only --enable-native-access=org.graalvm.truffle when svmt present
Browse files Browse the repository at this point in the history
  • Loading branch information
zakkak committed Oct 24, 2024
1 parent 0f833fd commit f7f6612
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
18 changes: 18 additions & 0 deletions sdk/mx.sdk/mx_sdk_vm_impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2317,6 +2317,23 @@ def _get_launcher_args():
return '-J--add-exports=jdk.internal.vm.ci/jdk.vm.ci.code=jdk.graal.compiler'
return ''

def _has_truffle_runtime_svm_component():
"""
Returns whether the Truffle Runtime SVM component is part of the final GraalVM distribution.
"""
if mx.suite('substratevm', fatalIfMissing=False) is not None:
try:
import mx_substratevm
except ModuleNotFoundError:
return False
return has_component(mx_substratevm.truffle_runtime_svm.short_name)
return False

def _get_jvm_args():
if _has_truffle_runtime_svm_component():
return '--enable-native-access=org.graalvm.truffle'
return ''

def _get_add_exports():
return ' '.join(self.subject.native_image_config.get_add_exports(_known_missing_jars))

Expand All @@ -2332,6 +2349,7 @@ def _get_add_exports():
_template_subst.register_no_arg('macro_name', GraalVmNativeProperties.macro_name(self.subject.native_image_config))
_template_subst.register_no_arg('option_vars', _get_option_vars)
_template_subst.register_no_arg('launcher_args', _get_launcher_args)
_template_subst.register_no_arg('jvm_args', _get_jvm_args)

if mx.is_windows():
add_exports_argfile = output_file[:-len('cmd')] + 'export-list'
Expand Down
2 changes: 1 addition & 1 deletion sdk/mx.sdk/vm/launcher_template.cmd
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ for /f "delims=" %%i in ("%relcp:;=!newline!%") do (
)
)

set "jvm_args=--enable-native-access=org.graalvm.truffle -Dorg.graalvm.launcher.shell=true "-Dorg.graalvm.launcher.executablename=%executablename%""
set "jvm_args=<jvm_args> -Dorg.graalvm.launcher.shell=true "-Dorg.graalvm.launcher.executablename=%executablename%""
set "launcher_args=<launcher_args>"

:: Check option-holding variables.
Expand Down
2 changes: 1 addition & 1 deletion sdk/mx.sdk/vm/launcher_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ for e in "${relative_cp[@]}"; do
absolute_cp+=("${location}/${e}")
done

jvm_args=("--enable-native-access=org.graalvm.truffle" "-Dorg.graalvm.launcher.shell=true" "-Dorg.graalvm.launcher.executablename=$0")
jvm_args=(<jvm_args> "-Dorg.graalvm.launcher.shell=true" "-Dorg.graalvm.launcher.executablename=$0")
launcher_args=(<launcher_args>)

# Unfortunately, parsing of `--vm.*` arguments has to be done blind:
Expand Down

0 comments on commit f7f6612

Please sign in to comment.