During the build, Ruby has special logic to serialize its own builtin
module to disk using the binary iseq format during the build (I assume
for speed so it doesn't have to parse builtin every time it starts
up).
However, since iseq format is architecture-specific, when building on
x86_64 for universal x86_64 + arm64, the serialized builtin module is
written with the x86_64 architecture of the build machine, which fails
this check whenever ruby imports the builtin module on arm64:
1fdaa06660/compile.c (L13243)
Thankfully, there's logic to disable this feature for cross-compiled builds:
1fdaa06660/builtin.c (L6)
This disables the iseq logic for universal builds as well.
Fixes [Bug #18286]
I check the s390s-linux/Ubuntu system and I found that MN threads
doesn't work with:
* function inlining (-O0 doesn't repro)
* Thread local specifier (`_Thread_local`.
With `pthread_get_specific works)
(it is not an issue of `__tls_get_addr()` written in thread.c)
* swap context with ucontext (coroutine/ucontext)
I couldn't find out what is the root cause of this issue but
disable MN threads to make CI healthy.
On some platforms, such as FreeBSD and Oracle Linux, symbols defined
in the crt0 setup routine are exported from shared libraries. So
ignore the symbols that would be exported even in an empty shared
library.
This patch introduce M:N thread scheduler for Ractor system.
In general, M:N thread scheduler employs N native threads (OS threads)
to manage M user-level threads (Ruby threads in this case).
On the Ruby interpreter, 1 native thread is provided for 1 Ractor
and all Ruby threads are managed by the native thread.
From Ruby 1.9, the interpreter uses 1:1 thread scheduler which means
1 Ruby thread has 1 native thread. M:N scheduler change this strategy.
Because of compatibility issue (and stableness issue of the implementation)
main Ractor doesn't use M:N scheduler on default. On the other words,
threads on the main Ractor will be managed with 1:1 thread scheduler.
There are additional settings by environment variables:
`RUBY_MN_THREADS=1` enables M:N thread scheduler on the main ractor.
Note that non-main ractors use the M:N scheduler without this
configuration. With this configuration, single ractor applications
run threads on M:1 thread scheduler (green threads, user-level threads).
`RUBY_MAX_CPU=n` specifies maximum number of native threads for
M:N scheduler (default: 8).
This patch will be reverted soon if non-easy issues are found.
[Bug #19842]
To get rid of mysterious errors such as:
```
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/nm: error: libruby.3.3-static.a(/): The end of the file was unexpectedly encountered
```
and
```
ld: warning: ignoring file ../../libruby.3.3-static.a, building for macOS-x86_64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture x86_64:
"_rb_rational_num", referenced from:
```
Checking by `__STDC_VERSION__` is unreliable because old gcc 4.8
supports `-std=gnu11` option but does not implement `_Thread_local`.
Check the implementation directly instead.
This is useful for passing directory file descriptors over UNIX
sockets or to child processes to avoid TOCTOU vulnerabilities.
The implementation follows the Dir.chdir code.
This will raise NotImplementedError on platforms not supporting
both fchdir and dirfd.
Implements [Feature #19347]
[Misc #16671]
I'd like to bump it to 2.7 to use pattern matching in
tool/mk_builtin_loader.rb.
However, I experienced a few blockers. 2.5 seems like the closest
version that is easy enough to use on CIs, so let me bump the version to
it as an intermediate step for it. I want to use &. and <<~ in 2.3 too.
Known blockers:
* AppVeyor Visual Studio 2015 doesn't have Ruby 2.7. You'd need to bump
the version to Visual Studio 2019.
* GitHub Actions windows-2019 doesn't have Ruby 2.7 either. You
can use ruby/setup-ruby, but configure doesn't seem to work with it.
* For ruby/ruby-ci-imaage, bionic doesn't have Ruby 2.7. I tried using
ruby-build to build Ruby 2.7 from package, but the build on its CI
seems to somehow loop forever when I do that. So I gave it up for now.
We might want to wait until bionic becomes EOL.
Note:
* AppVeyor Visual Studio 2015 has Ruby <= 2.6.3
https://www.appveyor.com/docs/windows-images-software/#ruby
* GitHub Actions windows-2019 uses Ruby 2.5.9
https://github.com/actions/runner-images/blob/main/images/win/Windows2019-Readme.md
libcapstone used to break when it's linked from C and Rust at the same
time, but it doesn't seem to happen anymore. Maybe it's related to
recent symbol hygiene changes. Thank you if that's the case.
This commit allows you to make both --enable-rjit=dev and
--enable-yjit=dev work in the same binary.
We used to require MJIT is supported when YJIT is supported. However,
now that RJIT dropped some platforms that YJIT supports, it no longer
makes sense. We should be able to enable only YJIT, and vice versa.
On macOS, it is not used to localize symbols in dynamic libraries
(libruby.dylib and libyjit.o). Instead, using `objcopy` which does
not support recent mach-O causes linker errors as bellow.
```
linking shared-library libruby.3.3.dylib
error: cannot parse the debug map for 'libruby.3.3.dylib': Invalid data was encountered while parsing the file
linking ruby
ld: malformed mach-o: LC_*_DYLIB load command string extends beyond end of load command file './libruby.3.3.dylib'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```