Build mx Java projects as individual Bazel targets. mx loads the suite and resolves its dependencies during migration. The generated declarations can then be reviewed, checked in, and built with Elide. Java compile actions consume source files, compile-time dependency jars and execution toolchains. They have no dependency on the mx launcher, suite.py or the discovery checkout.
Use Bazelisk from the repository root. The module fetches the exact mx revision used to initialize this repository. It works independently of the location of a developer's mx checkout.
bazelisk run //:mx -- --version
bazelisk run --config=elide-python //:mx -- --version
bazelisk build //:webserver @graal_mx//:com.oracle.mxtool.checkcopy @graal_mx//:com.oracle.mxtool.compilerserver
tools/check-graph
bazelisk build //tests/gazelle/...
bazelisk test //mx:export_test
bazelisk test --config=elide-python //mx:export_testThe default Python is managed CPython 3.13. The alternate configuration selects the matching Elide Python runtime for macOS arm64 or Linux x86_64/arm64. Both paths use the same rules_python binary. The checked-in rules_elide archive override provides the overlay support. Elide also compiles the Java targets and supplies JavaInfo and ABI jars. The launcher supplies the file-backed JDK selected by Bazel to mx as JAVA_HOME. Use a downloaded Java runtime in a consuming root, for example with --java_runtime_version=remotejdk_21.
The pinned Elide Graal fork exposes 322 of 371 declared mx projects and 281 of 315 distributions (280 of 313 active) through Bazel. The SDK, Truffle, compiler, Regex, Tools, SubstrateVM, Espresso, Espresso Shared, Espresso Compiler Stub, Web Image, Wasm, Visualizer and VM suites have labels for every declared project and distribution. Run individual upstream tests by label. Use tools/graal-coverage --active-only --missing to list the active roots that still need a Bazel implementation. Build and test coverage by suite
bazelisk build --config=elide-processors @graal//truffle:all_projects @graal//compiler:all_distributions @graal//regex:all_distributions
bazelisk test --config=elide-processors @graal//truffle:harness_tests @graal//compiler:harness_tests
bazelisk query 'tests(//graal:sdk_tests)'
bazelisk test --config=labsjdk --config=elide-processors @graal//web-image:unit_tests //graal:espresso_package_test
bazelisk test @graal//truffle:sl.test.Fibonacci
bazelisk test --config=elide-processors @graal//compiler:sl_compilation_test
bazelisk test --config=elide-processors @graal//truffle:sl_jit.tck.IdentityFunctionTest @graal//compiler:GR42688Test
bazelisk test --config=elide-processors //graal/... @graal//sdk/... @graal//truffle/... @graal//compiler/...
bazelisk test --config=elide-processors //graal/nativebridge:native_isolate_test
bazelisk test --config=labsjdk --config=elide-processors //graal:source_native_image_test
bazelisk run --config=labsjdk --config=elide-processors @graal//substratevm:native-image -- --versionThe source-built Native Image launcher assembles the selected Labs JDK with the Bazel-built compiler, SubstrateVM jars and native helper libraries. Use --config=source-native-image to select it for rules_graalvm Native Image actions in this workspace. The smoke test compiles and runs a Java executable on Linux x86_64 and macOS arm64.
The Native Bridge test builds a shared library and exercises the generated JNI bindings in the JVM process and through the C++ launcher. The migration notes cover the standalone benchmark, BuildBuddy commands and remaining suites. GraalVM migration
Run discovery against a trusted, prepared checkout. This is a developer operation. mx loads Python suite extensions and applies its normal environment, platform, JDK and suite-import selection. Invoke discovery separately for each relevant configuration when migrating conditional suites.
bazelisk run //:mx -- -p "$HOME/workspace/graal/sdk" bazel-projects org.graalvm.collections
bazelisk run //:mx -- -p "$HOME/workspace/graal/sdk" bazel-buildfile org.graalvm.collectionsThe first command prints versioned JSON with suite-relative roots, resolved dependency names, Java compliance ranges and processors. The second prints BUILD declarations for the selected projects and their supported same-suite dependencies. Place these declarations at the suite root in its Bazel workspace. They enumerate Java and resource inputs and preserve resource paths within jars. Choose the release explicitly with --release N, or use the declared lower bound. mx's own checkcopy source requires a newer API than its declared minimum, so the three bundled projects use release 21.
Regenerate the bundled macro and review changes with:
bazelisk run //:mx -- bazel-buildfile --macro --release 21 \
com.oracle.mxtool.checkcopy com.oracle.mxtool.compilerserver \
com.oracle.mxtool.webserver > /tmp/mx-projects.bzl &&
diff -u mx/projects.bzl /tmp/mx-projects.bzlThe standalone BUILD exporter handles plain Java projects with a single resource root per project. The Gazelle exporter also handles multiple source and resource roots. It exports annotation processor distributions backed by Java projects. External Java libraries and previously migrated distributions can be bound with --java-dep SUITE:NAME=LABEL. Use --library-module SUITE:LIB=MODULE to name a mapped automatic module when building a JPMS distribution. It diagnoses custom project types and unhandled project attributes. Mapping those features is part of migrating the rest of GraalVM. The generated suite-root targets assume their files share one Bazel package. Introducing nested BUILD files changes ownership of the sources.
bazel-graph --imports emits the resolved projects, distributions and libraries for the primary suite and its loaded imports. It includes the dependency edge kinds, Java archive membership, and distribution layout data. This command discovers inputs without fetching or building the suite's artifacts. Local projects use suite-relative path and source_roots. When a project uses another suite or a packed source library, directory_input or source_inputs identifies the owning suite or qualified library and the relative path.
bazel-buildfile --gazelle --all takes its roots from the resolved primary suite. It exports supported Java projects, JARs, POMs, resource layouts and TARs with explicit file and archive inputs. It also discovers JUnit classes. If a test project belongs to exactly one test JAR, the generated tests use that packaged runtime. Explicit test bindings take precedence.
bazelisk run //:mx -- -p "$PWD/tests/processing" bazel-graph --imports
bazelisk run //:mx -- -p "$PWD/tests/processing" bazel-buildfile --gazelle --all > tests/processing/mx-graph.json
bazelisk run //:gazelle -- -mx_graph=tests/processing/mx-graph.json tests/processingRepeat -mx_graph to generate several suite roots in one Gazelle invocation. Use --suite-package SUITE=//PACKAGE to resolve Java edges to imported suites whose Bazel targets are already available. Individual --java-dep bindings take precedence. Use --provided-target NAME for a suite constituent implemented by an existing Bazel rule at the same label. Suite-wide export fails when a root needs an unsupported lowering. Use --declared-only to select roots declared in suite.py when the suite also registers product configurations dynamically. The exporter still follows the resolved dependencies of those roots.
Add --partial to generate every supported closure in a mixed suite. The JSON lists the emitted and explicitly provided roots in suite_targets and groups the remaining roots by reason in blocked_roots. The strict default makes a useful completeness check once the suite has migrated.
A provider suite can publish its Java targets, JAR artifacts, Java packages and generated processor plugins for downstream Gazelle runs. Import the index at the Bazel package that owns the provider. Source imports resolve against the consuming project's mx classpath. Explicit dependency and processor mappings take precedence.
bazelisk run //:mx -- -p "$provider" bazel-buildfile --gazelle --all \
--bindings-out /tmp/provider.json > "$provider/mx-graph.json"
bazelisk run //:mx -- -p "$consumer" bazel-buildfile --gazelle --all --partial \
--bindings //provider=/tmp/provider.json > "$consumer/mx-graph.json"For Sulong, bazel-graph --cmake-tests includes source cases, variants, reference-build and shared-library settings for each in-tree CMake test project. This lets a generator inspect the test matrix without unpacking external test suites. Supply --sulong-llvm-link LABEL to lower the single-source LLVM IR recipe. Gazelle emits one independently buildable target per case and a project aggregate. The tool label is resolved for the execution platform. Supply --sulong-fixture-sdk LABEL for Linux x86-64 C, C++ and LLVM IR fixtures. The generated rules use the registered rules_foreign_cc CMake and Ninja toolchains to build individual upstream variants with the Graal LLVM SDK and Elide sysroot. Build a Sulong fixture
An exact mx test property such as <path:PROVIDER_JAR> resolves through the imported JAR index. Use --test-data SUITE:PROJECT=LABEL to give a discovered JUnit target a runtime tool or fixture. A matching --test-jvm-flag can refer to that input with Bazel's $(rootpath LABEL).
For each mx-declared processor distribution, the exporter uses mx's resolved service-provider list and emits one native java_plugin per processor class. A processed project becomes a rules_java java_library with explicit plugins. Bazel runs the processors on its execution platform and exposes generated API to downstream Java compilations. Processor implementation projects and ordinary consumers still use elide_java_library.
bazelisk run //:mx -- -p "$PWD/tests/processing" bazel-buildfile --macro consumer
bazelisk test --config=elide-processors //tests/processing:outputs_test //mx:export_testThe elide-processors profile selects the pinned Elide JavaBuilder adapter. It runs eligible compilations through Elide and delegates requests requiring native JNI headers to stock JavaBuilder. The default Java toolchain also builds these native declarations. For binary processors, cross-suite processor distributions, or distributions that require archive transformations, pass --processor-plugin SUITE:DIST=//pkg:plugin. Repeat the option for multiple plugin labels. --java-dep binds ordinary classpath dependencies to JavaInfo targets independently of the processor path.
mx_gazelle bundles the Java extension from contrib_rules_jvm. In a consuming workspace, load it in the root BUILD file and configure Gazelle's rule mapping:
load("@rules_mx//mx:gazelle.bzl", "mx_gazelle")
# gazelle:map_kind java_library elide_java_library @rules_mx//mx:java.bzl
mx_gazelle()Run bazelisk run //:gazelle -- path/to/java/tree for a tree assigned to package-level generation. The checked-in fixture demonstrates two packages with a resolved import edge. Use project-level generation for mutually dependent packages that must be compiled together. For Maven imports, point the Java extension at the consuming workspace's Maven lockfile.
Export a selected project closure once, then run Gazelle on that suite. Both paths below are relative to the Bazel repository root. Keep the graph next to the suite's root BUILD file.
bazelisk run //:mx -- -p "$PWD/tests/gazelle" bazel-buildfile --gazelle \
--java-dep mx:JUNIT=@contrib_rules_jvm_deps//:junit_junit check > /tmp/demo-graph.json &&
cp /tmp/demo-graph.json tests/gazelle/mx-graph.json
bazelisk run //:gazelle -- -mx_graph=tests/gazelle/mx-graph.json tests/gazelle
bazelisk query 'deps(//tests/gazelle:check.example.check.ConsumerTest, 3)'
bazelisk test //tests/gazelle:check.example.check.ConsumerTestFor projects declaring jniHeaders, the generated PROJECT.jni_headers label exposes javac’s JNI header archive. Bind a test property of the form <path:DIST> with --test-path SUITE:DIST=LABEL. Gazelle adds the artifact to each test’s runfiles and resolves the JVM property against that artifact.
The Java extension resolves source imports. For whole-project compilations, --infer-source-deps promotes Java imports found on the resolved mx classpath to direct Bazel dependencies. Use --generated-dep SUITE:PROJECT=LABEL for dependencies referenced by generated Java. The mx importer preserves declared project dependencies and Java releases and exposes each project by name. Building that label produces its package jars, and Java consumers receive their combined compile and runtime classpaths. Plain Java projects use one library per source package using the configured Gazelle Java naming convention. Test projects, projects with resources, and annotation-processed projects keep one compilation unit. Each discovered concrete JUnit 4 test class gets a runnable label. Repeat --test-runtime SUITE:PROJECT=LABEL to discover tests in a published library and supply the packaged test and provider JARs. Use --test-jvm-flag SUITE:PROJECT=FLAG for suite-specific JVM settings. A project can instead supply a shared test executable with --test-launcher SUITE:PROJECT=LABEL. Bazel gives it the selected class as MX_TEST_CLASS. Use --manual-test-project PROJECT to invoke expensive classes explicitly or from a test suite. For mixed-release suites, --project-release PROJECT=RELEASE overrides the selection for that project within its declared compliance range. Use --labs-javac-project PROJECT for a project that needs to compile against the pinned Labs JDK. Add --whole-project NAME at export time for packages that must compile together. Run generation across the entire selected suite when the graph changes and review removed targets and any old nested BUILD files when changing granularity.
Declare rules_mx and use a local_path_override pointing at this checkout during development. Declare rules_elide directly for generated BUILD files. Copy the rules_elide archive override, the Elide installation and its toolchain registration from MODULE.bazel into the consuming root. Bazel applies archive overrides from the root module. For Gazelle, use the pinned Go SDK from MODULE.bazel. For the Python overlay, declare the matching rules_python runtime as shown in tools/BUILD.bazel and select it via --extra_toolchains. The CLI is available as @rules_mx//:mx. To address the bundled native targets directly, import the mx source repository:
mx_sources = use_extension("@rules_mx//mx:extensions.bzl", "mx_sources")
use_repo(mx_sources, "graal_mx")bazelisk build --config=rbc --remote_cache="$CACHE_ENDPOINT" //:webserver
bazelisk build --config=rbe --remote_executor="$EXECUTOR_ENDPOINT" //:webserverThe RBE profile requests Linux x86_64 execution and target platforms, a pinned Linux C++ toolchain for Bazel's auxiliary tools, remote spawn execution and minimal output downloads. Supply any service-specific instance name, worker image digest and authentication in your own Bazel configuration. Cache reuse requires matching execution platforms, toolchain inputs, build options and execution properties. To inspect the execution platform and inputs for each Java compilation:
bazelisk aquery --config=rbe 'mnemonic("ElideJavac", deps(//tests/gazelle/src/main/java/example/app))'With BUILDBUDDY_API_KEY in your local environment, run:
tools/buildbuddy test --config=elide-processors //...
tools/buildbuddy test --config=buildbuddy-rbe --config=elide-processors //tests/processing:outputs_testBoth commands use the elide-dev/rules_mx cache instance. The RBE profile fixes the target and execution CPU settings so macOS and Linux clients produce the same Linux output paths. The second also sends actions to the tenant's Linux AMD64 executors with automatic pool selection.
On pushes to main and manual runs, the Bazel workflow uses the repository's BUILDBUDDY_API_KEY secret and runs the full processor-enabled suite and the exporter tests with Labs JDK and Elide Python on BuildBuddy. Pull requests run the same tests on the GitHub runner without the cluster credential. Open the invocation link in the job log to inspect remote actions and cache hits.
Use Conventional Commits such as feat: export a suite dependency or fix: preserve processor order. Release Please opens a release PR on main with the changelog and Bazel module version. Review and merge that PR to create the version tag and GitHub release.
The initial Linux x86_64 REAPI smoke build compiled and packaged the real Graal SDK org.graalvm.collections project. The jar contained EconomicMap.class and META-INF/native-image/org.graalvm.sdk/collections/native-image.properties. The exporter regression suite passed remotely with CPython and with the Elide overlay. A fresh output base recovered all six compile and packaging actions for the webserver and the two-package Gazelle fixture from an HTTP cache. An implementation-only edit to the fixture's API package reused the consumer compilation.
Ordinary Java builds use Elide persistent workers and emit the ABI alongside the class jar for eligible targets. For local builds with explicitly modeled processors, bazelisk build --config=elide-workers //tests/gazelle/... //:webserver also enables multiplex workers and digest-keyed classpath reuse. The classpath cache disables implicit processor discovery. Use the separate RBE profile for remote execution.
The archive override pins rules_elide at bb7c248. It includes the unified JVM builder, the JavaBuilder processor adapter, the Native Image toolchain and direct invocation of the Python overlay from execution toolchains. The workspace pins the Elide 1.6.3 SDK. Processor consumers use --config=elide-processors. Select --config=elide-unified with an SDK advertising unified JVM request version 1 to enable fused compilation for eligible targets. Python launcher changes
bazelisk run --config=labsjdk //:mx -- --version selects the Oracle Labs JDK 25 JVMCI build required by the pinned Graal compiler. The profile selects the target Java runtime independently of the JDK used to compile Bazel tools. The extension provides checksum-pinned archives for Linux AMD64, Linux ARM64, and macOS ARM64. Consumers can register the same runtime toolchains using the Labs JDK stanza in MODULE.bazel.
Build mx's copyright checker with bazelisk build //tests/native_image:checkcopy. For Linux AMD64 remote execution, run tools/buildbuddy test --config=buildbuddy-rbe --config=native-image-linux //tests/native_image:checkcopy_test. The target uses the ordinary rules_graalvm Native Image rule with the SDK from Elide. Its Java input is the same project JAR used in JVM builds. The root module connects the rulesets with inject_repo(elide, "rules_graalvm") and registers @elide_toolchains//graalvm:all.
Native C/C++ toolchains use the checksum-pinned elide-dev/toolchain LLVM 23 archives also used in Komodo. Linux native actions use the archive's Clang, lld, headers and libc sysroot. To reproduce the Linux build from a Mac, put Bazel's output user root on a case-sensitive volume. For the BuildBuddy wrapper, set BAZEL_OUTPUT_USER_ROOT to a directory on that volume. The Linux worker image is pinned by digest and its build actions request network isolation. Downstream roots can select the same compiler registrations with register_toolchains("@rules_mx//tools/cc:all").
For cacheable native macOS builds across machines, pin an Apple SDK archive in the consuming root module. Set urls and sha256 to your team's archive and digest. Use strip_prefix when the archive wraps the SDK in a directory.
llvm = use_extension("@rules_mx//tools/cc:extensions.bzl", "llvm")
llvm.darwin_sdk(
urls = [APPLE_SDK_ARCHIVE_URL],
sha256 = APPLE_SDK_SHA256,
strip_prefix = "MacOSX26.4.sdk",
)
register_toolchains("@rules_mx//tools/cc:all")The pinned SDK supplies the Darwin system headers, framework stubs and libraries as Bazel action inputs. The default macOS developer configuration selects an installed Xcode or Command Line Tools SDK at repository setup and tracks its files as compiler inputs. The compiler executes against the declared SDK in both modes. Linux comes with its sysroot in the compiler archive.