Skip to content

Add rust-1-linux dependency to all ruby packages for YJIT/ZJIT#63

Open
aramprice wants to merge 1 commit into
mainfrom
add-rust-for-yjit
Open

Add rust-1-linux dependency to all ruby packages for YJIT/ZJIT#63
aramprice wants to merge 1 commit into
mainfrom
add-rust-for-yjit

Conversation

@aramprice

@aramprice aramprice commented Jul 14, 2026

Copy link
Copy Markdown
Member

Summary

  • Vendors rust-1-linux (1.97.0) from bosh-package-rust-release via spec.lock
  • Makes rust-1-linux a compile-time dependency of ruby-3.3, ruby-3.4, and ruby-4.0 so Ruby auto-detects Rust and enables YJIT/ZJIT during ./configure
  • Drops Clang support: uses explicit CC=gcc/CXX=g++ on Linux; the original "Clang is faster" comment was incorrect — the slowdown was a GCC optimization-flag bug
  • Patches common.mk to replace -C lto=thin with -C lto=no before ./configure
  • Adds a bump-rust-1-linux Concourse job that auto-bumps the vendored Rust package when bosh-package-rust-release ships a new release
  • CI tests now verify RubyVM::YJIT is compiled in and can be enabled at runtime

Why sed -i 's/-C lto=thin/-C lto=no/' common.mk?

Ruby's source tarball ships a common.mk that includes YJIT/ZJIT Rust compilation rules. In newer Ruby versions (3.3+) these rules set -C lto=thin (ThinLTO) for the Rust crate that implements the JIT.

The problem with GNU ld + thin LTO: Rust's ThinLTO (-C lto=thin) embeds LLVM bitcode alongside the native code in the resulting object files. While this is transparent within a pure-Rust link (rustc/LLVM handles it internally), some configurations of GNU ld can encounter errors or unexpected behavior when it encounters these LLVM bitcode sections while linking the final Ruby binary. Since we are now explicitly using GCC (and thus GNU ld) — and dropping Clang/lld — the safest path is to disable thin LTO entirely with -C lto=no.

-C lto=no trade-offs: The Rust YJIT/ZJIT objects are slightly larger (no dead-code elimination across translation units within the Rust crate), and Rust compilation is marginally faster. There is no runtime performance impact — LTO is a compile-time optimization only. The Ruby binary still runs YJIT/ZJIT at full speed.

This is consistent with PR #60 which also applied this sed, and is the recommended approach for environments using GCC as the C compiler.

CI changes

  • New bump-rust-1-linux job triggers on changes to .final_builds/packages/rust-1-linux/index.yml in bosh-package-rust-release; it runs bosh vendor-package rust-1-linux (using the shared task from rust-release), tests all three ruby versions in parallel, then finalizes
  • All test job run scripts now assert defined?(RubyVM::YJIT) and RubyVM::YJIT.enabled?

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR vendors the rust-1-linux package and wires it into the Ruby 3.3/3.4/4.0 packages so Ruby auto-detects Rust at build time and compiles in YJIT/ZJIT (with CI assertions to verify YJIT availability and runtime enablement).

Changes:

  • Add rust-1-linux as a compile-time dependency for ruby-3.3, ruby-3.4, and ruby-4.0, and source Rust’s compile environment on Linux while explicitly selecting GCC.
  • Disable Rust ThinLTO in Ruby’s common.mk on Linux to avoid GNU ld + embedded LLVM bitcode issues.
  • Add/extend CI: new Concourse job to auto-bump vendored Rust and new test assertions that YJIT is compiled in and can be enabled.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/compile-3.3.env Removes clang auto-selection from compile env script.
src/compile-3.4.env Removes clang auto-selection from compile env script.
src/compile-4.0.env Removes clang auto-selection from compile env script.
packages/rust-1-linux/spec.lock Adds vendored Rust package lock metadata.
packages/ruby-3.3/spec Adds rust-1-linux dependency.
packages/ruby-3.4/spec Adds rust-1-linux dependency.
packages/ruby-4.0/spec Adds rust-1-linux dependency.
packages/ruby-3.3/packaging Forces GCC on Linux, sources Rust env, disables ThinLTO in common.mk.
packages/ruby-3.4/packaging Forces GCC on Linux, sources Rust env, disables ThinLTO in common.mk.
packages/ruby-4.0/packaging Forces GCC on Linux, sources Rust env, disables ThinLTO in common.mk.
jobs/ruby-3.3-test/templates/run Adds YJIT compile/runtime enablement checks.
jobs/ruby-3.4-test/templates/run Adds YJIT compile/runtime enablement checks.
jobs/ruby-4.0-test/templates/run Adds YJIT compile/runtime enablement checks.
config/blobs.yml Adds Rust toolchain blob entry.
ci/templates/src/compile.env.erb Removes clang auto-selection from template.
ci/templates/packages/ruby/spec.erb Adds rust-1-linux dependency in spec template.
ci/templates/packages/ruby/packaging.erb Mirrors GCC + Rust env + ThinLTO disabling in packaging template.
ci/templates/jobs/ruby-test/templates/run.erb Mirrors YJIT checks in job template.
ci/pipeline.yml Adds bump-rust-1-linux Concourse job and rust-release resource.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread config/blobs.yml
Comment on lines +25 to +27
rust-1-linux/rust-1.97.0-x86_64-unknown-linux-gnu.tar.gz:
size: 384617996
sha: sha256:eb89b20287153391c49ebcdb7fd91b683a12438d129bfb92eadcc495545af3a7

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This will be resolved later / in CI

Comment thread ci/pipeline.yml Outdated
…port

- Vendor rust-1-linux (1.97.0) from bosh-package-rust-release via spec.lock
- Add rust-1-linux as a compile-time dependency of ruby-3.3, ruby-3.4, and ruby-4.0
- Drop Clang support: use explicit GCC/G++ on Linux; Rust is now in PATH during ./configure
  so Ruby auto-detects and enables YJIT (3.3/3.4) and ZJIT (4.0)
- Patch common.mk: replace -C lto=thin with -C lto=no before ./configure because
  GNU ld (used with GCC) cannot link LLVM bitcode objects emitted by thin LTO;
  disabling thin LTO makes Rust emit plain native objects that GCC links cleanly
- Add bump-rust-1-linux CI job: triggered by new bosh-package-rust-release releases,
  runs bosh vendor-package + tests all ruby versions in parallel before finalizing
- Add rust-release git resource to pipeline (watches .final_builds for new releases)
- CI: verify that RubyVM::YJIT is compiled in and can be enabled at runtime in all
  ruby test jobs

ai-assisted=yes
[TNZ-109821] Bosh ruby package compiles with rustc

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 19 changed files in this pull request and generated 8 comments.

Comment thread packages/ruby-3.3/packaging
Comment on lines +22 to +25
source "${BOSH_PACKAGES_DIR:-/var/vcap/packages}/rust-1-linux/bosh/compile.env"

if command -v clang++ &> /dev/null
then
export CXX="$(command -v clang++)"
echo "Rust version:"
rustc --version --verbose
Comment thread packages/ruby-4.0/packaging
Comment thread ci/templates/packages/ruby/packaging.erb
Comment thread jobs/ruby-3.3-test/templates/run
Comment thread jobs/ruby-3.4-test/templates/run
Comment thread jobs/ruby-4.0-test/templates/run
Comment thread ci/templates/jobs/ruby-test/templates/run.erb
@aramprice aramprice requested a review from rkoster July 14, 2026 03:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants