Import Ruby 4.0.0

Mark BROKEN on sparc64 as it doesn't build.

arm64 testing by tb@
sparc64 issue found by tb@

OK tb@
This commit is contained in:
jeremy
2025-12-27 16:25:13 +00:00
parent f66734adbc
commit 95a9d4be0a
26 changed files with 19079 additions and 0 deletions
+69
View File
@@ -0,0 +1,69 @@
BROKEN-sparc64 = miniruby SIGBUS during build
VERSION = 4.0.0
DISTNAME = ruby-${VERSION}
PKGNAME-main = ruby-${VERSION}
PKGNAME-ri_docs = ruby${BINREV}-ri_docs-${VERSION}
SHARED_LIBS = ruby40 0.0
NEXTVER = 4.1
PKGSPEC-main ?= ruby->=4.0.0beta0,<${NEXTVER}
PATCHFILES.p = ruby-box-test-fix{099da884fe95ccf6c684a1563ed1c4b0fd8e1196}.patch
PSEUDO_FLAVORS= no_ri_docs bootstrap
# Do not build the RI docs on slow arches
.if ${MACHINE_ARCH:Malpha} || ${MACHINE_ARCH:Marm} || ${MACHINE_ARCH:Mhppa}
FLAVOR?= no_ri_docs bootstrap
.else
FLAVOR?=
.endif
.if ${MACHINE_ARCH:Mamd64}
# Support YJIT JIT compiler on arches Ruby supports
MODULES += lang/rust
WANTLIB-main += c++abi
MAKE_ENV += LIBRUBY_DLDFLAGS="-lc++abi"
.endif
.if ${MACHINE_ARCH:Maarch64}
# Disable YJIT on arm64 until it is fixed
CONFIGURE_ARGS += --disable-yjit
.endif
.if ${MACHINE_ARCH:Mriscv64}
CONFIGURE_ARGS += --with-coroutine=riscv64
.endif
MULTI_PACKAGES = -main -ri_docs
.include <bsd.port.arch.mk>
.if ${BUILD_PACKAGES:M-ri_docs}
ALL_TARGET += rdoc
INSTALL_TARGET += install-doc
.endif
COMPILER = base-clang ports-gcc
GEM_EXTENSIONS_DIR = lib/ruby/gems/${REV}/extensions/${MACHINE_ARCH:S/i386/x86/:S/amd64/x86_64/}-openbsd
SUBST_VARS += GEM_EXTENSIONS_DIR
TEST_ENV = RUBYGEMS_SYSTEM_UPDATE_MESSAGE=enable
TEST_TARGET = test-all test-spec TESTOPTS="-v -q"
post-extract:
${POST_EXTRACT}
pre-configure:
${FIX_RIPPER}
/usr/bin/touch ${WRKSRC}/ext/ripper/ripper.c
pre-install:
${PRE_INSTALL}
post-install:
${FIX_RBCONFIG}
gunzip ${PREFIX}/man/man1/ruby${BINREV}.1
gunzip ${PREFIX}/man/man1/erb${BINREV}.1
rm -rf ${PREFIX}/lib/ruby/gems/${REV}/gems/{debug,rbs}-*/ext/
.include <bsd.port.mk>
+4
View File
@@ -0,0 +1,4 @@
SHA256 (ruby-4.0.0.tar.gz) = LoOJyMByy2WMk6E3JzLZ6shAgsiLBldQ2x5SpaxjAnE=
SHA256 (ruby-box-test-fix.patch) = GbHsCPL9ZNdpXZl62mqghVbwkVoqKj6H3KtVJOoSrdk=
SIZE (ruby-4.0.0.tar.gz) = 23955109
SIZE (ruby-box-test-fix.patch) = 1047
+25
View File
@@ -0,0 +1,25 @@
Enable verbose mode when building.
Don't regenerate rdoc documentation during install.
Index: common.mk
--- common.mk.orig
+++ common.mk
@@ -9,7 +9,7 @@ dll: $(LIBRUBY_SO)
.SUFFIXES: .rbinc .rbbin .rb .inc .h .c .y .i .$(ASMEXT) .$(DTRACE_EXT)
# V=0 quiet, V=1 verbose. other values don't work.
-V = 0
+V = 1
V0 = $(V:0=)
Q1 = $(V:1=)
Q = $(Q1:0=@)
@@ -591,7 +591,7 @@ dont-install-man: $(PREP)
post-no-install-man::
@$(NULLCMD)
-install-doc: rdoc pre-install-doc do-install-doc post-install-doc
+install-doc: pre-install-doc do-install-doc post-install-doc
pre-install-doc:: install-prereq
do-install-doc: $(PROGRAM) pre-install-doc
$(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=rdoc $(INSTALL_DOC_OPTS)
+17
View File
@@ -0,0 +1,17 @@
Disable peephole optimizer on mips64 and sparc64, since it occasionally
segfaults.
Index: compile.c
--- compile.c.orig
+++ compile.c
@@ -3358,6 +3358,10 @@ static int
iseq_peephole_optimize(rb_iseq_t *iseq, LINK_ELEMENT *list, const int do_tailcallopt)
{
INSN *const iobj = (INSN *)list;
+#if defined(__mips64__) || defined(__sparc64__)
+ return COMPILE_OK;
+#endif
+
again:
optimize_checktype(iseq, iobj);
+48
View File
@@ -0,0 +1,48 @@
Using -mbranch-protection=standard to build with BTI support on aarch64.
Don't use -A -n flags to strip (broken by default due to ports infrastructure).
Set correct shared library name.
Override the arch setting to remove OpenBSD version from it,
so ports don't have to be bumped when OpenBSD version changes.
Index: configure
--- configure.orig
+++ configure
@@ -11106,7 +11106,7 @@ rm -f core conftest.err conftest.$ac_objext conftest.b
if test "x$rb_cv_libunwind_broken_ra_signing" = "xno"
then :
- for opt in -mbranch-protection=pac-ret -msign-return-address=all
+ for opt in -mbranch-protection=standard -msign-return-address=all
do :
# Try these flags in the _prepended_ position - i.e. we want to try building a program
@@ -31848,7 +31848,7 @@ main (void)
_ACEOF
if ac_fn_c_try_link "$LINENO"
then :
- if "${STRIP}" -A -n conftest$ac_exeext 2>/dev/null
+ if false # "${STRIP}" -A -n conftest$ac_exeext 2>/dev/null
then :
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: -A -n" >&5
@@ -32396,7 +32396,7 @@ fi
;; #(
openbsd*|mirbsd*) :
- LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
+ LIBRUBY_SO='lib$(RUBY_SO_NAME).so.'${LIBruby40_VERSION}
;; #(
solaris*) :
@@ -34645,7 +34645,7 @@ then :
else $as_nop
- arch="${target_cpu}-${target_os}"
+ arch="${target_cpu}-openbsd"
fi
printf "%s\n" "#define RUBY_PLATFORM \"$arch\"" >>confdefs.h
+23
View File
@@ -0,0 +1,23 @@
Use shadow versions of password functions.
Index: ext/etc/etc.c
--- ext/etc/etc.c.orig
+++ ext/etc/etc.c
@@ -236,7 +236,7 @@ etc_getpwuid(int argc, VALUE *argv, VALUE obj)
else {
uid = getuid();
}
- pwd = getpwuid(uid);
+ pwd = getpwuid_shadow(uid);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %d", (int)uid);
return setup_passwd(pwd);
#else
@@ -266,7 +266,7 @@ etc_getpwnam(VALUE obj, VALUE nam)
struct passwd *pwd;
const char *p = StringValueCStr(nam);
- pwd = getpwnam(p);
+ pwd = getpwnam_shadow(p);
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam);
return setup_passwd(pwd);
#else
+14
View File
@@ -0,0 +1,14 @@
Build extensions in verbose mode by default.
Index: ext/extmk.rb
--- ext/extmk.rb.orig
+++ ext/extmk.rb
@@ -730,7 +730,7 @@ exts.map! {|d| "#{ext_prefix}/#{d}/."}
FileUtils.makedirs(File.dirname($command_output))
begin
atomic_write_open($command_output) do |mf|
- mf.puts "V = 0"
+ mf.puts "V = 1"
mf.puts "V0 = $(V:0=)"
mf.puts "Q1 = $(V:1=)"
mf.puts "Q = $(Q1:0=@)"
@@ -0,0 +1,14 @@
Allow overriding CFLAGS for ripper extension.
Index: ext/ripper/depend
--- ext/ripper/depend.orig
+++ ext/ripper/depend
@@ -52,6 +52,8 @@ ripper.E: ripper.c
$(ECHO) preprocessing ripper.c
$(Q) $(CC) -E $(INCFLAGS) $(CPPFLAGS) $< | $(RUBY) $(srcdir)/tools/strip.rb > $@
+CFLAGS += %%CFLAGS_OVERRIDE%%
+
# AUTOGENERATED DEPENDENCIES START
eventids1.o: $(RUBY_EXTCONF_H)
eventids1.o: $(arch_hdrdir)/ruby/config.h
@@ -0,0 +1,15 @@
Make FileUtils.mkdir_p act more like mkdir(1) -p, by not attempting
to create directories that already exist.
Index: lib/fileutils.rb
--- lib/fileutils.rb.orig
+++ lib/fileutils.rb
@@ -378,7 +378,7 @@ module FileUtils
end
stack.reverse_each do |dir|
begin
- fu_mkdir dir, mode
+ fu_mkdir dir, mode unless File.directory?(dir)
rescue SystemCallError
raise unless File.directory?(dir)
end
+14
View File
@@ -0,0 +1,14 @@
Ignore linker warnings when compiling native extensions.
Index: lib/mkmf.rb
--- lib/mkmf.rb.orig
+++ lib/mkmf.rb
@@ -444,7 +444,7 @@ MESSAGE
result = nil
Logging.postpone do |log|
output = IO.popen(env, command, &:read)
- result = ($?.success? and File.zero?(log.path))
+ result = $?.success?
output
end
result
@@ -0,0 +1,16 @@
Make gem binaries on ruby 3.5 use a 35 suffix, so you can have both
other versions of the same gem installed at the same time
without conflicts.
Index: lib/rubygems/commands/install_command.rb
--- lib/rubygems/commands/install_command.rb.orig
+++ lib/rubygems/commands/install_command.rb
@@ -23,7 +23,7 @@ class Gem::Commands::InstallCommand < Gem::Command
def initialize
defaults = Gem::DependencyInstaller::DEFAULT_OPTIONS.merge({
- format_executable: false,
+ format_executable: true,
lock: true,
suggest_alternate: true,
version: Gem::Requirement.default,
@@ -0,0 +1,12 @@
Index: lib/rubygems/dependency_installer.rb
--- lib/rubygems/dependency_installer.rb.orig
+++ lib/rubygems/dependency_installer.rb
@@ -19,7 +19,7 @@ class Gem::DependencyInstaller
document: %w[ri],
domain: :both, # HACK: dup
force: false,
- format_executable: false, # HACK: dup
+ format_executable: true, # HACK: dup
ignore_dependencies: false,
prerelease: false,
security_policy: nil, # HACK: NoSecurity requires OpenSSL. AlmostNo? Low?
@@ -0,0 +1,21 @@
Ugly hack to make --user-install option work. Without this, when
a user uses gem install --user-install, it calls
/usr/bin/install -o root -g bin, which fails due to permission issues.
This removes the -o root -g bin, so it can succeed as a regular user.
Index: lib/rubygems/ext/builder.rb
--- lib/rubygems/ext/builder.rb.orig
+++ lib/rubygems/ext/builder.rb
@@ -54,6 +54,12 @@ class Gem::Ext::Builder
env << format("sitelibdir=%s", sitedir)
end
+ unless Process.euid == 0
+ %w[INSTALL INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM].each do |ins|
+ env.unshift "#{ins}=#{RbConfig::MAKEFILE_CONFIG[ins].gsub(/-o root -g bin/, '')}"
+ end
+ end
+
targets.each do |target|
# Pass DESTDIR via command line to override what's in MAKEFLAGS
cmd = [
@@ -0,0 +1,14 @@
Don't clean extension dir when installing gems. Doing so breaks packaging
of some ports.
Index: lib/rubygems/ext/ext_conf_builder.rb
--- lib/rubygems/ext/ext_conf_builder.rb.orig
+++ lib/rubygems/ext/ext_conf_builder.rb
@@ -60,7 +60,6 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
destent.exist? || FileUtils.mv(ent.path, destent.path)
end
- make dest_path, results, extension_dir, tmp_dest_relative, ["clean"], target_rbconfig: target_rbconfig
ensure
ENV["DESTDIR"] = destdir
end
@@ -0,0 +1,25 @@
Disable the use of `gem update --system`, which is not supported when using
OpenBSD packages. Also avoids printing the nagging update message:
A new release of RubyGems is available: 3.4.1 - 3.4.2!
Run `gem update --system 3.4.2` to update your installation.
The ENV usage is to skip this logic during tests, to avoid test failures.
Index: lib/rubygems.rb
--- lib/rubygems.rb.orig
+++ lib/rubygems.rb
@@ -1244,6 +1244,13 @@ An Array (#{env.inspect}) was passed in from #{caller[
attr_accessor :disable_system_update_message
+ unless ENV['RUBYGEMS_SYSTEM_UPDATE_MESSAGE'] == 'enable'
+ Gem.disable_system_update_message = <<EOF
+Ruby was installed using an OpenBSD package, and using `gem update --system`
+is not supported.
+EOF
+ end
+
##
# Whether RubyGems should enhance builtin `require` to automatically
# check whether the path required is present in installed gems, and
@@ -0,0 +1,13 @@
Skip spec that requires network access.
Index: spec/ruby/library/socket/socket/connect_spec.rb
--- spec/ruby/library/socket/socket/connect_spec.rb.orig
+++ spec/ruby/library/socket/socket/connect_spec.rb
@@ -73,6 +73,6 @@ describe 'Socket#connect' do
}.should raise_error(IO::TimeoutError)
ensure
client.close
- end
+ end if false
end
end
@@ -0,0 +1,13 @@
Skip spec that requires network access.
Index: spec/ruby/library/socket/tcpsocket/shared/new.rb
--- spec/ruby/library/socket/tcpsocket/shared/new.rb.orig
+++ spec/ruby/library/socket/tcpsocket/shared/new.rb
@@ -15,6 +15,7 @@ describe :tcpsocket_new, shared: true do
end
it 'raises IO::TimeoutError with :connect_timeout when no server is listening on the given address' do
+ skip
-> {
TCPSocket.send(@method, "192.0.2.1", 80, connect_timeout: 0)
}.should raise_error(IO::TimeoutError)
@@ -0,0 +1,16 @@
Allow linking libruby to libc++abi on amd64/aarch64, so other
software that links to libruby other than ruby itself does
not need to manually handle arch-dependent linking.
Index: template/Makefile.in
--- template/Makefile.in.orig
+++ template/Makefile.in
@@ -338,7 +338,7 @@ verify-static-library: $(LIBRUBY_A)
$(LIBRUBY_SO):
@-[ -n "$(EXTSTATIC)" ] || $(PRE_LIBRUBY_UPDATE)
$(ECHO) linking shared-library $@
- $(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) $(EXTSOLIBS) $(OUTFLAG)$@
+ $(Q) $(LDSHARED) ${LIBRUBY_DLDFLAGS} $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) $(EXTSOLIBS) $(OUTFLAG)$@
-$(Q) $(OBJCOPY) -w -L '$(SYMBOL_PREFIX)Init_*' -L '$(SYMBOL_PREFIX)InitVM_*' \
-L '$(SYMBOL_PREFIX)ruby_static_id_*' \
-L '$(SYMBOL_PREFIX)*_threadptr_*' -L '$(SYMBOL_PREFIX)*_ec_*' $@
@@ -0,0 +1,14 @@
Avoid test failure.
Index: test/rubygems/test_gem_commands_install_command.rb
--- test/rubygems/test_gem_commands_install_command.rb.orig
+++ test/rubygems/test_gem_commands_install_command.rb
@@ -1638,7 +1638,7 @@ ERROR: Possible alternatives: non_existent_with_hint
end
assert_directory_exists nested_bin_dir, "Nested bin directory should exist now"
- assert_path_exist File.join(nested_bin_dir, "a_bin")
+ #assert_path_exist File.join(nested_bin_dir, "a_bin")
assert_equal %w[a-2], @cmd.installed_specs.map(&:full_name)
end
@@ -0,0 +1,15 @@
Change expectation in test as we modify Ruby to keep intermediate files
in order to work with the ports system.
Index: test/rubygems/test_gem_installer.rb
--- test/rubygems/test_gem_installer.rb.orig
+++ test/rubygems/test_gem_installer.rb
@@ -1699,7 +1699,7 @@ class TestGemInstaller < Gem::InstallerTestCase
end
assert_path_exist extension_file, "installed"
- assert_path_not_exist intermediate_file
+ assert_path_exist intermediate_file
end
def test_installation_satisfies_dependency_eh
+17
View File
@@ -0,0 +1,17 @@
Ruby is the interpreted scripting language for quick and
easy object-oriented programming. It has many features to
process text files and to do system management tasks (as in
Perl). It is simple, straight-forward, and extensible.
Features of Ruby are shown below.
- Simple Syntax
- *Normal* Object-Oriented features(ex. class, method calls)
- *Advanced* Object-Oriented features(ex. Mix-in, Singleton-method)
- Operator Overloading
- Exception Handling
- Iterators and Closures
- Garbage Collection
- Dynamic Loading of Object files(on some architecture)
- Highly Portable(works on many UNIX machines, and on DOS,
Windows, Mac, BeOS etc.)
+2
View File
@@ -0,0 +1,2 @@
This contains the files used by ruby's ri tool to get documentation
about classes and methods in ruby core and standard library.
+22
View File
@@ -0,0 +1,22 @@
If you want to use this package as your default system ruby, as root
create symbolic links like so (overwriting any previous default):
ln -sf ${PREFIX}/bin/ruby40 ${PREFIX}/bin/ruby
ln -sf ${PREFIX}/bin/bundle40 ${PREFIX}/bin/bundle
ln -sf ${PREFIX}/bin/bundler40 ${PREFIX}/bin/bundler
ln -sf ${PREFIX}/bin/erb40 ${PREFIX}/bin/erb
ln -sf ${PREFIX}/bin/gem40 ${PREFIX}/bin/gem
ln -sf ${PREFIX}/bin/irb40 ${PREFIX}/bin/irb
ln -sf ${PREFIX}/bin/minitest40 ${PREFIX}/bin/minitest
ln -sf ${PREFIX}/bin/racc40 ${PREFIX}/bin/racc
ln -sf ${PREFIX}/bin/rake40 ${PREFIX}/bin/rake
ln -sf ${PREFIX}/bin/rbs40 ${PREFIX}/bin/rbs
ln -sf ${PREFIX}/bin/rdbg40 ${PREFIX}/bin/rdbg
ln -sf ${PREFIX}/bin/rdoc40 ${PREFIX}/bin/rdoc
ln -sf ${PREFIX}/bin/ri40 ${PREFIX}/bin/ri
ln -sf ${PREFIX}/bin/syntax_suggest40 ${PREFIX}/bin/syntax_suggest
ln -sf ${PREFIX}/bin/test-unit40 ${PREFIX}/bin/test-unit
ln -sf ${PREFIX}/bin/typeprof40 ${PREFIX}/bin/typeprof
The ruby-shims package is also available to automatically select an
appropriate Ruby version per-project directory or system-wide.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+19
View File
@@ -0,0 +1,19 @@
If you set up the symlinks to make ruby 4.0 the system
ruby, don't forget to remove the following files:
rm ${PREFIX}/bin/ruby
rm ${PREFIX}/bin/bundle
rm ${PREFIX}/bin/bundler
rm ${PREFIX}/bin/erb
rm ${PREFIX}/bin/gem
rm ${PREFIX}/bin/irb
rm ${PREFIX}/bin/minitest
rm ${PREFIX}/bin/racc
rm ${PREFIX}/bin/rake
rm ${PREFIX}/bin/rbs
rm ${PREFIX}/bin/rdbg
rm ${PREFIX}/bin/rdoc
rm ${PREFIX}/bin/ri
rm ${PREFIX}/bin/syntax_suggest
rm ${PREFIX}/bin/test-unit
rm ${PREFIX}/bin/typeprof