-
Notifications
You must be signed in to change notification settings - Fork 13
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
Feature: Hermetic GraalVM #35
Conversation
b96469a
to
9e8be03
Compare
relates to #28 Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
- feat: add mapping generator in python - feat: re-organize for split new/legacy mappings - feat: hermetic control of compiler - fix: fewer non-dev dependencies - fix: resolution of native image toolchain - chore: general cleanup and doc - chore: strict flags, hermetic flags Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
- feat: calculate set of Bazel platform tags for artifacts - feat: include platform tags in geneated mappings - feat: generate set of `rules_graalvm` tags and include - fix: output mappings file write bug - chore: general cleanup Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
- feat: register gvm toolchains automatically in workspaces - feat: use gvm toolchain to resolve native image bin - feat: map entire set of gvm sdk files as deps Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
Signed-off-by: Sam Gammon <sam@elide.ventures>
- doc: add notes to component doc about dependencies - doc: add `hermeticity` doc - doc: add `windows` doc Signed-off-by: Sam Gammon <sam@elide.ventures>
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
====================================
Coverage ? 0
====================================
Files ? 0
Lines ? 0
Branches ? 0
====================================
Hits ? 0
Misses ? 0
Partials ? 0 ☔ View full report in Codecov by Sentry. |
Kudos, SonarCloud Quality Gate passed! |
Really exciting! I'll try to upgrade our usage to this today! |
Summary
This changeset applies a few combined feature branches to fix a suite of issues ahead of
1.0.0
. Altogether, thenative-image
build process should soon be fully hermetic.Features:
native-image
toolchainAdditional cleanup/fixes:
--strict
mode flags, performed a flag migrationIntegration tests for hermetic compilernote: coming soonKnown issues:
SDKROOT
andVSINSTALLDIR
included in env (hermeticity violation)Windows builds still fail due to Visual Studio resolution issues within the Bazel sandboxHow it Works
The mapping generator
There is a new Python script at
//tools/scripts/mapping_generator
. This script is equipped to generate a file,internal/graalvm_bindist_map.bzl
, when run from the command line. The script's logic roughly performs the following:Tool awareness:
Script logic:
(platforms, jdks, components, distributions, versions)
, generate artifact/hash URL pairsHEAD
request against each(artifact, hash)
:compatible_with
tagsBut why?
The biggest maintenance burden on these rules is obtaining the artifact hashes for a new GraalVM release, and updating the rules to know about it. With this script, we can at least keep these up to date in a fully repeatable manner. Later we can maybe automate the generation of this file entirely in GitHub Actions, in response to a GraalVM release.
Running the generator
Pass
-h
to the tool to see flags. Example invocation:This command will generate URLs for:
Hermetic compiler / toolchain support
Toolchains are now auto-registered according to the latest setup instructions, and can be registered easily from
MODULE.bazel
when using Bzlmod. The new GraalVM toolchain type (@rules_graalvm//graalvm/toolchain:toolchain_type
) enables Bazel to properly resolve GraalVM tooling without resorting to hard-coded repositories or implicit dependencies.With this step complete, most of the Native Image compilation process can be considered "hermetic," in the sense that inputs are largely controlled by Bazel and accessible to the end-user. There is one place where this remains a challenge, and that is the
env
for compiling native images. Read on for more.Compilation environment
On Linux this is really not a problem, but on macOS and Windows, there is some required environment for building native images:
BAZEL_USE_CPP_ONLY_TOOLCHAIN=1
must be set, ornative-image
, which uses them to resolve toolchains:DEVELOPER_DIR
SDKROOT
native-image
, which uses them to resolve toolchains:VSINSTALLDIR
MSVC
LIB
INCLUDE
In some cases, it may be necessary to make these values available to the action execution environment via
.bazelrc
settings:Generally speaking, Bazel is designed to resolve the Xcode toolchain without the
BAZEL_USE_CPP_ONLY_TOOLCHAIN
env var set, so you may not need to provideaction_env
flags for, say,DEVELOPER_DIR
.Use of
PATH
The
native-image
tool sometimes has issues invoking the wrappers provided by Bazel for native compilers. In particular this is true on Windows, where Bazel provides a Batch file, which may actually be stubbed to unconditionally fail if Bazel cannot locate the Visual Studio toolchain properly.Ultimately this means that configuring Bazel to speak properly to Visual Studio can be quite difficult, when in fact users of these rules may not care how their native binaries are compiled. Bazel doesn't need to invoke Visual Studio directly, but
native-image
does, and it expects to find it on thePATH
.For these reasons, the rules are set (by adjustable default) to unconditionally provide a full
PATH
to thenative-image
tool, and withhold the--native-compiler-path
variable which normally points to Bazel's wrapper. This conveniently skips the wrapper script even if it is stubbed to fail. If you would prefer to use a fully hermetic toolchain, this functionality can be overridden with thenative_image_tool
orpass_compiler_path
attributes for thenative_image
rule (both the legacy and modern rules support the new attributes).