Commit graph

638 commits

Author SHA1 Message Date
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
Nobuyoshi Nakada
899ea35035
Extract include/ruby/internal/attr/packed_struct.h
Split `PACKED_STRUCT` and `PACKED_STRUCT_UNALIGNED` macros into the
macros bellow:
* `RBIMPL_ATTR_PACKED_STRUCT_BEGIN`
* `RBIMPL_ATTR_PACKED_STRUCT_END`
* `RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_BEGIN`
* `RBIMPL_ATTR_PACKED_STRUCT_UNALIGNED_END`
2023-02-08 12:34:13 +09:00
Nobuyoshi Nakada
be81495c16
Silence dozens of useless warnings from nm on macOS 2023-01-31 19:42:01 +09:00
Alan Wu
e7e48e8a66 configure: Keep OBJCOPY even when visibility options are available
YJIT will need it to address symbol leakage issue. Fallback to `:` when
OBJCOPY is not available on the system.

Co-authored-by: Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2023-01-27 12:28:09 -05:00
Alan Wu
17c8bf2c63 configure: Don't use use LD=clang, ld takes different flags
This was a difference from using a GNU toolchain previously. It wasn't a
problem because we don't invoke $(LD) in the Makefile currently. YJIT
will want to invoke LD, so needs this consistency.
2023-01-27 12:28:09 -05:00
Nobuyoshi Nakada
00ee1d128f Get rid of duplicate "--disable=gems" options 2023-01-26 16:31:08 +09:00
Nobuyoshi Nakada
1e2523fad7
Silence dozens of useless warnings from ranlib on macOS [ci skip] 2023-01-23 19:02:36 +09:00
Jeremy Evans
1066d42ca8 Enable arm64 coroutine implementation on OpenBSD/arm64
Tested by another OpenBSD developer and confirmed to significantly
improve things.
2022-12-25 19:14:13 -08:00
NARUSE, Yui
3fb1d49a1f Revert "darwin: resolve rb symbols from ext by -flat_namespace to see libruby transitively"
This reverts commit c5eefb7f37.

Flat namespace breaks gems with C extention if its symbols conflict
with ohter libraries.
2022-12-24 18:59:45 +09:00