Commit graph

72962 commits

Author SHA1 Message Date
Alan Wu
f1057393da [DOC] Clarify that IO.read uses text mode
See: https://bugs.ruby-lang.org/issues/18882#note-13

[Bug #18882]
2022-08-05 14:34:08 -04:00
git
ce6dc9f660 * 2022-08-06 [ci skip] 2022-08-06 03:05:55 +09:00
Burdette Lamar
412da2c221
Sync new doc in Date (#6215) 2022-08-05 13:05:38 -05:00
Nobuyoshi Nakada
2f0d9e74c8 Get rid of -C option for very old git 2022-08-05 20:46:53 +09:00
Ivo Anjo
74817f3d37
[DOC] Process._fork does not get called by Process.daemon
As discussed in [Bug #18911], I'm adding some documentation to
`Process._fork` to clarify that it is not expected to cover
calls to `Process.daemon`.

[Bug #18911]: https://bugs.ruby-lang.org/issues/18911

Co-authored-by: Yusuke Endoh <mame@ruby-lang.org>
2022-08-05 18:40:48 +09:00
David Rodríguez
f310ac1cb2 [rubygems/rubygems] Include backtrace with crashes by default
3cc3bfd371
2022-08-05 16:37:03 +09:00
David Rodríguez
5a9db23734 [rubygems/rubygems] Automatically remove "ruby" from lockfile if incomplete
69d0b4e10b
2022-08-05 16:36:42 +09:00
Nobuyoshi Nakada
73f0573cb3
Ignore revision to test unless HAVE_GIT 2022-08-05 09:55:49 +09:00
Nobuyoshi Nakada
8fae120912
Clone upstream gem repositories for test 2022-08-05 09:53:18 +09:00
Nobuyoshi Nakada
5791171201
Load gemspec file at that directory
Gemspec files generated by old bundler run `git` without changing the
working directory.
Or some gemspec files expect an owned file at the top exists ath the
current working directory.
2022-08-05 09:52:20 +09:00
Nobuyoshi Nakada
661536ab16
Copy from cloned gem sources in parallel 2022-08-05 09:52:12 +09:00
Nobuyoshi Nakada
44a0a66559
Move to tool/lib/bundled_gem.rb 2022-08-05 09:44:18 +09:00
Nobuyoshi Nakada
41516b3541
Extract bundled gems by BASERUBY 2022-08-05 09:44:18 +09:00
Nobuyoshi Nakada
6a8f1a9e5c
Copy from bundled gem source for test 2022-08-05 09:44:18 +09:00
Nobuyoshi Nakada
87d8d25796
Use configured GIT 2022-08-05 09:39:47 +09:00
John Hawthorn
70b60d24b9 Fix inconsistency with opt_aref_with
opt_aref_with is an optimized instruction for accessing a Hash using a
non-frozen string key (ie. from a file without frozen_string_literal).
It attempts to avoid allocating the string, and instead silently using a
frozen string (hash string keys are always fstrings).

Because this is just an optimization, it should be invisible to the
user. However, previously this optimization was could be seen via hashes
with default procs.

For example, previously:

    h = Hash.new { |h, k| k.frozen? }
    str = "foo"
    h[str]   # false
    h["foo"] # true when optimizations enabled

This commit checks that the Hash doesn't have a default proc when using
opt_aref_with.
2022-08-04 14:48:47 -07:00
Noah Gibbs
1e7a2415a4
YJIT: Allow str-concat arg to be any string subtype, not just rb_cString (#6205)
Allow str-concat arg to be any string subtype, not just rb_cString
2022-08-04 12:19:14 -04:00
John Hawthorn
7f5f9d19c5
YJIT: Add known_* helpers for Type (#6208)
* YJIT: Add known_* helpers for Type

This adds a few helpers to Type which all return Options representing
what is known, from a Ruby perspective, about the type.

This includes:
* known_class_of: If known, the class represented by this type
* known_value_type: If known, the T_ value type
* known_exact_value: If known, the exact VALUE represented by this type
  (currently this is only available for true/false/nil)
* known_truthy: If known, whether or not this value evaluates as true
  (not false or nil)

The goal of this is to abstract away the specifics of the mappings
between types wherever possible from the codegen. For example previously
by introducing Type::CString as a more specific version of
Type::TString, uses of Type::TString in codegen needed to be updated to
check either case. Now by using known_value_type, at least in theory we
can introduce new types with minimal (if any) codegen changes.

I think rust's Option type allows us to represent this uncertainty
fairly well, and should help avoid mistakes, and the matching using this
turned out pretty cleanly.

* YJIT: Use known_value_type for checktype

* YJIT: Use known_value_type for T_STRING check

* YJIT: Use known_class_of in guard_known_klass

* YJIT: Use known truthyness in jit_rb_obj_not

* YJIT: Rename known_class_of => known_class
2022-08-04 11:18:24 -04:00
git
8bab099830 * 2022-08-05 [ci skip] 2022-08-05 00:09:30 +09:00
David Rodríguez
c84d0538be [rubygems/rubygems] Fix unused variable warning
```
/Users/deivid/Code/rubygems/rubygems/test/rubygems/test_gem_resolver_installer_set.rb:55: warning: assigned but unused variable - a_1_local
```

9ea4534800
2022-08-05 00:09:18 +09:00
Jean Boussier
6b2fc33ae2 thread_sync.c: pass proper argument to queue_sleep in rb_szqueue_push
When I removed the SizeQueue#push timeout from my PR, I forgot to
update the `queue_sleep` parameters to be a `queue_sleep_arg`.

Somehow this worked on most archs, but on Solaris/Sparc it would
legitimately crash when trying to access the `timeout` and `end`
members of the struct.
2022-08-04 11:48:31 +02:00
Yuta Saito
00f411c58a Add -bundle_loader to mjit compilation args on macOS 2022-08-04 16:29:22 +09:00
Yuta Saito
184fd94d7e Resolve abi symbols from libruby.dylib when available 2022-08-04 16:29:22 +09:00
Yuta Saito
6d8b9a9d61 Resolve abi symbol references from miniruby to avoid circular deps
Adding `ruby` to `PREP` causes the following circular dependencies
because `PREP` is used as a prerequisite by some targets required to
build `ruby` target itself.
```
make: Circular .rbconfig.time <- ruby dependency dropped.
make: Circular builtin_binary.inc <- ruby dependency dropped.
make: Circular ext/extinit.c <- ruby dependency dropped.
make: Circular ruby <- ruby dependency dropped.
```

Adding a new Make variable like `EXTPREP` only for exts may be also
reasonable, but it would introduce another complexity into our build
system. `-bundle_loader` doesn't care that link-time and run-time
loader executables are different as long as bound symbols are provided,
so it's ok to resolve from miniruby to simplify our build.
2022-08-04 16:29:22 +09:00
Alan Wu
e5a3f23256 Use $(bindir) for path to executable in mkmf
For the macOS -bundle_loader linker option, we need a path to the
Ruby exectuable. $(RUBY) is not necessarily a path since it could
be a command line invocation. That happens during build with
runruby.rb and can happen post installation if the user passes
the --ruby option to a extconf.rb. Use $(bindir) to locate
the executable instead.

Before installation, $(bindir) doesn't exist, so we need to be
able to override $(BUILTRUBY) in such situations so test-spec
and bundled extensions could build. Use a new mkmf global,
$builtruby, to do this; set it in fake.rb and in extmk.rb.

Our build system is quite complex...
2022-08-04 16:29:22 +09:00
Alan Wu
c69582a540 Quote $(BUILTRUBY) so paths with spaces work 2022-08-04 16:29:22 +09:00
Yuta Saito
50d81bfbc1 Link ext bundles with bundle loader option for newer ld64
ld64 shipped with Xcode 14 emits a warning when using `-undefined
dynamic_lookup`.

```
ld: warning: -undefined dynamic_lookup may not work with chained fixups
```

Actually, `-undefined dynamic_lookup` doesn't work when:

1. Link a *shared library* with the option
2. Link it with a program that uses the chained-fixup introduced from
   macOS 12 and iOS 15
because `-undefined dynamic_lookup` uses lazy-bindings and they won't be
bound while dyld fixes-up by traversing chained-fixup info.

However, we build exts as *bundles* and they are loaded only through
`dlopen`, so it's safe to use `-undefined dynamic_lookup` in theory.
So the warning produced by ld64 is false-positive, and it results
failure of option checking in configuration. Therefore, it would be an
option to ignore the warning during our configuration.

On the other hand, `-undefined dynamic_lookup` is already deprecated on
all darwin platforms except for macOS, so it's good time to get rid of
the option. ld64 also provides `-bundle_loader <executable>` option,
which allows to resolve symbols defined in the executable symtab while
linking. It behaves almost the same with `-undefined dynamic_lookup`,
but it makes the following changes:

1. Require that unresolved symbols among input objects must be defined
   in the executable.
2. Lazy symbol binding will lookup only the symtab of the bundle loader
   executable. (`-undefined dynamic_lookup` lookups all symtab as flat
   namespace)

This patch adds `-bundle_loader $(RUBY)` when non-EXTSTATIC
configuration by assuming ruby executable can be linked before building
exts.

See "New Features" subsection under "Linking" section for chained fixup
https://developer.apple.com/documentation/xcode-release-notes/xcode-13-release-notes
2022-08-04 16:29:22 +09:00
David Rodríguez
542040fb83 [rubygems/rubygems] Warn dangling symlinks
425b78637f
2022-08-04 13:36:45 +09:00
David Rodríguez
0591780a74 [rubygems/rubygems] Extract entry.full_name to a variable
3973773005
2022-08-04 13:36:44 +09:00
git
3944862066 * 2022-08-04 [ci skip] 2022-08-04 08:37:19 +09:00
tompng
b54f26b704 [ruby/irb] shortcut colorize_code to speedup pretty_print
8a074a6904
2022-08-04 08:37:03 +09:00
Jean Boussier
4406cb1bf1 Harden Queue#pop timeout tests
They occasionaly fail with;

```
  FLeaked thread: TestThreadQueue#test_queue_pop_timeout: #<Thread:0x0000000108e38e48 /Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:123 sleep>
  .Finished thread: TestThreadQueue#test_deny_pushers: #<Thread:0x0000000108e38e48 /Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:123 dead>
  ...
  Retrying...

    1) Failure:
  TestThreadQueue#test_sized_queue_pop_timeout [/Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:157]:
  <#<Thread:0x00000001084bc7e8 /Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:156 sleep>> expected but was
  <nil>.

    2) Failure:
  TestThreadQueue#test_queue_pop_timeout [/Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:124]:
  <#<Thread:0x00000001083ff058 /Users/runner/work/ruby/ruby/src/test/ruby/test_thread_queue.rb:123 sleep>> expected but was
  <nil>.
```

I'm hoping joining for longer should help avoid this.
2022-08-03 10:59:13 +02:00
David Rodríguez
851b3aa7dd [rubygems/rubygems] Fix bundle outdated --strict
It should be an alias of `--filter-strict`.

`--update-strict` is essentially a dummy option with no special behavior
associated and should be deprecated.

ec1e5d83c8
2022-08-03 16:33:53 +09:00
David Rodríguez
35c65e7ba6 [rubygems/rubygems] Fix conservative updates regardless of --strict
c9a1d69a8d
2022-08-03 16:33:52 +09:00
Hiroshi SHIBATA
71794a75db Merge rubygems/bundler HEAD
Pick from 8331e63263
2022-08-03 13:14:10 +09:00
Thomas Winsnes
8a1be433e8 [ruby/bigdecimal] Updated to use the correct spec for muilti license
13165b29b8
2022-08-03 11:04:31 +09:00
Thomas Winsnes
f33b2ae918
Updated to use multiple licenses
Co-authored-by: Hiroshi SHIBATA <hsbt@ruby-lang.org>
2022-08-03 11:04:20 +09:00
Ilya Dyakonov
4f00ee8d47 [rubygems/rubygems] fix platform matching for index specs
f087f1b590
2022-08-03 06:56:36 +09:00
David Rodríguez
20936eb3a9 [rubygems/rubygems] Warn (rather than crash) when setting nil specification versions
a4ba1a4d97
2022-08-03 06:56:18 +09:00
Burdette Lamar
eaf6189fe5 [ruby/date] Enhanced RDoc (https://github.com/ruby/date/pull/69)
Treats:
    ::_strptime
    ::strptime
Adds 'Related' entry to some methods' doc.

a6c2129273
2022-08-03 05:17:55 +09:00
Burdette Lamar
d8ea3a20fa [ruby/date] [DOC] Enhanced RDoc for parser methods (https://github.com/ruby/date/pull/68)
Treats:
    ::_httpdate
    ::_iso8601
    ::_jisx0301
    ::_parse
    ::_rfc2822
    ::_rfc3339
    ::_xmlschema
    ::httpdate
    ::iso8601
    ::jisx0301
    ::parse
    ::rfc2822
    ::rfc3339
    ::xmlschema

24bdab600a
2022-08-03 02:28:12 +09:00
git
4ba611ab29 * 2022-08-03 [ci skip] 2022-08-03 01:04:26 +09:00
Aaron Patterson
e4e054e3ce Speed up setting the backref match object
This patch speeds up setting the backref match object by avoiding some
memcopies.  Take the following code for example:

```ruby
"hello world" =~ /hello/
p $~
```

When the RE matches the string, we have to set the Match object in the
backref global.  So we would allocate a match object[^1] and use
`rb_reg_region_copy`[^2] to make a deep copy of the stack allocated
`re_registers` struct[^3] in to the newly created Ruby object.  This
could possibly trigger GC[^4], and would allocate new memory.

This patch makes a shallow copy of the `re_registers` struct on to the
Match object allowing the match object to manage the `re_registers`
pointer and also avoiding some calls to `xmalloc` and some manual
memcopy.

Benchmark looks like this:

```ruby

require "benchmark/ips"

def test_re thing
  thing =~ /hello/
end

Benchmark.ips do |x|
  x.report("re hit") do
    test_re "hello world"
  end

  x.report("re miss") do
    test_re "world"
  end
end
```

Before this patch:

```
$ ruby -v test.rb
ruby 3.2.0dev (2022-07-27T22:29:00Z master 4ad69899b7) [arm64-darwin21]
Ignoring bcrypt-3.1.16 because its extensions are not built. Try: gem pristine bcrypt --version 3.1.16
Warming up --------------------------------------
              re hit   345.401k i/100ms
             re miss   673.584k i/100ms
Calculating -------------------------------------
              re hit      3.452M (± 0.5%) i/s -     17.270M in   5.002535s
             re miss      6.736M (± 0.4%) i/s -     34.353M in   5.099593s
```

After this patch:

```
$ ./ruby -v test.rb
ruby 3.2.0dev (2022-08-01T21:24:12Z less-memcpy 0ff2a56606) [arm64-darwin21]
Warming up --------------------------------------
              re hit   419.578k i/100ms
             re miss   673.251k i/100ms
Calculating -------------------------------------
              re hit      4.201M (± 0.7%) i/s -     21.398M in   5.093593s
             re miss      6.716M (± 0.4%) i/s -     33.663M in   5.012756s
```

Matches get faster and misses maintain the same speed

[^1]: 24204d54ab/re.c (L1737)
[^2]: 24204d54ab/re.c (L1738)
[^3]: 24204d54ab/re.c (L1686)
[^4]: 24204d54ab/re.c (L981)
2022-08-02 09:04:04 -07:00
Peter Zhu
da00243dfe [DOC] Specify ways to run bootstrap tests 2022-08-02 09:40:53 -04:00
David Rodríguez
f70b26af47 [rubygems/rubygems] Array is already uniq, no need to deduplicate it
3212ae14b7
2022-08-02 21:57:52 +09:00
Takuya Noguchi
b81858cf6f [rubygems/rubygems] Fix arguments for bundle-config(1) docs
Signed-off-by: Takuya Noguchi <takninnovationresearch@gmail.com>

3e62ca776d
2022-08-02 18:35:38 +09:00
Jean Boussier
e3aabe93aa Implement Queue#pop(timeout: sec)
[Feature #18774]

As well as `SizedQueue#pop(timeout: sec)`

If both `non_block=true` and `timeout:` are supplied, ArgumentError
is raised.
2022-08-02 11:04:28 +02:00
Nobuyoshi Nakada
ec3f59309e [Bug #17767] Now ENV.clone raises TypeError as well as ENV.dup
One year ago, the former method has been deprecated while the latter
has become an error.  Then the 3.1 released, it is enough time to make
also the former an error.
2022-08-02 16:40:12 +09:00
David Rodríguez
3e4fedca4e [rubygems/rubygems] Preserve the previous behavior of raising an error when in frozen mode
6e35a6edfe
2022-08-02 16:10:19 +09:00
David Rodríguez
bc90090672 [rubygems/rubygems] Check for errors in error stream
7b0f7804f2
2022-08-02 16:10:18 +09:00