Commit graph

546 commits

Author SHA1 Message Date
Nobuyoshi Nakada
1cba1b3992
Check windres message using the found windres only if needed 2023-11-24 20:00:13 +09:00
Pierrick Bouvier
784fdecc4c
windows-arm64 support (#8995)
* [win32] fix compilation for windows-arm64

Credits to MSYS2 Ruby package using this patch.

* [win32] nm use full options

Fix compilation error when using MSYS2 environment.
Credits to MSYS2 Ruby package using this patch.

* [win32] detect llvm-windres (used for windows-arm64)

When adding preprocessor option for llvm-windres (using clang as
parameter), it fails. Thus, do not add this.

It's needed to be able to compile windows-arm64 version, because MSYS2
toolchain is LLVM based (instead of GCC/binutils).

* [win32] pioinfo detection for windows-arm64

This fixes "unexpected ucrtbase.dll" for native windows-arm64 ruby
binary. It does not solve issue with x64 version emulated on this
platform.

Value of pioinfo pointer can be found in ucrtbase.dll at latest adrp/add
sequence before return of _isatty function. This works for both release
and debug ucrt.

Due to the nature of aarch64 ISA (vs x86 or x64), it's needed to
disassemble instructions to retrieve offset value, which is a bit more
complicated than matching specific string patterns.

Details about adrp/add usage can be found in this blog post:
https://devblogs.microsoft.com/oldnewthing/20220809-00/?p=106955
For instruction decoding, the Arm documentation was used as a reference.
2023-11-23 17:17:28 +09:00
Hiroshi SHIBATA
f100c6477a
[Bug #20004] Revert "[Feature #19422] Enable shared by default on macOS"
This reverts commit 9694445051.

  This change broke our release CI.

  1792764457 (step):16:44

  Invoking `/Users/runner/work/actions/actions/snapshot-master/ruby -rrubygems /Users/runner/work/actions/actions/snapshot-master/bin/gem --backtrace build lib/bundler/bundler.gemspec` failed with output:
  ----------------------------------------------------------------------
  dyld[42417]: Library not loaded: '/usr/local/lib/libruby.3.3.dylib'
    Referenced from: '/Users/runner/work/actions/actions/snapshot-master/ruby'
    Reason: tried: '/usr/local/lib/libruby.3.3.dylib' (no such file), '/usr/lib/libruby.3.3.dylib' (no such file)
  ----------------------------------------------------------------------
2023-11-21 20:21:18 +09:00
Nobuyoshi Nakada
22939382a8 [Bug #18286] Make builtin binary if sharable in universal binaries 2023-11-09 16:01:01 +09:00
Nobuyoshi Nakada
40d40a651e Revert "Disable iseq-dumped builtin module for universal x86_64/arm64 binaries"
This reverts commit 1d5598fe0d.
2023-11-09 16:01:01 +09:00
Ben Hamilton
1d5598fe0d Disable iseq-dumped builtin module for universal x86_64/arm64 binaries
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]
2023-11-09 12:24:01 +09:00
Nobuyoshi Nakada
6031fdc632
Select proper dsymutil for gcc 13 2023-11-07 23:19:51 +09:00
Nobuyoshi Nakada
f8456b650b
Ignore duplicate libraries warnings from gcc 13 2023-11-07 23:19:50 +09:00
Nobuyoshi Nakada
642875e474
[Bug #19967] Revert "configure.ac: LIBPATHENV on macOS"
This reverts commit 1961c786aa.  These
environment variables should no longer propagate to child processes.
2023-10-21 14:05:21 +09:00
Nobuyoshi Nakada
aee1bfd88e
Get rid of set with empty argument which dumps all definitions 2023-10-17 15:48:05 +09:00
Koichi Sasada
55c5ebe0a0 disable MN threads on s390s-linux
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.
2023-10-15 04:35:17 +09:00
Nobuyoshi Nakada
96cd73d78f
Ignore symbols even in empty shared library
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.
2023-10-14 18:38:24 +09:00
Nobuyoshi Nakada
9694445051
[Feature #19422] Enable shared by default on macOS 2023-10-12 19:26:07 +09:00
Koichi Sasada
be1bbd5b7d M:N thread scheduler for Ractors
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]
2023-10-12 14:47:01 +09:00
Nobuyoshi Nakada
bcb3247072
[Bug #19778] Pass additional include options to INCFLAGS in common.mk 2023-09-17 19:18:23 +09:00
Jean Boussier
efe2822708 Process.warmup: invoke malloc_trim if available
Similar to releasing free GC pages, releasing free malloc pages
reduce the amount of page faults post fork.
2023-09-15 17:45:21 +02:00
Nobuyoshi Nakada
fe0225ff4d [Bug #19778] Add -I options for opt-dir to $INCFLAGS
These options have been separated from `$CFLAGS` already in the
other places.
2023-09-15 13:27:19 +09:00
Nobuyoshi Nakada
abd0b9b28a
Exclude -Wmisleading-indentation when -save-temps
That option may be triggered wrongly by pre-processed files.
2023-09-06 14:06:26 +09:00
Nobuyoshi Nakada
5c98ee02d2
Define bounds-checking interfaces macro for each file 2023-08-27 00:12:03 +09:00
Jeremy Evans
b635388a90 Check that __builtin_mul_overflow can handle long long
Fixes [Bug #17646]

Patch from xtkoba (Tee KOBAYASHI)
2023-08-24 20:47:23 -07:00
Nobuyoshi Nakada
d26b015e83 [Bug #19831] Remove duplicate library options
`$(LIBRUBYARG_SHARED)` is included in `$(LIBS)` in extension
libraries.
2023-08-17 16:30:01 +09:00
Nobuyoshi Nakada
f339937abb RJIT: Remove macros inherited from MJIT but no longer used 2023-08-17 08:33:52 +09:00
Nobuyoshi Nakada
47b1a52826
Split installation from build section 2023-08-16 08:40:43 +09:00
Nobuyoshi Nakada
d9d4ae511a
Group configure outputs on GitHub Actions 2023-08-15 23:30:41 +09:00
Hiroshi SHIBATA
a642a94b68
llvm-objcopy is not provided by Xcode Command Line Tools.
Revert "Disable YJIT if objcopy command is old"

  This reverts commit 75f8781c08.
2023-07-07 09:28:27 +09:00
Nobuyoshi Nakada
75f8781c08
Disable YJIT if objcopy command is old
Co-authored-by: Takashi Kokubun <takashikkbn@gmail.com>
2023-07-06 21:16:00 +09:00
Jemma Issroff
9614a61379 Fixed build scripts for YARP 2023-07-05 16:58:55 -04:00
Takashi Kokubun
f2c367734f Introduce --enable-rjit=disasm 2023-04-27 14:27:51 -07:00
Takashi Kokubun
0bf10dfd25 Avoid linking capstone by default
Workaround for https://github.com/ruby/setup-ruby/pull/501#issuecomment-1520722486
2023-04-24 12:54:33 -07:00
Nobuyoshi Nakada
038f9ade3c
Use tools appropriate with CC
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:
```
2023-04-09 22:47:26 +09:00
Nobuyoshi Nakada
08324ab9eb
Include --no-llvm-bc option in NM macro only if usable 2023-04-08 12:47:27 +09:00
Nobuyoshi Nakada
f99af43980 [Bug#19161] Detect thread local storage specifier
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.
2023-04-07 13:42:48 +09:00
Jeremy Evans
466ca7ae20 Add Dir.fchdir
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]
2023-03-24 11:18:57 -07:00
Nobuyoshi Nakada
ed4dc1c33d
Fix ENABLE_MULTIARCH
This macro is used in `ruby_init_loadpath()`, but was removed
mistakenly at 31f4b2d86b.
2023-03-24 01:46:59 +09:00
Takashi Kokubun
51834ff2ec
YJIT: Make dev_nodebug closer to dev (#7570) 2023-03-20 13:03:22 -07:00
Takashi Kokubun
39cd74d2a0 RJIT: Use RJIT_STATS on --enable-rjit=dev
RUBY_DEBUG is too slow.
2023-03-17 23:17:26 -07:00
Takashi Kokubun
ac47b8df8f
Bump the required BASERUBY version to 2.5 (#7504)
[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
2023-03-10 23:40:22 -08:00
Takashi Kokubun
d5b7c8a972 RJIT: Always enable --rjit-dump-disasm 2023-03-10 11:29:25 -08:00
Nobuyoshi Nakada
96d1acfdf6
[Bug #19161] Check for TLS usability
On all platforms using GCC, even other than darwin.
2023-03-09 13:54:50 +09:00
Takashi Kokubun
9df1f58e01 Link libcapstone no matter what cargo does
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.
2023-03-07 22:58:11 -08:00
Takashi Kokubun
6d91df08b5
Allow enabling YJIT and RJIT independently (#7474)
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.
2023-03-07 22:43:37 -08:00
Takashi Kokubun
23ec248e48 s/mjit/rjit/ 2023-03-06 23:44:01 -08:00
Takashi Kokubun
2e875549a9 s/MJIT/RJIT/ 2023-03-06 23:44:01 -08:00
Takashi Kokubun
b2130d5f5d Remove obsoleted tool/mjit_tabs.rb 2023-03-06 22:53:38 -08:00
Takashi Kokubun
31f4b2d86b
Drop obsoleted MJIT header (#7458)
RJIT doesn't need this.
2023-03-06 21:41:48 -08:00
Takashi Kokubun
a7d01656b1 Rely on YJIT's switch for now 2023-03-05 23:28:59 -08:00
Takashi Kokubun
3fa4d41460 Implement --mjit-dump-disasm 2023-03-05 22:11:20 -08:00
小MAO钓鱼
65ef20d2a7
Add support for LoongArch (#7343)
* vm_dump.c: Dump machine registers on loongarch64 Linux.

* coroutines: Support for native loongarch64 coroutines.

---------

Co-authored-by: zangruochen <zangruochen@loongson.cn>
2023-02-22 13:11:33 +09:00
Nobuyoshi Nakada
413120e581
Do not use objcopy on macOS
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)
```
2023-02-15 13:45:26 +09:00
Nobuyoshi Nakada
ef9efcf0bf
Check if objcopy works to localize symbol
LLVM objcopy does not support localizing symbols option, e.g,
`--localize-symbol` and `--keep-global-symbol`, for MachO.
2023-02-14 18:47:29 +09:00