407 Commits
Author SHA1 Message Date
Jean Boussier 9ce0df6719 Make ISeq binaries portable
* Make `__FILE__` a frozen core method that return the iseq path.
* Make `load_from_binary` accept `file, path` like compile.

[Feature #17593]
[Feature #22395]
2026-10-07 09:57:31 +02:00
Kevin Menard 696ebaad23 JITs: Rebuild libjit.rlib when jit/src/lib.rs changes
Both libyjit.rlib and libzjit.rlib list jit/src/lib.rs as a dependency
in release builds containing both JITs. Any change to that file causes
the JIT-specific libraries to rebuild, but they'll rebuild with a stale
libjit.rlib, which can break the build or silently link old code.
2026-09-29 11:02:00 -04:00
Jean Boussier f01bf185f6 Refactor core_hash_merge_ptr and core_hash_merge_kw
Rather than start from a mutable hash created with `newhash` or
`duphash`, and then iteratively insert into it, it's preferable to
start from a constant hidden hash, so that we can directly allocate
the final hash with the right size.

For instance:

```ruby
{a: 1, B => 2, c: 3}
```

Before:

```
0000 duphash                                {a: 1}                    (   1)[Li]
0002 putspecialobject                       1
0004 swap
0005 opt_getconstant_path                   <ic:0 B>
0007 putobject                              2
0009 putobject                              :c
0011 putobject                              3
0013 opt_send_without_block                 <calldata!mid:core#hash_merge_ptr, argc:5, ARGS_SIMPLE>
```

After:

```
0000 putobject                              {a: 1}                    (   1)[Li]
0002 putspecialobject                       1
0004 swap
0005 opt_getconstant_path                   <ic:0 B>
0007 putobject                              2
0009 putobject                              :c
0011 putobject                              3
0013 opt_send_without_block                 <calldata!mid:core#hash_merge_ptr, argc:5, ARGS_SIMPLE>
```

Since, `duphash` has no idea how large the final hash might be,
it can't right-size the hash it allocates.

Hence it's preferable to use a `putobject` and let `hash_merge_ptr`
compute the final hash right size by assuming all keys are unique.
2026-08-24 09:12:31 +02:00
Nobuyoshi Nakada f7f3757488 Compare full version info of rustc to avoid E0514 2026-08-19 21:43:27 +09:00
Nobuyoshi Nakada ec1a1efed2 Add encdb.h and transdb.h dependencies 2026-08-14 12:28:42 +09:00
Paul Barker ef6b630cdb Finish fix for cross-compilation build race condition
Commit bb235bddd4 ("Avoid build-time race condition when
cross-compiling from a source tarball") turned out to be only a partial
fix, we also need to cover the case where git is present but we're not
building from a git checkout.

We can simply check if the `git log` command returned any output, if it
didn't then we're not in a git checkout.
2026-08-06 16:26:38 +09:00
Paul Barker bb235bddd4 Avoid build-time race condition when cross-compiling from a source tarball
Since commit 66529eef88 ("Force to update revision.h when commits
differ"), the Makefile rule for $(REVISION_H) is always marked as PHONY
when building from a source tarball. This has no benefit,
file2lastrev.rb will just print a warning and exit if we're not in a VCS
checkout, but it can cause problems.

When cross-compiling, the generated file $(arch)-fake.rb is used by
every invocation of MINIRUBY. $(arch)-fake.rb depends on $(REVISION_H),
so it is considered perpetually out-of-date and sub-make invocations
will repeatedly regenerate this file.

There is no enforcement of dependencies between sub-make invocations, so
one sub-make can be running MINIRUBY (and so using $(arch)-fake.rb) at
the same time as a different sub-make is regenerating $(arch)-fake.rb.
Truncating and re-writing $(arch)-fake.rb while it is mmapped by a
running ruby interpreter can cause a SIGBUS error, for example:

  i686-linux-gnu-fake.rb: [BUG] Bus Error at 0x00007fee11f02765

No addition of dependencies to Makefile rules can address this. Instead,
we need to stop treating $(REVISION_H) as PHONY when not building from a
git checkout.

Signed-off-by: Paul Barker <paul@pbarker.dev>
2026-07-31 22:35:21 +09:00
Nobuyoshi Nakada dca417bde7 [Misc #22206] Parse mkdepend options with OptionParser
Replace `-s` globals with explicit command options and standard long
option names. Group source selection under `--scope` and represent
output behavior as a single mode so command-line precedence is clear.

Keep command-line parsing and option dispatch inside `Mkdepend`, and
return command success directly from `Mkdepend.main`.
2026-07-23 00:54:13 +09:00
Nobuyoshi Nakada 7d4461e162 [Misc #22206] Generate dependencies without compiler builds
Replace `tool/update-deps` with a Ruby source scanner so dependency
updates no longer require GNU make, a configured build, or compiler
preprocessor output.

Keep compact source mappings and scanner declarations in dependency
files, and expand complete rules into the build directory.  Avoid the
temporary fixture headers required by the compiler-driven prototype.

Use the generated rules from GNU make, BSD make, and NMake builds.
Support out-of-tree and read-only source trees, and retain expanded
dependencies shipped in release archives when baseruby is unavailable.
2026-07-23 00:04:47 +09:00
Luke Gruber f66235e2bb Use getblockparamproxy for block#[], block#yield, block#===
Make block#[], block#yield, block#=== faster when inside a method and the block is a
block parameter. Treat it like an optimized method just like block#call was already.
This avoids the proc allocation unless the method is redefined.

```
Summary (YJIT disabled):

┌──────────────────────┬────────────┬────────────┬─────────────────────────────────┐
│          op          │   before   │   after    │             speedup             │
├──────────────────────┼────────────┼────────────┼─────────────────────────────────┤
│ block.call (control) │ 8.287M i/s │ 8.298M i/s │ ~1.00× (unchanged, as expected) │
├──────────────────────┼────────────┼────────────┼─────────────────────────────────┤
│ block[]              │ 3.786M i/s │ 8.289M i/s │ ~2.19×                          │
├──────────────────────┼────────────┼────────────┼─────────────────────────────────┤
│ block.yield          │ 3.760M i/s │ 8.269M i/s │ ~2.20×                          │
└──────────────────────┴────────────┴────────────┴─────────────────────────────────┘

Summary (YJIT enabled)

┌──────────────────────┬─────────────┬─────────────┬────────────────────┐
│          op          │   before    │    after    │      speedup       │
├──────────────────────┼─────────────┼─────────────┼────────────────────┤
│ block.call (control) │ 32.736M i/s │ 32.749M i/s │ ~1.00× (unchanged) │
├──────────────────────┼─────────────┼─────────────┼────────────────────┤
│ block[]              │ 9.112M i/s  │ 32.012M i/s │ ~3.51×             │
├──────────────────────┼─────────────┼─────────────┼────────────────────┤
│ block.yield          │ 9.119M i/s  │ 32.683M i/s │ ~3.58×             │
└──────────────────────┴─────────────┴─────────────┴────────────────────┘
```
2026-07-07 12:49:29 -04:00
Nobuyoshi Nakada f3d86878f7 Update default gemspecs after update 2026-05-13 11:55:57 +09:00
Jean Boussier 072a6a4a10 Rename putstring instruction as dupstring
As well as `putchilledstring` as `dupchilledstring`.

This is more consistent with similar `duparray` and `duphash`
instructions and better reflect it's behavior.
2026-04-30 06:30:50 +09:00
Nobuyoshi Nakada b94a7ec7c3 Suppress rev-parse error message when out-of-place build 2026-04-09 15:10:58 +09:00
Jean Boussier 9a2ffd8e54 Fix sending backtraces across ractors
[Bug #21818]

Currently exceptions can be sent across ractors,
but because of a limitation in the TypedData API,
the exception backtrace is duped as an empty backtrace.

The problem is that backtraces are embedded objects,
hence the classic `rb_class_alloc(klass)` API is insufficient
because we need to know the size of the Backtrace object we're
duping to instantiate the copy.

This is worked around by changing Ractors to call `#clone` on objects
rather than use `rb_obj_clone`, and to implement `Thread::Backtrace#clone`
to properly clone the variable size object.
2026-04-01 11:43:55 +01:00
Nobuyoshi Nakada 75e8401a61 Remove duplicate dependency 2026-03-19 10:35:25 +09:00
Kevin Newton a70dbe1065 Use Prism for mk_builtin_loader.rb 2026-03-13 09:15:28 -04:00
Nobuyoshi Nakada a3ee27fa3f Fix rdoc:% target for bundled rdoc 2026-03-12 17:39:53 +09:00
Nobuyoshi Nakada 319de3c513 git must in in the source tree instead of the build directory 2026-02-26 20:32:00 +09:00
NARUSE, Yui 70c6251488 Use rev-parse HEAD instead of log --format=%H -1 2026-02-24 14:27:52 +09:00
Nobuyoshi Nakada 2d2afa8c17 Group rubyspec_capiext 2026-02-20 19:25:21 +09:00
Nobuyoshi Nakada f33076be41 Clean rust target when rustc bumped up
Fix:
```
error[E0514]: found crate `jit` compiled by an incompatible version of rustc
```
2026-02-07 21:18:25 +09:00
Nobuyoshi Nakada 49ce12d2ef Silence building rubyspec-capiext [ci skip] 2026-01-14 13:55:35 +09:00
Nobuyoshi Nakada 6a630d992e Push the commits to the origin at make matz [ci skip] 2026-01-11 17:09:40 +09:00
Jarek ProkopandAlan Wu 25c72b0e8e Support customizable rustc_flags for rustc builds.
Add `rustc_flags` option for configure that appends to RUSTC_FLAGS
flags used when compiling with rustc for customizable build flags.
It appends to existing defaults in RUSTC_FLAGS.

Co-authored-by: Alan Wu <XrXr@users.noreply.github.com>
2026-01-06 23:55:06 -05:00
Mike Dalessio e6520de344 [Bug #21792] Build rubyspec-capiext only when excuting test-spec
rubyspec-capiext is only needed for running specs, not for building or
installing Ruby.
2025-12-20 22:24:52 +09:00
Alan Wu 656de67d5c JITs: Pass down GNU make jobserver resources when appropriate
To fix warnings from rustc on e.g. Make 4.3, which is in Ubuntu 24.04:

> warning: failed to connect to jobserver from environment variable
2025-12-17 14:49:32 -05:00
Nobuyoshi Nakada 6513cf9058 Export GIT
Propagate the value given with `--with-git` configure option to
tool/lib/vcs.rb.
2025-12-14 00:43:14 +09:00
Yusuke Endoh 129d74c96b Binding#implicit_parameters, etc. support the implicit "it" parameter
[Bug #21049]
2025-12-12 23:24:50 +09:00
Alan Wu 029a48176c JITs: Drop cargo and use just rustc for release combo build
So we don't expose builders to network flakiness which cannot be worked
around using cargo's --offline flag.
2025-12-10 16:35:00 -05:00
Alan Wu 121d0da025 JITs: Move cargo-specific variables into conditional 2025-12-10 16:35:00 -05:00
Nobuyoshi Nakada 52426a22de Remove an excess colon [ci skip] 2025-11-27 08:10:56 +09:00
Nobuyoshi Nakada ae60b0bfd8 Use DOT_WAIT for old GNU make [ci skip] 2025-11-08 00:29:34 +09:00
Nobuyoshi Nakada db57080450 [DOC] How to use make matz 2025-11-01 19:10:19 +09:00
Nobuyoshi Nakada 5ce27bef01 Flush NEWS.md only when NEW is not given
Split flushing NEWS and bumping up versions
2025-11-01 18:58:32 +09:00
Nobuyoshi Nakada 4b1279b6e9 Take MAJOR and MINOR from $(NEW) if given 2025-10-30 18:30:27 +09:00
Nobuyoshi Nakada a2849239db Expect git -C <path> to work
This option is available since git 1.8.5 that was released in 2013.
2025-09-16 20:28:37 +09:00
Aiden Fox Ivey f75e1cb362 ZJIT: Move jit.rs to ruby.rs and create a shared crate jit
* ruby.rs should hold the main entrypoint to YJIT and ZJIT
* The crate jit will hold code shared between them
2025-09-11 21:51:47 -07:00
Nobuyoshi Nakada 6023195fbd Abandon ruby target on the others than GNU make
The default non-transformed name, `ruby` target was added for the case
of `--program-transform-name` and similars, but it was occasionally
added even when no such option is used.
2025-08-28 19:01:48 +09:00
Nobuyoshi Nakada 75a968d88a Add the recipe to fix/update depend files 2025-08-18 11:03:58 +09:00
Nobuyoshi Nakada 6b2d9ed2a5 Handle preperly comments in middle of lines in gems/bundled_gems 2025-08-12 16:04:57 +09:00
Hiroshi SHIBATA be7b1164e6 Split autogenerated dependency to depend file from common.mk 2025-07-25 19:50:06 +09:00
Alan Wu 1a20765074 DRY up CARGO_VERBOSE for JITs 2025-07-16 19:50:30 -04:00
Nobuyoshi Nakada 698cf146ac Fetch only necessary commits of bundled gems 2025-06-09 23:41:13 +09:00
Nobuyoshi Nakada 7a56c31641 Revert "[Bug #21388] Make snapshots of gems"
This reverts commit e90282be7b, a commit miss.
2025-06-07 18:43:56 +09:00
Nobuyoshi Nakada e90282be7b [Bug #21388] Make snapshots of gems
If the revision of bundled gems is specified for ruby master (and
`git` is usable), checkout that revision and build a snapshot gem, and
use it for `test-spec` instead of the downloaded release version.
2025-06-07 18:41:36 +09:00
Koichi Sasada 7b75b1f2da prepare IDs for Ractor::monitor
To prevent the following strange error, prepare IDs at first.

```
     <internal:ractor>:596:in 'Ractor#monitor': symbol :exited is already registered with 98610c (fatal)
             from <internal:ractor>:550:in 'Ractor#join'
             from <internal:ractor>:574:in 'Ractor#value'
             from bootstraptest.test_ractor.rb_2013_1309.rb:12:in '<main>'
```

BTW, the error should be fixed on ID management system.
2025-05-31 18:29:02 +09:00
Alan Wu 8f50bb7c24 JITs: Add back MACOSX_DEPLOYMENT_TARGET=11.0 setting to avoid warning
See: 41251fdd30
2025-05-21 22:48:20 +09:00
Alan Wu dfc0fe3679 Add jit.rs as dependency in Makefile 2025-05-21 00:35:56 +09:00
Alan Wu 92b218fbc3 YJIT: ZJIT: Allow both JITs in the same build
This commit allows building YJIT and ZJIT simultaneously, a "combo
build". Previously, `./configure --enable-yjit --enable-zjit` failed. At
runtime, though, only one of the two can be enabled at a time.

Add a root Cargo workspace that contains both the yjit and zjit crate.
The common Rust build integration mechanisms are factored out into
defs/jit.mk.

Combo YJIT+ZJIT dev builds are supported; if either JIT uses
`--enable-*=dev`, both of them are built in dev mode.

The combo build requires Cargo, but building one JIT at a time with only
rustc in release build remains supported.
2025-05-15 00:39:03 +09:00
Nobuyoshi Nakada ed2806117a Do not let files depend on a phony target 2025-05-12 17:45:39 +09:00