Repository navigation
Build the GraalPy JVM standalone from live sources - #66
Conversation
There was a problem hiding this comment.
Devin Review found 3 potential issues.
1 flag not posted on this PR by your GitHub settings — view it in Devin Review. (Configure)
| exec "$root/jvm/bin/java" --enable-native-access=ALL-UNNAMED \\ | ||
| -Dorg.graalvm.launcher.executablename="$0" \\ | ||
| -cp "%s" %s %s --python.PythonHome="$root" "$@" | ||
| """ % (cp, ctx.attr.launcher, " ".join(ctx.attr.args)), |
There was a problem hiding this comment.
🔴 Packaged helper commands reject valid calls
When invoked as graalpy-config or graalpy-polyglot-get, _layout_runtime_impl sends Python startup flags to the helper’s own argument parser. Both commands reject valid invocations before processing the user’s options.
Learn more
The standalone generator passes --experimental-options to the shared wrapper, which also adds --python.PythonHome. In the pinned GraalPythonMain.preprocessArguments, graalpy-config inserts -m graalpy-config before the entire argument list. Everything after that module name becomes an argument to the module, whose option parser rejects the injected flags. The graalpy-polyglot-get branch passes the entire list to the Maven downloader before the interpreter parses any arguments. The downloader also rejects the injected flags.
Example: bin/graalpy-config --includes exits with usage instead of printing include paths. libexec/graalpy-polyglot-get --help rejects --experimental-options instead of displaying help.
Recommended fix: Keep Python startup settings out of helper argument lists. Use launcher-specific dispatch or set the required defaults through JVM properties where supported. Add standalone tests for graalpy-config --includes and graalpy-polyglot-get --help.
Was this helpful? React with 👍 or 👎 to provide feedback.
| """#!/bin/sh | ||
| set -eu | ||
| root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd -P) | ||
| exec "$root/jvm/bin/java" --enable-native-access=ALL-UNNAMED \\ | ||
| -Dorg.graalvm.launcher.executablename="$0" \\ | ||
| -cp "%s" %s %s --python.PythonHome="$root" "$@" |
There was a problem hiding this comment.
🔴 Virtual environment launchers cannot start
When venv runs its symlinked interpreter, _layout_runtime_impl looks for the bundled JVM inside the environment instead of the installation. The wrapper also passes PythonHome explicitly, which prevents GraalPythonMain from loading pyvenv.cfg.
Learn more
The pinned GraalPy venv.EnvBuilder.setup_python creates executable symlinks back to the base interpreter on Unix. Invoking one of those links still gives the shell wrapper the virtual environment’s path in $0. Resolving the parent directory with pwd -P does not follow the executable symlink, so the wrapper tries to start a JVM the environment does not contain. The pinned GraalPythonMain also skips findAndApplyVenvCfg when PythonHome is supplied on the command line. Resolving the symlink alone would therefore leave the virtual environment’s configuration unapplied.
Example: Run bin/graalpy -m venv --without-pip /tmp/myenv from an extracted standalone, then run /tmp/myenv/bin/python -V. The wrapper tries /tmp/myenv/jvm/bin/java instead of the bundled Java executable.
Recommended fix: Resolve executable symlinks when locating the JVM and JARs, but keep the original invocation path for org.graalvm.launcher.executablename. Let GraalPythonMain load pyvenv.cfg for virtual environment launches rather than forcing PythonHome in that case. Test with --without-pip and assert that sys.prefix and sys.base_prefix differ.
Was this helpful? React with 👍 or 👎 to provide feedback.
| exec "$root/jvm/bin/java" --enable-native-access=ALL-UNNAMED \\ | ||
| -Dorg.graalvm.launcher.executablename="$0" \\ | ||
| -cp "%s" %s %s --python.PythonHome="$root" "$@" | ||
| """ % (cp, ctx.attr.launcher, " ".join(ctx.attr.args)), |
There was a problem hiding this comment.
🟡 Standalone silently ignores JVM options
When users pass --vm.* options, _layout_runtime_impl forwards them to the Java application instead of the JVM. Launcher discards them because it expects the wrapper to have applied them already.
Learn more
The GraalVM SDK’s Launcher advertises --vm.* as the way to pass arguments to the host JVM. In the pinned SDK, Launcher.parsePolyglotOption returns immediately for these options, because native and shell launchers are expected to put them in the JVM argument list first. _layout_runtime_impl puts the entire user argument list after GraalPythonMain, so those JVM options have no effect and cause no error.
Example: Running bin/graalpy --vm.Xmx256m script.py starts the program without applying the requested 256 MiB heap limit.
Recommended fix: Reuse the SDK launcher’s JVM-argument handling or translate launcher-side --vm.* options into JVM arguments before the main class. Preserve arguments after -c, -m, or a script name as guest arguments. Add a standalone test that checks a JVM property set with --vm.D.
Was this helpful? React with 👍 or 👎 to provide feedback.
Build the GraalPy JVM standalone from the same live sibling checkout graph used by the development launcher. mx supplies the release naming, launcher names, native extension results, and JDK exclusions. Bazel assembles the install tree and release archive with the pinned JDK.
The upstream GraalPy freezer runs with a source-built bootstrap JVM and emits a resource JAR. The upstream CMake projects build the platform configuration and C API modules through rules_foreign_cc, using the generated Java headers and the existing Truffle libffi distribution.
The existing live checkout check also runs the standalone test. It extracts the archive into a path containing spaces and exercises frozen imports, native libraries, and the upstream zlib test class from the installed launcher.
The archive contains 53 frozen modules and 13 C API extensions on the qualified platforms. The installed tests cover SQLite, SHA3, Expat, a ctypes callback through libffi, native POSIX and zlib, and all seven upstream checksum cases. The macOS build disables ThinLTO for libpython-native to preserve its C API exports.