From 38763f2306fea127c9f7f257edb2e3e984666625 Mon Sep 17 00:00:00 2001 From: Loic Ottet Date: Wed, 1 Oct 2025 15:07:10 +0200 Subject: [PATCH] Add macro for LLVM backend --- sdk/mx.sdk/mx_sdk_benchmark.py | 2 +- substratevm/CHANGELOG.md | 1 + substratevm/ci/ci_common/svm-gate.libsonnet | 2 +- substratevm/mx.substratevm/mx_substratevm.py | 5 +++-- substratevm/mx.substratevm/suite.py | 9 +++++++++ substratevm/mx.substratevm/tool-llvm.properties | 4 ++++ .../src/com/oracle/svm/core/graal/llvm/LLVMBackend.md | 2 +- 7 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 substratevm/mx.substratevm/tool-llvm.properties diff --git a/sdk/mx.sdk/mx_sdk_benchmark.py b/sdk/mx.sdk/mx_sdk_benchmark.py index fcd4fa059b7f..8cfb608bd919 100644 --- a/sdk/mx.sdk/mx_sdk_benchmark.py +++ b/sdk/mx.sdk/mx_sdk_benchmark.py @@ -425,7 +425,7 @@ def __init__(self, vm: NativeImageVM, bm_suite: BenchmarkSuite | NativeImageBenc if vm.use_compacting_gc: base_image_build_args += ['-H:+CompactingOldGen'] if vm.is_llvm: - base_image_build_args += ['--features=org.graalvm.home.HomeFinderFeature'] + ['-H:CompilerBackend=llvm', + base_image_build_args += ['--features=org.graalvm.home.HomeFinderFeature'] + ['--tool:llvm-backend', '-H:DeadlockWatchdogInterval=0'] if vm.gc: base_image_build_args += ['--gc=' + vm.gc] + ['-H:+SpawnIsolates'] diff --git a/substratevm/CHANGELOG.md b/substratevm/CHANGELOG.md index 6e43eeb9b86f..81b4b4d18a1d 100644 --- a/substratevm/CHANGELOG.md +++ b/substratevm/CHANGELOG.md @@ -8,6 +8,7 @@ This changelog summarizes major changes to GraalVM Native Image. * (GR-69280) Allow use of the `graal.` prefix for options without issuing a warning. * (GR-2092) Add jitdump support for recording run-time compilation metadata for perf (see PerfProfiling.md). Can be enabled with `-g -H:+RuntimeDebugInfo -H:RuntimeDebugInfoFormat=jitdump`. * (GR-69572) Deprecates the `native-image-inspect` tool. To extract embedded SBOMs, use `native-image-configure extract-sbom --image-path=`. +* (GR-70136) Add a new tool `--tool:llvm` for the LLVM backend of Native Image. ## GraalVM 25 * (GR-52276) (GR-61959) Add support for Arena.ofShared(). diff --git a/substratevm/ci/ci_common/svm-gate.libsonnet b/substratevm/ci/ci_common/svm-gate.libsonnet index c7a6a189f047..58f3bafd089c 100644 --- a/substratevm/ci/ci_common/svm-gate.libsonnet +++ b/substratevm/ci/ci_common/svm-gate.libsonnet @@ -116,7 +116,7 @@ use_llvm:: task_spec({ mxgate_config+::["llvm"], - mxgate_extra_args+: ["--extra-image-builder-arguments=-H:+UnlockExperimentalVMOptions -H:CompilerBackend=llvm -H:-UnlockExperimentalVMOptions"], + mxgate_extra_args+: ["--extra-image-builder-arguments=-H:+UnlockExperimentalVMOptions --tool:llvm-backend -H:-UnlockExperimentalVMOptions"], }), use_ecj:: task_spec({ diff --git a/substratevm/mx.substratevm/mx_substratevm.py b/substratevm/mx.substratevm/mx_substratevm.py index bf4c1654ade8..5eac86e74954 100644 --- a/substratevm/mx.substratevm/mx_substratevm.py +++ b/substratevm/mx.substratevm/mx_substratevm.py @@ -1546,11 +1546,11 @@ def _native_image_launcher_extra_jvm_args(): jlink=False, )) -ce_llvm_backend = mx_sdk_vm.GraalVmJreComponent( +ce_llvm_backend = mx_sdk_vm.GraalVmSvmTool( suite=suite, name='Native Image LLVM Backend', short_name='svml', - dir_name='svm', + dir_name='llvm-backend', license_files=[], third_party_license_files=[], dependencies=[ @@ -1564,6 +1564,7 @@ def _native_image_launcher_extra_jvm_args(): 'substratevm:LLVM_PLATFORM_SPECIFIC_SHADOWED', 'substratevm:JAVACPP_PLATFORM_SPECIFIC_SHADOWED', ], + support_distributions=['substratevm:SVM_LLVM_GRAALVM_SUPPORT'], stability="experimental-earlyadopter", jlink=False, ) diff --git a/substratevm/mx.substratevm/suite.py b/substratevm/mx.substratevm/suite.py index f8bd399cc411..ae5e2e81ef67 100644 --- a/substratevm/mx.substratevm/suite.py +++ b/substratevm/mx.substratevm/suite.py @@ -2610,6 +2610,15 @@ "maven" : False, }, + "SVM_LLVM_GRAALVM_SUPPORT": { + "native": True, + "description": "LLVM backend support distribution for SVM", + "layout": { + "native-image.properties": "file:mx.substratevm/tool-llvm.properties", + }, + "maven": False, + }, + "SVM_TRUFFLE_TCK" : { "subDir" : "src", "description" : "Truffle TCK", diff --git a/substratevm/mx.substratevm/tool-llvm.properties b/substratevm/mx.substratevm/tool-llvm.properties new file mode 100644 index 000000000000..7ed6ae48cefb --- /dev/null +++ b/substratevm/mx.substratevm/tool-llvm.properties @@ -0,0 +1,4 @@ +ProvidedHostedOptions=IncludeLLVMDebugInfo= DumpLLVMStackMap= LLVMMaxFunctionsPerBatch= CustomLD= BitcodeOptimizations UseLLVMDataSection LLVMDataSectionBatchSizeFactor= +ImageBuilderModulePath=${.}/builder/svm-llvm.jar:${.}/builder/javacpp-shadowed.jar:${.}/builder/javacpp-platform-specific-shadowed.jar:${.}/builder/llvm-wrapper-shadowed.jar:${.}/builder/llvm-platform-specific-shadowed.jar +Args=-H:CompilerBackend=llvm +ExcludeFromAll=true \ No newline at end of file diff --git a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMBackend.md b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMBackend.md index 5c30eee5a990..012353db89cd 100644 --- a/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMBackend.md +++ b/substratevm/src/com.oracle.svm.core.graal.llvm/src/com/oracle/svm/core/graal/llvm/LLVMBackend.md @@ -11,7 +11,7 @@ mx --dynamicimports /substratevm build export JAVA_HOME=$(mx --dynamicimports /substratevm graalvm-home) ``` -To enable the LLVM backend, pass the `-H:CompilerBackend=llvm` option to the `native-image` command. +To enable the LLVM backend, pass the `--tool:llvm` option to the `native-image` command. ## Code Generation Options