Commit graph

546 commits

Author SHA1 Message Date
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
Nobuyoshi Nakada
c5ca250eb5
Clear _FORTIFY_SOURCE before definition
As clang on macOS defines this macro as 0 internally when a sanitizer
option is given, clear it before definition to suppress redefinition
warnings.
2022-10-29 16:17:45 +09:00
Alan Wu
5ca23caa20
YJIT: fold the "asm_comments" feature into "disasm" (#6591)
Previously, enabling only "disasm" didn't actually build. Since these
two features are closely related and we don't really use one without the
other, let's simplify and merge the two features together.
2022-10-19 14:03:07 -04:00
Sergey Fedorov
567725ed30
Fix and improve coroutines for Darwin (macOS) ppc/ppc64. (#5975) 2022-10-19 23:49:45 +13:00
Nobuyoshi Nakada
ee6cc25026
Remove wrong dollar 2022-10-15 01:03:47 +09:00
Nobuyoshi Nakada
f3a3ab110e
[Bug #16909] Honor the tool prefix against pkg-config 2022-10-02 16:08:38 +09:00
Maxime Chevalier-Boisvert
8fcbb79742
YJIT: reverse configure.ac changes that disable --yjit-stats on Graviton1 (#6457)
Reverse configure.ac changes that disable YJIT stats on Graviton1
2022-09-27 19:27:19 -04:00
Nobuyoshi Nakada
ecffc6a203 Generate the revision.h before Makefile
Except for GNU make which updates makefiles automatically, repeating
configure in the same directory causes `make` to stop whenever pulled
a new commit.  This is unexpected in CIs.
2022-09-26 13:03:23 +09:00
Nobuyoshi Nakada
dc7d929e54
Extract RUBY_RELEASE_DATE from also revision.h
This make variable is very useful for daily build.
2022-09-25 22:40:05 +09:00
Takashi Kokubun
912ea8257a
YJIT: Support Rust 1.58.1 for --yjit-stats on Arm (#6410)
* YJIT: Test Rust 1.58.1 as well on Cirrus

* YJIT: Avoid using a Rust 1.60.0 feature

* YJIT: Use autoconf to detect support

* YJIT: We actually need to run it

for checking it properly

* YJIT: Try cfg!(target_feature = "lse")

* Revert "YJIT: Try cfg!(target_feature = "lse")"

This reverts commit 4e2a9ca9a9.

* YJIT: Add --features stats only when it works

* Update configure.ac

Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
2022-09-23 16:17:54 -04:00
Jeremy Evans
88bf8ad6e9 Allow --enable-yjit on OpenBSD
yjit uses _Unwind_* functions from libunwind.  These functions
are available in libc++abi (which requires libpthread), so
add those to LDFLAGS if enabling yjit on OpenBSD.
2022-09-23 05:51:34 +09:00
Alan Wu
a8dc49b4d5 YJIT: Support MAKE=bmake for release build
This add support for bmake, which should allow building with
`configure --enable-yjit` for the BSDs. Tested on FreeBSD 13 and
on macOS with `configure MAKE=bmake` on a case-sensitive file system.

It works by including a fragment into the Makefile through the configure
script, similar to common.mk. It uses the always rebuild approach to
keep build system changes minimal.
2022-09-20 14:17:27 -04:00
Nobuyoshi Nakada
6898984f1c
[Bug #19005] dynamic_lookup linker option in external libraries
The warning against `-undefined dynamic_lookup` is just a warning yet,
and many gems seem to pay no attention to warnings.  Until it fails
actually, keep it as a migration path, except for standard extension
libraries and bundled extension gems.
2022-09-17 12:09:34 +09:00
Kenta Murata
2e25b85a7e
configure.ac: Apply suggestions from code review in #6366
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
2022-09-14 23:14:36 +09:00
Kenta Murata
f512df7398
configure.ac: Add --with-gmp-dir (#6366)
Add the `--with-gmp-dir` to specify the prefix directory of GMP.
The`--without-gmp` option is preserved for convenience.  It can
be used to force to reject using GMP even if the `--with-gmp-dir`
option is specified.
2022-09-14 22:17:39 +09:00
Nobuyoshi Nakada
c428fc0e1f -undefined dynamic_lookup is obsolete 2022-09-14 11:27:05 +09:00
Nobuyoshi Nakada
e2b47b832f
configure.ac: Manage OPT_DIR better (#6367)
* Check rpath flag earlier

* Manage OPT_DIR at once
2022-09-14 10:42:38 +09:00
Nobuyoshi Nakada
ed029e9bd4
Autoconf 2.70 or AC_PROG_CC_C99 for earlier is checking for C99
It is no longer necessary to add it to `CFLAGS`/`CPPFLAGS` later.

Furthermore, as `CPPFLAGS` is used also with C++ compiler, the option
particular to C such as `-std=gnu99` results in an error.
2022-09-12 19:53:10 +09:00
Nobuyoshi Nakada
1f91dcdab3
Define BOOTSTRAPRUBY from HAVE_BASERUBY 2022-09-07 14:33:25 +09:00