Skip to content

Commit

Permalink
Fix native builds without EXTRA_GRAALVM_HOME
Browse files Browse the repository at this point in the history
  • Loading branch information
fniephaus committed Jan 11, 2024
1 parent cf0980d commit 7f9a682
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 11 deletions.
28 changes: 18 additions & 10 deletions mx.trufflesqueak/mx_trufflesqueak.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,25 @@ def patched_init(self, *args, **kw_args):
_enable_local_compression()


def _use_different_graalvm_home_for_native_image(extra_graalvm_home):
def _patch_svm_support_native_image():

def patched_native_image(self, build_args, output_file, allow_server=False, nonZeroIsFatal=True, out=None, err=None):
build_args.remove('--macro:smalltalkvm-library')
def patched_native_image(self, build_args, output_file, out=None, err=None, find_bad_strings=False):
assert 'smalltalkvm' in output_file
native_image_path = os.path.join(extra_graalvm_home, 'bin', mx.cmd_suffix('native-image'))
dist_names = ['TRUFFLESQUEAK', 'TRUFFLESQUEAK_LAUNCHER', 'TRUFFLE_NFI_LIBFFI', 'TRUFFLE-ENTERPRISE', 'SDK-NATIVEBRIDGE'] + mx_truffle.resolve_truffle_dist_names(use_optimized_runtime=True, use_enterprise=True)
selected_gc = 'G1' if mx.is_linux() else 'serial'
build_command = [native_image_path] + build_args + mx.get_runtime_jvm_args(names=dist_names) + [
is_oracle_graalvm = False
extra_graalvm_home = os.getenv('EXTRA_GRAALVM_HOME')
if extra_graalvm_home:
native_image_bin = os.path.join(extra_graalvm_home, 'bin', mx.cmd_suffix('native-image'))
is_oracle_graalvm = '-community' not in is_oracle_graalvm
else:
stage1 = mx_sdk_vm_impl.get_stage1_graalvm_distribution()
native_image_project_name = mx_sdk_vm_impl.GraalVmLauncher.launcher_project_name(mx_sdk.LauncherConfig(mx.exe_suffix('native-image'), [], "", []), stage1=True)
native_image_bin = os.path.join(stage1.output, stage1.find_single_source_location('dependency:' + native_image_project_name))
build_args.remove('--macro:smalltalkvm-library')
dist_names = ['TRUFFLESQUEAK', 'TRUFFLESQUEAK_LAUNCHER', 'TRUFFLE_NFI_LIBFFI', 'SDK-NATIVEBRIDGE'] \
+ (['TRUFFLE-ENTERPRISE'] if is_oracle_graalvm else []) \
+ mx_truffle.resolve_truffle_dist_names(use_optimized_runtime=True, use_enterprise=True)
selected_gc = 'G1' if is_oracle_graalvm and mx.is_linux() else 'serial'
build_command = [native_image_bin] + build_args + mx.get_runtime_jvm_args(names=dist_names) + [
'-o', os.path.splitext(output_file)[0],
'--shared',
'--gc=' + selected_gc,
Expand All @@ -166,9 +176,7 @@ def patched_native_image(self, build_args, output_file, allow_server=False, nonZ
mx_sdk_vm_impl.SvmSupport.native_image = patched_native_image


extra_graalvm_home = os.getenv('EXTRA_GRAALVM_HOME')
if extra_graalvm_home:
_use_different_graalvm_home_for_native_image(extra_graalvm_home)
_patch_svm_support_native_image()


mx_sdk_vm.register_vm_config('trufflesqueak-jar', ['sdk', 'sdkc', 'sdkni', 'ins', 'cov', 'dap', 'lsp', 'sdkl', 'pro', 'insight', 'insightheap', 'tfl', 'tfla', 'tflc', 'truffle-json', 'nfi', 'nfi-libffi', 'st'],
Expand Down
2 changes: 1 addition & 1 deletion mx.trufflesqueak/trufflesqueak-native
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
COMPONENTS=TruffleSqueak,suite:tools,GraalVM compiler,SubstrateVM,Truffle Macro
COMPONENTS=TruffleSqueak,suite:tools,GraalVM compiler,SubstrateVM,Truffle Macro,Truffle SVM Macro
INSTALLABLES=TruffleSqueak
DYNAMIC_IMPORTS=/compiler,/substratevm,/tools
NATIVE_IMAGES=lib:smalltalkvm
Expand Down

0 comments on commit 7f9a682

Please sign in to comment.