Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions MODULE.bazel.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions graal/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,13 @@ load("@rules_python//python:py_test.bzl", "py_test")
load("//mx:bitcode.bzl", "mx_bitcode_suite")
load("//mx:netbeans.bzl", "netbeans_test_java")
load(":automatic_module.bzl", "automatic_module")
load(":developer_targets.bzl", "graal_workspace_targets")
load(":layout.bzl", "mx_archive_layout")
load(":pom_classpath_test.bzl", "pom_classpath_test")
load(":sdk_llvm.bzl", "sdk_llvm_link", "sulong_fixture_sdk")

graal_workspace_targets()

exports_files([
"netbeans_maven.json",
"benchmark_timer.patch",
Expand All @@ -32,6 +35,7 @@ exports_files([
"sdk_llvm.json",
"sdk_musl.json",
"packed_sources.json",
"sulong_stock_javac.patch",
"sulong_external_tests.patch",
"sulong_setjmp.patch",
"sl.py.tpl",
Expand Down
31 changes: 18 additions & 13 deletions graal/README.md
Original file line number Diff line number Diff line change
@@ -1,37 +1,42 @@
# Building GraalVM

Bazel fetches a checksum-pinned Graal source archive, by default the Elide fork, and applies the BUILD files generated by mx and Gazelle. Builds and tests use declared sources and toolchains. A local Graal checkout is optional. The suites share one external repository so cross-suite edges use ordinary Bazel labels. [Pinned source tree](https://github.com/elide-dev/graal/tree/21dea4deb60d8aa9b07cbd3cc77b1581b61b6fb2) (`elide-dev/graal` `elide-25.6.x`, based on `oracle/graal@7b7825ae92c`)
Bazel uses the Graal source pin by default. With `--config=dev`, it generates the BUILD graph from your sibling checkouts with mx and Gazelle. The shared suites have the same public labels in both modes. [Pinned source tree](https://github.com/elide-dev/graal/tree/21dea4deb60d8aa9b07cbd3cc77b1581b61b6fb2)

## Daily build and test

```sh
bazelisk test --config=elide-processors //graal/... @graal//sdk/... @graal//truffle/... @graal//compiler/...
bazelisk query 'tests(//graal:sdk_tests)'
bazelisk test @graal//sdk:org.graalvm.word.test.org.graalvm.word.test.WordTests
bazelisk query 'somepath(@graal//truffle:com.oracle.truffle.api.library, @graal//sdk:POLYGLOT)'
tools/buildbuddy test --config=buildbuddy-rbe --config=elide-processors //graal/... @graal//sdk/... @graal//truffle/... @graal//compiler/...
bazel build //graal/...
bazel test //graal/...
bazel test //graal/truffle:test
bazel query 'tests(//graal:test)'
```

`//graal:build` groups the SDK, Truffle, compiler, Wasm and Sulong build products. `//graal:test` groups their daily tests, including the SDK, Truffle and Native Bridge integration tests. Both groups pick up GraalJS and GraalPy when their live checkouts are present. Each component has `:build` and `:test`, and components with a launcher expose `:run`. Use `bazel query //graal/truffle:all` to list a component's entry points. The generated `@graal` labels let you select individual projects, distributions and test cases.

Request packaging or Native Image jobs explicitly. The `:release` target builds the JVM archive where one is available, and `:release_test` checks the unpacked release. Wasm and Sulong expose `:native_release` for their native archives. Use `--config=source-native-image` when building those archives or testing the combined Sulong release suite. Espresso's JVM installation is `//graal/espresso:install`.

## Work on sibling checkouts

Keep `rules_mx`, `graal`, and any `graaljs` and `graalpython` checkouts beside each other. Run Bazel from `rules_mx` with `--config=dev`. Bazel locates the sibling checkouts and selects the Elide processor toolchain and Labs JDK 25. Add `common --config=dev` to your local `user.bazelrc` to use the checkouts with plain `bazel` commands.

```sh
bazel run --config=dev @graal//graal-js:js -- -e 'print(6 * 7)'
bazel test --config=dev @graal//graal-js:regression/direct_eval
bazel test --config=dev @graal//graalpython:zlib/ChecksumTestCase.test_crc32start
bazel build --config=dev @graal//graalpython:GRAALPY_JVM_STANDALONE_RELEASE_ARCHIVE
bazel run --config=dev //graal/graaljs:run -- -e 'print(6 * 7)'
bazel test --config=dev //graal/graalpy:test
bazel build --config=dev //graal/graalpy:release
bazel test --config=dev //graal/graalpy:release_test
```

Use a reverse-dependency query to select tests from the packages and targets you want to check. This example finds GraalJS regressions and the Truffle SimpleLanguage Fibonacci test affected by an edit to the Truffle API.
Use a reverse-dependency query to find which daily tests depend on the Truffle API, including tests in GraalJS and GraalPy.

```sh
bazel query --config=dev 'kind(".*_test rule", rdeps(@graal//graal-js:all + @graal//truffle:sl.test.Fibonacci, @graal//truffle:com.oracle.truffle.api))'
bazel query --config=dev 'kind(".*_test rule", rdeps(tests(//graal:test), @graal//truffle:com.oracle.truffle.api))'
```

Bazel generates BUILD files from mx and Gazelle on first use. Edits to existing source files flow directly into compilation and tests. File additions, removals, renames, and changes to mx suite metadata refresh the graph. After editing Java imports that change Gazelle’s dependency analysis, refresh it with `bazel fetch --config=dev --force --repo=@graal`. The checkouts need to match the Bazel input pins in `rules_mx`. CI qualifies Graal at `21dea4d`, GraalJS at `747d45b`, and GraalPy at `11344f3`.

The live GraalPy launcher uses Labs JDK 25 and bundles the standard library, GraalPy core library, headers, platform versions, and source-built zlib. The first two upstream zlib checks are individually selectable.

The GraalPy JVM standalone tarball bundles the pinned JDK, package-relative launchers, frozen bytecode from the upstream freezer, native POSIX and zlib support, and the C API extensions built with the upstream CMake project. The installed launcher uses the bundled runtime in the `jvm/` and `modules/` directories. `@graal//graalpython:jvm_standalone_test` extracts the archive into a path containing spaces and tests frozen imports, native modules, and upstream zlib checks.
The GraalPy JVM standalone tarball bundles the pinned JDK, package-relative launchers, frozen bytecode from the upstream freezer, native POSIX and zlib support, and the C API extensions built with the upstream CMake project. `//graal/graalpy:release_test` extracts the archive into a path containing spaces and tests frozen imports, native modules, and upstream zlib checks.

The JVM archive uses a classpath launcher and compiles from the checked-in PEG parser. Native Image and GraalOS standalones, native bzip2 and LZMA, and the virtualenv seeder remain separate work.

Expand Down
7 changes: 7 additions & 0 deletions graal/compiler/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
build = ["@graal//compiler:GRAAL"],
run = "@graal//compiler:sl_jit",
tests = ["@graal//compiler:GR36613Test"],
)
36 changes: 36 additions & 0 deletions graal/developer_targets.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
"""Declare the public entry points for a GraalVM component."""

load("@graal//:live_suites.bzl", "LIVE_SUITES")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Downstream Graal dependency queries fail

When a consuming workspace queries SimpleLanguage dependencies, LIVE_SUITES blocks Bazel from loading the launcher template. The workspace’s use_repo does not restore the dev-only repository mapping inside rules_mx.

Learn more

The Graal source extension can be imported by a consuming root module using the setup under Select the Graal source. That import adds the @graal name to the consuming root, not to the rules_mx module, whose own Graal extension usage is dev-only. The generated SimpleLanguage launcher uses an existing template from the shared Graal package. Loading that package now also loads the workspace target macro, so the missing repository mapping prevents Bazel from resolving the template even though it does not use live-suite metadata.

Example: In a consuming root that imports Graal as @graal, bazel query 'deps(@graal//truffle:sl, 2)' reaches the launcher template and fails when its package tries to load the dev-only repository.

Recommended fix: Keep the shared Graal package loadable without the dev-only repository mapping. Put the workspace aggregate and its metadata load in a dedicated package, or provide an always-available metadata repository with an empty downstream default. Add a consuming-root query that reaches the launcher template.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.


_PUBLIC = ["//visibility:public"]
_COMPONENTS = ["compiler", "sdk", "sulong", "truffle", "wasm"]
_LIVE_COMPONENTS = {"graal-js": "graaljs", "graalpython": "graalpy"}

def graal_component(build, tests, run = None, artifacts = {}, packaging_tests = {}, live_suite = None, manual = False):
"""Expose a component's daily targets and explicitly selected packages."""
if live_suite and live_suite not in LIVE_SUITES:
return

tags = ["manual"] if manual else []
native.filegroup(name = "build", srcs = build, tags = tags, visibility = _PUBLIC)
native.test_suite(name = "test", tests = tests, tags = tags, visibility = _PUBLIC)
if run:
native.alias(name = "run", actual = run, tags = tags, visibility = _PUBLIC)
for name, target in artifacts.items():
native.alias(name = name, actual = target, tags = ["manual"], visibility = _PUBLIC)
for name, targets in packaging_tests.items():
native.test_suite(name = name, tests = targets, tags = ["manual"], visibility = _PUBLIC)

def graal_workspace_targets():
"""Collect the daily build products and tests in the shared workspace."""
components = _COMPONENTS + [name for suite, name in _LIVE_COMPONENTS.items() if suite in LIVE_SUITES]
native.filegroup(
name = "build",
srcs = ["//graal/" + name + ":build" for name in components],
visibility = _PUBLIC,
)
native.test_suite(
name = "test",
tests = ["//graal/" + name + ":test" for name in components],
visibility = _PUBLIC,
)
15 changes: 15 additions & 0 deletions graal/espresso/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
artifacts = {
"install": "@graal//espresso:ESPRESSO_JVM_STANDALONE",
"native_install": "@graal//espresso:ESPRESSO_NATIVE_STANDALONE",
},
build = ["@graal//espresso:ESPRESSO"],
manual = True,
packaging_tests = {
"install_test": ["//graal:espresso_standalone_test"],
"native_install_test": ["//graal:espresso_native_standalone_test"],
},
tests = ["//graal:espresso_guest_test"],
)
5 changes: 4 additions & 1 deletion graal/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ OVERLAYS = [
Label("//graal:vm.patch"),
Label("//graal:regex.patch"),
Label("//graal:tools.patch"),
Label("//graal:sulong_stock_javac.patch"),
Label("//graal:sulong_external_tests.patch"),
Label("//graal:sulong_setjmp.patch"),
Label("//graal:sulong.patch"),
Expand Down Expand Up @@ -84,7 +85,9 @@ def _graal_impl(ctx):
build_file_content = """exports_files(["mx-source.json"])""" if source.provenance else """load("@bazel_skylib//rules:write_file.bzl", "write_file")
write_file(name = "mx-source.json", out = "source-info.json", content = ["{}"], visibility = ["//visibility:public"])
""",
files = {"mx-source.json": source.provenance} if source.provenance else {},
files = {"live_suites.bzl": Label("//graal:no_live_suites.bzl")} | (
{"mx-source.json": source.provenance} if source.provenance else {}
),
patch_strip = 1,
patches = source.patches,
sha256 = source.sha256,
Expand Down
11 changes: 11 additions & 0 deletions graal/graaljs/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
build = ["@graal//graal-js:js"],
live_suite = "graal-js",
run = "@graal//graal-js:js",
tests = [
"@graal//graal-js:regression/direct_eval",
"@graal//graal-js:regression/indirect_eval",
],
)
13 changes: 13 additions & 0 deletions graal/graalpy/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
artifacts = {"release": "@graal//graalpython:GRAALPY_JVM_STANDALONE_RELEASE_ARCHIVE"},
build = ["@graal//graalpython:python"],
live_suite = "graalpython",
packaging_tests = {"release_test": ["@graal//graalpython:jvm_standalone_test"]},
run = "@graal//graalpython:python",
tests = [
"@graal//graalpython:zlib/ChecksumTestCase.test_adler32start",
"@graal//graalpython:zlib/ChecksumTestCase.test_crc32start",
],
)
8 changes: 8 additions & 0 deletions graal/native-image/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
build = ["@graal//substratevm:native-image"],
manual = True,
run = "@graal//substratevm:native-image",
tests = ["//graal:source_native_image_test"],
)
3 changes: 3 additions & 0 deletions graal/no_live_suites.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
"""The pinned Graal source archive contains no sibling checkouts."""

LIVE_SUITES = []
12 changes: 12 additions & 0 deletions graal/sdk/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
build = ["@graal//sdk:GRAAL_SDK"],
tests = [
"//graal:launcher_modules_test",
"//graal:sdk_classpath_test",
"//graal:sdk_tests",
"//graal/nativebridge:launcher_test",
"//graal/nativebridge:module_test",
],
)
14 changes: 14 additions & 0 deletions graal/sulong/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
artifacts = {
"release": "@graal//sulong:SULONG_JVM_STANDALONE_RELEASE_ARCHIVE",
"native_release": "@graal//sulong:SULONG_NATIVE_STANDALONE_RELEASE_ARCHIVE",
},
build = ["@graal//sulong:SULONG_CORE"],
packaging_tests = {"release_test": ["//graal:sulong_standalone_install_test"]},
tests = [
"//graal:sulong_language_test",
"//graal:sulong_pipe_test",
],
)
28 changes: 28 additions & 0 deletions graal/sulong_stock_javac.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
diff --git a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/CXXDemangler.java b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/CXXDemangler.java
--- a/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/CXXDemangler.java
+++ b/sulong/projects/com.oracle.truffle.llvm/src/com/oracle/truffle/llvm/CXXDemangler.java
@@ -140,5 +140,5 @@
int libIdx = i + 1;
if (libIdx >= numNamespaces) {
- throw new LLVMLinkerException(String.format("No library name to decode: ", String.join("::", namespaces)));
+ throw new LLVMLinkerException("No library name to decode: " + String.join("::", namespaces));
}
String rawLibname = namespaces.get(libIdx);
@@ -161,5 +161,5 @@
for (int i = 0; i < result.length; i++) {
char ch = charSequence.charAt(i);
- assert ch >= 0 && ch <= Byte.MAX_VALUE;
+ assert ch <= Byte.MAX_VALUE;
result[i] = (byte) ch;
}
diff --git a/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/memory/LLVMNativeMemory.java b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/memory/LLVMNativeMemory.java
--- a/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/memory/LLVMNativeMemory.java
+++ b/sulong/projects/com.oracle.truffle.llvm.nativemode/src/com/oracle/truffle/llvm/nativemode/runtime/memory/LLVMNativeMemory.java
@@ -59,5 +59,5 @@
static {
assert (DEREF_HANDLE_SPACE_START & HANDLE_HEADER_MASK) != (DEREF_HANDLE_SPACE_END & HANDLE_HEADER_MASK);
assert (HANDLE_SPACE_START & HANDLE_HEADER_MASK) != (HANDLE_SPACE_END & HANDLE_HEADER_MASK);
- assert (DEREF_HANDLE_SPACE_START & HANDLE_HEADER_MASK) != 0;
- assert (HANDLE_SPACE_START & HANDLE_HEADER_MASK) != 0;
+ assert (DEREF_HANDLE_SPACE_START & HANDLE_HEADER_MASK) != 0L;
+ assert (HANDLE_SPACE_START & HANDLE_HEADER_MASK) != 0L;
20 changes: 20 additions & 0 deletions graal/truffle/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
build = [
"@graal//truffle:TRUFFLE_API",
"@graal//truffle:TRUFFLE_RUNTIME",
"@graal//truffle:sl",
],
run = "@graal//truffle:sl",
tests = [
"//graal:panama_module_test",
"//graal:truffle_archive_test",
"//graal:truffle_distributions_test",
"//graal:truffle_layout_test",
"//graal:truffle_polyglot_test",
"//graal:truffle_processor_test",
"//graal:truffle_runtime_modules_test",
"@graal//truffle:sl.test.Fibonacci",
],
)
14 changes: 14 additions & 0 deletions graal/wasm/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("//graal:developer_targets.bzl", "graal_component")

graal_component(
artifacts = {
"release": "@graal//wasm:GRAALWASM_JVM_STANDALONE_RELEASE_ARCHIVE",
"native_release": "@graal//wasm:GRAALWASM_NATIVE_STANDALONE_RELEASE_ARCHIVE",
},
build = ["@graal//wasm:WASM"],
packaging_tests = {
"release_test": ["//graal:wasm_jvm_release_test"],
"native_release_test": ["//graal:wasm_native_release_test"],
},
tests = ["@graal//wasm:org.graalvm.wasm.test.org.graalvm.wasm.test.WasmIndirectCallTest"],
)
1 change: 1 addition & 0 deletions mx/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@rules_python//python:py_test.bzl", "py_test")
exports_files([
"export.py",
"jdk_release.patch",
"junit_duration.patch",
"launcher.py.tpl",
"module_descriptor.patch",
"register.patch",
Expand Down
9 changes: 8 additions & 1 deletion mx/extensions.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ def _sources(_ctx):
strip_prefix = "mx-" + revision,
build_file = Label("//mx:upstream.BUILD"),
files = {"mx.mx/mx_bazel_export.py": Label("//mx:export.py")},
patches = [Label("//mx:register.patch"), Label("//mx:module_descriptor.patch"), Label("//mx:symbolic_classpath.patch"), Label("//mx:declaration_name.patch"), Label("//mx:dynamic_java_project.patch")],
patches = [
Label("//mx:register.patch"),
Label("//mx:module_descriptor.patch"),
Label("//mx:symbolic_classpath.patch"),
Label("//mx:declaration_name.patch"),
Label("//mx:dynamic_java_project.patch"),
Label("//mx:junit_duration.patch"),
],
patch_args = ["-p1"],
)

Expand Down
8 changes: 8 additions & 0 deletions mx/junit_duration.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
diff --git a/java/com.oracle.mxtool.junit/src/com/oracle/mxtool/junit/MxJUnitWrapper.java b/java/com.oracle.mxtool.junit/src/com/oracle/mxtool/junit/MxJUnitWrapper.java
--- a/java/com.oracle.mxtool.junit/src/com/oracle/mxtool/junit/MxJUnitWrapper.java
+++ b/java/com.oracle.mxtool.junit/src/com/oracle/mxtool/junit/MxJUnitWrapper.java
@@ -492,3 +492,3 @@
Object[] current = timings.getCurrentTestDuration();
if (current != null && !ctrlCPressed) {
- System.out.printf("Test %s not finished after %d ms%n", current[0], current[1]);
+ System.out.printf("Test %s not finished after %d ms%n", current[0], (Long) current[1]);
14 changes: 11 additions & 3 deletions tools/check-graal-dev
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ marker = getattr(Truffle, "rulesMxLiveMarker", None)
print(marker() if marker else "before")
"""
LAUNCHERS = {
"@graal//graal-js:js": ("-e", JS_MARKER),
"@graal//graalpython:python": ("-c", PY_MARKER),
"//graal/graaljs:run": ("-e", JS_MARKER),
"//graal/graalpy:run": ("-c", PY_MARKER),
}


Expand Down Expand Up @@ -95,6 +95,14 @@ def main(config):
raise SystemExit(
f"Unexpected test selection for the Truffle source edit {affected!r}"
)
daily = invoke(
"query",
"tests(//graal/graaljs:test + //graal/graalpy:test)",
stdout=subprocess.PIPE,
text=True,
).stdout.splitlines()
if set(daily) != REGRESSIONS - {FIBONACCI}:
raise SystemExit(f"Unexpected public language test targets {daily!r}")
location = invoke(
"query",
"--output=location",
Expand Down Expand Up @@ -164,7 +172,7 @@ def main(config):
"The Truffle edit reached GraalJS and GraalPy, and all selected tests were cached on repeat."
)
invoke(
"test", "--test_output=errors", "@graal//graalpython:jvm_standalone_test"
"test", "--test_output=errors", "//graal/graalpy:release_test"
)


Expand Down
1 change: 1 addition & 0 deletions tools/generate-graal
Original file line number Diff line number Diff line change
Expand Up @@ -2584,6 +2584,7 @@ def prepare_suite(suite, stage, peers=()):
'srcs = ["@rules_mx//graal:graalpy_standalone_test.py"], main = "graalpy_standalone_test.py", '
'args = ["$(rootpath :GRAALPY_JVM_STANDALONE_RELEASE_ARCHIVE)", "$(rootpath graalpython/lib-python/3/test/test_zlib.py)"], '
'data = [":GRAALPY_JVM_STANDALONE_RELEASE_ARCHIVE", "graalpython/lib-python/3/test/test_zlib.py"], '
'tags = ["manual"], '
'visibility = ["//visibility:public"])\n'
+ "".join(
f'py_test(name = "zlib/{case}", size = "small", '
Expand Down
Loading
Loading