From 3c1be9f9c2c1d8679eebb9a185fefa15baa1bcfc Mon Sep 17 00:00:00 2001 From: Jun Aruga Date: Fri, 2 Dec 2022 13:23:33 +0000 Subject: [PATCH] Enable YJIT support in Ruby 3.2.0. YJIT was introduced as a new feature in Ruby 3.1.0.[1] However, since the commit[2], the YJIT feature support was disabled as a default[3], and we need to set the `--enable-yjit` to the `configure` script to enable the YJIT support, and as the YJIT source code was ported from C to the Rust source, the `rustc` is required to build it. Note that the `rustc` is not used in the runtime process of the YJIT, because the YJIT does not generate the Rust code.[4] The static library `libyjit.a` built from the ``yjit/src/**/*.rs is linked in the build process to create the `libruby.so.3.2.0`, `miniruby` and `ruby` binary files.[4] In the Ruby 3.2.0, YJIT supports only the x86_64 and the aarch64 CPU environments.[1][5] The YJIT test files are executed in the `make check` if the YJIT is supported by `--enable-yjit`. That is equivalent with that the `test/lib/jit_support.rb#yjit_supported?` is `true`.[6] ``` test/ruby/test_yjit_exit_locations.rb test/ruby/test_yjit.rb ``` Note the Ruby's behavior is the same if the the `ruby`'s command `--yjit` or `--yjit-*` options are not specified. [1] https://www.ruby-lang.org/en/news/2021/12/25/ruby-3-1-0-released/ [2] https://github.com/ruby/ruby/commit/f90549cd38518231a6a74432fe1168c943a7cc18 [3] https://src.fedoraproject.org/rpms/ruby/pull-request/139 [4] https://bugs.ruby-lang.org/issues/19120 [5] https://www.ruby-lang.org/en/news/2022/09/09/ruby-3-2-0-preview2-released/ [6] https://github.com/ruby/ruby/commit/1d64a5a7c09d1029508b6b3cb3d04e5a939bc8f8 --- ruby.spec | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/ruby.spec b/ruby.spec index 447524f..0c519e3 100644 --- a/ruby.spec +++ b/ruby.spec @@ -82,6 +82,11 @@ %bcond_without gmp %bcond_without hostname %bcond_without systemtap +# YJIT is supported on x86_64 and aarch64. +# https://github.com/ruby/ruby/blob/master/doc/yjit/yjit.md +%ifarch x86_64 aarch64 +%bcond_without yjit +%endif # Enable test when building on local. %bcond_with bundler_tests @@ -183,6 +188,7 @@ BuildRequires: multilib-rpm-config BuildRequires: gcc BuildRequires: make BuildRequires: zlib-devel +%{?with_yjit:BuildRequires: %{_bindir}/rustc} # The bundler/spec/runtime/setup_spec.rb requires the command `man`. %{?with_bundler_tests:BuildRequires: %{_bindir}/man} @@ -655,6 +661,7 @@ pushd %{_vpath_builddir} --enable-shared \ --with-ruby-version='' \ --enable-multiarch \ + %{?with_yjit: --enable-yjit} \ popd