Repository navigation
Use native Bazel commands for live GraalVM development #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+256
−169
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,4 +2,5 @@ | |
|
|
||
| __pycache__/ | ||
|
|
||
| /user.bazelrc | ||
| /.graal-dev/ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,62 @@ | ||
| """Materialize the mx and Gazelle graph for live GraalVM checkouts.""" | ||
|
|
||
| def _live_repository_impl(ctx): | ||
| checkout_parent = ctx.getenv("RULES_MX_CHECKOUTS") or str(ctx.workspace_root.dirname) | ||
| if not checkout_parent.startswith("/"): | ||
| checkout_parent = str(ctx.workspace_root) + "/" + checkout_parent | ||
| python = ctx.which("python3") | ||
| bazel = ctx.which("bazel") or ctx.which("bazelisk") | ||
| if not python or not bazel: | ||
| fail("Live Graal checkout discovery requires python3 and Bazel on PATH") | ||
|
|
||
| helper = ctx.path(ctx.attr._helper) | ||
| for label in ctx.attr._graph_inputs + ctx.attr.patches: | ||
| ctx.watch(label) | ||
| patches = [ctx.path(label) for label in ctx.attr.patches] | ||
| inventory = ctx.execute([python, helper, "scan", checkout_parent] + patches) | ||
| if inventory.return_code: | ||
| fail(inventory.stderr) | ||
| inputs = json.decode(inventory.stdout) | ||
| for file in inputs["watch_files"]: | ||
| ctx.watch(file) | ||
| for directory in inputs["watch_dirs"]: | ||
| ctx.path(directory).readdir() | ||
|
|
||
| # Bazel runs the generator's tool targets in a separate output base so they | ||
| # can resolve and build while the main invocation is fetching @graal. | ||
| repo = ctx.path("") | ||
| tooling = repo.dirname.dirname.get_child("graal-graph") | ||
| ctx.file(".graph-inputs.json", inventory.stdout, executable = False) | ||
| ctx.report_progress("Generating BUILD files from live GraalVM checkouts") | ||
| result = ctx.execute( | ||
| [python, helper, "generate", repo, bazel, tooling] + patches, | ||
| timeout = 1800, | ||
| ) | ||
| if result.return_code: | ||
| fail(result.stderr) | ||
| ctx.delete(".graph-inputs.json") | ||
|
|
||
| graal_live_repository = repository_rule( | ||
| implementation = _live_repository_impl, | ||
| attrs = { | ||
| "patches": attr.label_list(mandatory = True), | ||
| "_helper": attr.label(default = Label("//tools:graal_live_repository.py")), | ||
| "_graph_inputs": attr.label_list(default = [ | ||
| Label("//:MODULE.bazel"), | ||
| Label("//graal:libffi.json"), | ||
| Label("//graal:live_suites.json"), | ||
| Label("//graal:packed_sources.json"), | ||
| Label("//graal:sdk_llvm.json"), | ||
| Label("//graal:sdk_musl.json"), | ||
| Label("//graal:shaded_inputs.json"), | ||
| Label("//graal:suite_imports.json"), | ||
| Label("//graal:svm_inputs.json"), | ||
| Label("//graal:visualvm.json"), | ||
| Label("//mx:export.py"), | ||
| Label("//mx:labsjdk.json"), | ||
| Label("//mx:labsjdk21.json"), | ||
| Label("//mx/gazelle:graph.go"), | ||
| Label("//tools:generate-graal"), | ||
| ]), | ||
| }, | ||
| ) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 Live graph skips two cache inputs
Editing only
_helperor the HSDIS lock leaves the cached live graph valid. Bazel does not watch_helperthroughctx.path(), and the lock is absent from_graph_inputs. The next dev command skips updated discovery or HSDIS compatibility validation.Learn more
The live repository runs a Python helper to discover checkouts, generate BUILD files, and run check_input_pins. That check compares each generated JSON file with its committed counterpart. The generator emits an HSDIS pin, which the compiler's disassembler targets consume through the HSDIS repository rule. Bazel 9.3.3 disables implicit watches on labels passed to
ctx.path(), and neither the helper nor the committed HSDIS lock gets an explicit watch.Example: Fetch the live repository, change just the helper's discovery logic, and run another dev query. Bazel reuses the previous BUILD files, so the query does not exercise the revised helper.
Recommended fix: Explicitly watch
ctx.attr._helperand addLabel("//graal:hsdis.json")to_graph_inputs. This makes a change to either file invalidate an existing fetch.Was this helpful? React with 👍 or 👎 to provide feedback.