From c286dcb017296bc2a8f0b536d6ef49a54c67cece Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Mon, 30 Dec 2024 22:00:01 -0500 Subject: [PATCH] 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)