Skip to content

bump(main/ruby): 4.0.3, enable YJIT and ZJIT#29576

Draft
kaan-escober wants to merge 1 commit into
termux:masterfrom
kaan-escober:ruby-4.0.3-yjit-zjit
Draft

bump(main/ruby): 4.0.3, enable YJIT and ZJIT#29576
kaan-escober wants to merge 1 commit into
termux:masterfrom
kaan-escober:ruby-4.0.3-yjit-zjit

Conversation

@kaan-escober
Copy link
Copy Markdown

bump(main/ruby): 4.0.3, enable YJIT and ZJIT

Updates Ruby from 3.4.1 to 4.0.3 and enables the YJIT and ZJIT JIT compilers for aarch64-linux-android.

What changed

build.sh

  • Version bump to 4.0.3 (SHA256 updated).
  • Added --enable-yjit --enable-zjit to configure args.
  • Added termux_setup_rust call to provide a Rust toolchain with aarch64-linux-android std (uses the standard Termux helper, no hand-rolled Cargo setup).
  • Passes JIT_RUST_TARGET=$CARGO_TARGET_NAME through to configure so rustc cross-compiles the JIT crates for the target, not the host.

New patches

Patch Purpose
configure.ac.patch Adds AC_ARG_VAR(JIT_RUST_TARGET) to inject --target into RUSTC, and allows JIT_TARGET_OK=yes for Android when cross-compiling with a Rust target set.
yjit-src-options.rs.patch Replaces hardcoded /tmp/perf-{pid}.map paths with @TERMUX_PREFIX@/tmp/ in YJIT options.

Updated patches (line-number / context updates for 4.0.3, no logic changes):

  • Makefile.in.patch
  • fix-paths.patch
  • libandroid-execinfo.patch
  • process.c.patch
  • yjit-src-codegen.rs.patch
  • yjit-src-yjit.rs.patch

How the cross-compilation works

Upstream Ruby's configure.ac blocks YJIT/ZJIT when cross_compiling=yes or when the target is *android*. The configure.ac.patch adds a JIT_RUST_TARGET variable that, when set:

  1. Rewrites RUSTC to "$RUSTC --target=$JIT_RUST_TARGET" so libyjit.a / libzjit.a / libruby.a are built for aarch64-linux-android instead of the host.
  2. Allows the JIT_TARGET_OK=yes path for Android cross-builds.

The Termux toolchain setup already exports CARGO_TARGET_NAME and CARGO_TARGET_<TARGET>_LINKER, so termux_setup_rust + JIT_RUST_TARGET is all that's needed.

Build verification

Successfully cross-compiled from x86_64 → aarch64 with:

./build-package.sh -a aarch64 -s ruby

Produced ruby_4.0.3_aarch64.deb (10 MB) and ruby-ri_4.0.3_all.deb (1.7 MB).

Notes

  • Upstream Ruby considers Android unsupported for YJIT/ZJIT; this is a Termux-specific enablement.
  • On-device runtime validation of YJIT/ZJIT is a separate follow-up step.

Update Ruby from 3.4.1 to 4.0.3 with YJIT and ZJIT JIT compilers enabled.

Changes to build.sh:
- Bump version to 4.0.3, update SHA256.
- Add --enable-yjit --enable-zjit to configure args.
- Call termux_setup_rust in termux_step_pre_configure to provide a
  Rust toolchain with aarch64-linux-android std.
- Pass JIT_RUST_TARGET=$CARGO_TARGET_NAME so configure.ac can inject
  the correct --target into rustc for cross-compiling the JIT crates.

New patches:
- configure.ac.patch: Add AC_ARG_VAR(JIT_RUST_TARGET) to rewrite RUSTC
  with --target for cross-compilation, and allow JIT_TARGET_OK=yes for
  Android when JIT_RUST_TARGET is set.
- yjit-src-options.rs.patch: Fix hardcoded /tmp paths to
  @TERMUX_PREFIX@/tmp in YJIT perf-map options.

Updated patches (line numbers / context for 4.0.3):
- Makefile.in.patch
- fix-paths.patch
- libandroid-execinfo.patch
- process.c.patch
- yjit-src-codegen.rs.patch
- yjit-src-yjit.rs.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant