From: "ufuk (Ufuk Kayserilioglu)" Date: 2022-11-10T19:01:11+00:00 Subject: [ruby-core:110699] [Ruby master Misc#19120] How does YJIT work in --enable-shared case? Issue #19120 has been updated by ufuk (Ufuk Kayserilioglu). jaruga (Jun Aruga) wrote in #note-3: > ... the commands worked without the `rust` command. Could you tell me why it worked? I can answer this part of the question. > ``` > sh-5.2$ which rustc > which: no rustc in (/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin) > > sh-5.2$ ~/local/ruby-yjit-199b59f065/bin/ruby --yjit --yjit-call-threshold=1 -e '100.times { |n| puts "Hello #{n}" }' > ... > Hello 98 > Hello 99 > ``` YJIT does NOT generate Rust code at runtime to perform its JIT compilation. YJIT is, itself, a Rust code-base that generates the correct assembly code for optimized methods at runtime. So `rustc` is only needed to compile the YJIT code itself, once you've compiled Ruby with YJIT, there is no dependency on `rustc` at runtime anymore. ---------------------------------------- Misc #19120: How does YJIT work in --enable-shared case? https://bugs.ruby-lang.org/issues/19120#change-100041 * Author: jaruga (Jun Aruga) * Status: Open * Priority: Normal ---------------------------------------- We are trying to add the new YJIT feature that is ported to Rust[1][2] in Ruby 3.2 RPM on Fedora project.[3] I am trying to understand how the YJIT works in the case the `./configure --enable-yjit --enable-shared`. In the case below, when building Ruby on the latest master branch `199b59f065ce6f1c13b8424f35a70c513523211b`, the static libraries `libruby-static.a` and `./libruby-static.a` were built. ``` sh-5.2$ cat /etc/fedora-release Fedora release 38 (Rawhide) sh-5.2$ ./autogen.sh sh-5.2$ ./configure --prefix=$HOME/local/ruby-yjit-199b59f065 --enable-shared --enable-yjit 2>&1 | tee configure.log ... * MJIT support: yes * YJIT support: yes sh-5.2$ make sh-5.2$ find . -name "*.a" ./yjit/target/release/libyjit.a ./libruby-static.a ``` After running `make install`, these static libraries (`*.a` files) were not copied to the installed directory. That makes sense, as Ruby works with shared libraries (`*.so` files). ``` sh-5.2$ make install 2>&1 | tee make_install.log sh-5.2$ find ~/local/ruby-yjit-199b59f065/ -name "*.a" => empty ``` In this case, we really don't need the `libyjit.a` to run the YJIT right? I couldn't find the .so file something like `yjit.so`. Which .so file contains the YJIT feature (maybe the content of the `yjit/src/**/*.rs`)? ``` sh-5.2$ find ~/local/ruby-yjit-199b59f065/ -name "*.so" | grep yjit.so => empty ``` How can we test the content of the `yjit/src/**/*.rs`? For example, if the command below works, I can say that I tested the content of the `yjit/src/**/*.rs`? ``` sh-5.2$ which rustc /usr/bin/rustc sh-5.2$ rustc --version rustc 1.65.0 (Fedora 1.65.0-1.fc38) sh-5.2$ ~/local/ruby-yjit-199b59f065/bin/ruby --yjit -e 'puts "abc"' abc ``` ## References * [1] https://bugs.ruby-lang.org/issues/18481 * [2] https://github.com/ruby/ruby/commit/f90549cd38518231a6a74432fe1168c943a7cc18#diff-1d53751ddf3ffeb25cfe609c6bd28746651e23ea81d51fe582b0f635f0896e0d * [3] https://src.fedoraproject.org/rpms/ruby/pull-request/139 -- https://bugs.ruby-lang.org/ Unsubscribe: