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] f90549cd38
[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] 1d64a5a7c0
This commit is contained in:
Jun Aruga 2022-12-02 13:23:33 +00:00 committed by Vít Ondruch
commit 3c1be9f9c2

View file

@ -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