Skip to content

Commit

Permalink
ruby_3_2: build with YJIT support by default
Browse files Browse the repository at this point in the history
  • Loading branch information
marsam committed Feb 24, 2023
1 parent 0ce320c commit 188e51d
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions pkgs/development/interpreters/ruby/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
, fetchurl, fetchpatch, fetchFromSavannah, fetchFromGitHub
, zlib, gdbm, ncurses, readline, groff, libyaml, libffi, jemalloc, autoreconfHook, bison
, autoconf, libiconv, libobjc, libunwind, Foundation
, buildEnv, bundler, bundix
, buildEnv, bundler, bundix, rustPlatform
, makeBinaryWrapper, buildRubyGem, defaultGemConfig, removeReferencesTo
, openssl, openssl_1_1
, linuxPackages, libsystemtap
Expand All @@ -18,9 +18,10 @@ let
# Contains the ruby version heuristics
rubyVersion = import ./ruby-version.nix { inherit lib; };

generic = { version, sha256 }: let
generic = { version, sha256, cargoSha256 ? null }: let
ver = version;
atLeast30 = lib.versionAtLeast ver.majMin "3.0";
atLeast32 = lib.versionAtLeast ver.majMin "3.2";
self = lib.makeOverridable (
{ stdenv, buildPackages, lib
, fetchurl, fetchpatch, fetchFromSavannah, fetchFromGitHub
Expand All @@ -43,7 +44,8 @@ let
# Or (usually):
# $(nix-build -A ruby)/lib/ruby/2.6.0/x86_64-linux/rbconfig.rb
# - In $out/lib/libruby.so and/or $out/lib/libruby.dylib
, removeReferencesTo, jitSupport ? false
, removeReferencesTo, jitSupport ? yjitSupport
, rustPlatform, yjitSupport ? atLeast32
, autoreconfHook, bison, autoconf
, buildEnv, bundler, bundix
, libiconv, libobjc, libunwind, Foundation
Expand Down Expand Up @@ -73,6 +75,7 @@ let
nativeBuildInputs = [ autoreconfHook bison ]
++ (op docSupport groff)
++ (ops (dtraceSupport && stdenv.isLinux) [ systemtap libsystemtap ])
++ ops yjitSupport [ rustPlatform.cargoSetupHook rustPlatform.rust.cargo rustPlatform.rust.rustc ]
++ op useBaseRuby baseRuby;
buildInputs = [ autoconf ]
++ (op fiddleSupport libffi)
Expand Down Expand Up @@ -117,6 +120,14 @@ let
})
];

cargoRoot = opString yjitSupport "yjit";

cargoDeps = if yjitSupport then rustPlatform.fetchCargoTarball {
inherit src;
sourceRoot = "${pname}-${version}/${cargoRoot}";
sha256 = cargoSha256;
} else null;

postUnpack = opString rubygemsSupport ''
rm -rf $sourceRoot/{lib,test}/rubygems*
cp -r ${rubygems}/lib/rubygems* $sourceRoot/lib
Expand All @@ -140,6 +151,7 @@ let
(lib.withFeatureAs useBaseRuby "baseruby" "${baseRuby}/bin/ruby")
(lib.enableFeature dtraceSupport "dtrace")
(lib.enableFeature jitSupport "jit-support")
(lib.enableFeature yjitSupport "yjit")
(lib.enableFeature docSupport "install-doc")
(lib.withFeature jemallocSupport "jemalloc")
(lib.withFeatureAs docSupport "ridir" "${placeholder "devdoc"}/share/ri")
Expand Down Expand Up @@ -303,5 +315,6 @@ in {
ruby_3_2 = generic {
version = rubyVersion "3" "2" "1" "";
sha256 = "sha256-E9Z5AWYO4yF9vZ3VYFk0a9QhLOZKacMG71LfZJNfjb0=";
cargoSha256 = "sha256-6du7RJo0DH+eYMOoh3L31F3aqfR5+iG1iKauSV1uNcQ=";
};
}

0 comments on commit 188e51d

Please sign in to comment.