From 504ad0ac46cfa6910e45e0201c69a3afabc0a52e Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Fri, 14 Nov 2025 14:10:48 -0500 Subject: [PATCH 1/2] Revert "ruby: disable yjit on cross" This reverts commit 4fce4c99f7b607a034f7b195465f16ab093fbcef. --- pkgs/development/interpreters/ruby/default.nix | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index 33eaaf90ede2..b278f3661670 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -57,13 +57,9 @@ let }: let ver = version; - isCross = stdenv.buildPlatform != stdenv.hostPlatform; # https://github.com/ruby/ruby/blob/v3_2_2/yjit.h#L21 yjitSupported = - !isCross - && ( - stdenv.hostPlatform.isx86_64 || (!stdenv.hostPlatform.isWindows && stdenv.hostPlatform.isAarch64) - ); + stdenv.hostPlatform.isx86_64 || (!stdenv.hostPlatform.isWindows && stdenv.hostPlatform.isAarch64); rubyDrv = lib.makeOverridable ( { stdenv, From c286dcb017296bc2a8f0b536d6ef49a54c67cece Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 30 Dec 2024 22:00:01 -0500 Subject: [PATCH 2/2] ruby: Fix cross-compilation with yjit Otherwise it will produce `yjit.a` with the default target for the `rustc` compiler, which in turn turns out to be the build platform? It could be configured using the `RUST` environment variable, and since it's used without quoting it would expand the arguments added to it. Using `RUST = "rust --target ..."` I think would be undesirable for cross-compiling (and native), since it will save those arguments in `lib/ruby/*/*/rbconfig.rb`. Though that might be fine too. I guess. Note that 3.2 breaks differently. I haven't investigated it, since it's not the default anymore, and will eventually be dropped. Signed-off-by: Samuel Dionne-Riel (cherry picked from commit 75d6216956bfb72a2a1082da7237f74dddf8e123) --- pkgs/development/interpreters/ruby/default.nix | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkgs/development/interpreters/ruby/default.nix b/pkgs/development/interpreters/ruby/default.nix index b278f3661670..f3f1cb84f685 100644 --- a/pkgs/development/interpreters/ruby/default.nix +++ b/pkgs/development/interpreters/ruby/default.nix @@ -177,6 +177,13 @@ let ]; propagatedBuildInputs = op jemallocSupport jemalloc; + env = lib.optionalAttrs (stdenv.hostPlatform != stdenv.buildPlatform && yjitSupport) { + # The ruby build system will use a bare `rust` command by default for its rust. + # We can use the Nixpkgs rust wrapper to work around the fact that our Rust builds + # for cross-compilation output for the build target by default. + NIX_RUSTFLAGS = "--target ${stdenv.hostPlatform.rust.rustcTargetSpec}"; + }; + enableParallelBuilding = true; # /build/ruby-2.7.7/lib/fileutils.rb:882:in `chmod': # No such file or directory @ apply2files - ...-ruby-2.7.7-devdoc/share/ri/2.7.0/system/ARGF/inspect-i.ri (Errno::ENOENT)