Граф коммитов

514 Коммитов

Автор SHA1 Сообщение Дата
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
Yuta Saito c5eefb7f37 darwin: resolve rb symbols from ext by `-flat_namespace` to see libruby transitively
This repairs the assumption, which many fat-gem maintainer expect, "An
extension built with --disable-shared Ruby is loadable from
--enable-shared Ruby".

By default all references resolved to a dynamic library use "two-level
namespace", which record the library name and symbol name for each
resolution entry. On the other hand, `-flat_namespace` discards the
library name information and resolves symbols "flatly".
This behavior is useful for us to ignore which image (`ruby`
executable or `libruby.dylib`) provides rb symbols at runtime.
2022-12-23 17:45:20 +09:00
Mike Dalessio 5c21cc3970 configure.ac: limit miniruby dep to when bundle_loader needs it
See also e7bffe0

https://bugs.ruby-lang.org/issues/19239

Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-12-20 15:57:22 +09:00
Takashi Kokubun 1482f0649e
YJIT: Improve the description about --enable-yjit (#6947) 2022-12-19 10:26:21 -05:00
Nobuyoshi Nakada 7e93f7ceb7
Suppress cross tool warning for pkg-config [ci skip]
It is used from mkmf.rb on target environments.
2022-12-18 14:24:14 +09:00
Mike Dalessio e7bffe0c4b configure.ac: add miniruby to PREP when cross-compiling to darwin
miniruby is used to resolve symbols in ext bundles

https://bugs.ruby-lang.org/issues/19239

Co-authored-by: Yuta Saito <kateinoigakukun@gmail.com>
2022-12-18 11:56:53 +08:00
Maxime Chevalier-Boisvert 1004d693b7
Make it so YJIT is no longer marked as experimental (#6909)
Tested on production workloads at Shopify for > 1 year and proven
to be quite stable. Enabling YJIT at run-time is still guarded
behind the --yjit command-line option for now.
2022-12-12 15:13:46 -05:00
Alan Wu 1015e69d37
YJIT: echo "\n" is not portable
It's unspecified by POSIX. zsh and dash give a newline and
bash doesn't substitute it. Attributes don't have to be
followed by a newline anyway, so just remove it.

[Bug #19174]
2022-12-02 12:24:17 -05:00
Nobuyoshi Nakada a5dde619a4
Fix up "Avoid bash specific variable substitution"
Keep `target_alias` empty if it is set to empty.  If it is set to non
empty, `os_version_style_transform` is not used.
2022-12-03 02:03:57 +09:00
Nobuyoshi Nakada eb6785356d Avoid bash specific variable substitution
It may cause parse errors in some other sh even in never executed
parts.
2022-12-02 23:45:43 +09:00
Alan Wu a81c89b7c8
YJIT: Make sure rustc's target matches before enabling (#6804)
For people using Rosetta 2 on ARM Macs, it can happen that the
rustc in the PATH compiles for x86_64 while clang is targeting
ARM. We were enabling YJIT in these situations because the test
program compiled fine, but caused linking failure later due to
the architecture mismatch.

Adjust the test program to fail when rustc's target arch is different
from ruby's target arch.

[Bug #19146]
2022-11-24 14:58:41 -05:00
Takashi Kokubun 3071a727e0
Add a comment about confusing code [ci skip] 2022-11-20 23:21:28 -08:00
Samuel Williams ea8a7287e2
Add support for `sockaddr_un` on Windows. (#6513)
* Windows: Fix warning about undefined if_indextoname()

* Windows: Fix UNIXSocket on MINGW and make .pair more reliable

* Windows: Use nonblock=true for read tests with scheduler

* Windows: Move socket detection from File.socket? to File.stat

Add S_IFSOCK to Windows and interpret reparse points accordingly.
Enable tests that work now.

* Windows: Use wide-char functions to UNIXSocket

This fixes behaviour with non-ASCII characters.
It also fixes deletion of temporary UNIXSocket.pair files.

* Windows: Add UNIXSocket tests for specifics of Windows impl.

* Windows: fix VC build due to missing _snwprintf

Avoid usage of _snwprintf, since it fails linking ruby.dll like so:

  linking shared-library x64-vcruntime140-ruby320.dll
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol snwprintf
  x64-vcruntime140-ruby320.def : error LNK2001: unresolved external symbol vsnwprintf_l

whereas linking miniruby.exe succeeds.

This patch uses snprintf on the UTF-8 string instead.

Also remove branch GetWindowsDirectoryW, since it doesn't work.

* Windows: Fix dangling symlink test failures

Co-authored-by: Lars Kanis <kanis@comcard.de>
2022-11-17 14:50:25 -08:00
Takashi Kokubun 05af417587
YJIT: Show YJIT build option in RUBY_DESCRIPTION (#6738)
YJIT: Show YJIT profile in RUBY_DESCRIPTION
2022-11-16 10:08:52 -08:00
Takashi Kokubun d905632851
Define YJIT_STATS on --enable-yjit=stats (#6710) 2022-11-10 13:16:25 -08:00
Alan Wu c771d83593
Set up EXTSTATIC before checking it
The bundle_loader check for darwin checks EXTSTATIC, but previously the
setup for the variable comes after the check. I had trouble building
using --with-static-linked-ext on darwin before this change.
2022-11-10 11:30:54 -05:00
Alan Wu 1466682a23
YJIT: Improve checking message for rustc version (#6693)
Preivously we didn't have a "checking ...." line for this check and when
rustc was too old, we would dump the error message to the console like:

    checking for rustc... rustc
    error: there is no argument named `x`
     --> <anon>:1:33
      |
    1 | fn main() { let x = 1; format!("{x}"); }
      |                                 ^^^

    error: aborting due to previous error

`configure` checks usually don't do this and this might be confusing.

With this commit it now says something like:

    checking whether rustc is new enough for YJIT... no
2022-11-08 15:29:30 -05:00
Maxime Chevalier-Boisvert 3703a81491
YJIT: improve/fix code to automatically build YJIT when available (#6684)
* YJIT: improve/fix code to automatically build YJIT when available

* Set YJIT_SUPPORT=no

* Fix rustc => $RUSTC
2022-11-08 11:57:11 -05:00
Nobuyoshi Nakada fc842c9ccc
Check `rustc` with the target 2022-11-06 19:32:50 +09:00
Nobuyoshi Nakada 9627aab825
`--disable-jit-support` should disable YJIT successfully
Even if `rustc` is available, it should not be an error unless
`--enable-yjit` is explicitly given.
2022-11-06 17:07:44 +09:00
Nobuyoshi Nakada cb899a990a
Disable YJIT support when cross-compiling
As the target-list of `rustc` is different from `config.guess` and
`config.sub`, `$target` cannot be used directly.
2022-11-06 10:16:12 +09:00
Nobuyoshi Nakada 1454f8f219 Add `--target` option to RUSTC when cross-compiling 2022-11-06 06:47:38 +09:00
Nobuyoshi Nakada 10fd1d9507 Should use the configured rustc consistently 2022-11-06 06:47:38 +09:00
Maxime Chevalier-Boisvert dd4ae9a475
Auto-enable YJIT build when rustc >= 1.58.0 present (#6662)
* Auto-enable YJIT build when rustc >= 1.58.0 present

* Try different incantation to have rustc output to stdout only

* Add comment, remove whitespace

* Try to detect if we are on a platform on which YJIT is supported
2022-11-04 17:02:04 -04:00
Nobuyoshi Nakada 0717cb8419
Try -fstack-protector-strong on MinGW
The CI for MinGW has used it.
2022-10-30 19:16:09 +09:00