Import Ruby 3.1.0

OK sebastia@
This commit is contained in:
jeremy 2022-01-04 19:46:40 +00:00
parent 04d989abfd
commit b528e05fd4
21 changed files with 16073 additions and 0 deletions

45
lang/ruby/3.1/Makefile Normal file
View File

@ -0,0 +1,45 @@
# $OpenBSD: Makefile,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
VERSION = 3.1.0
DISTNAME = ruby-${VERSION}
SHARED_LIBS = ruby31 0.0
NEXTVER = 3.2
PKGSPEC-main ?= ruby->=3.1.0,<${NEXTVER}
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
MULTI_PACKAGES = -main -ri_docs
.include <bsd.port.arch.mk>
.if ${BUILD_PACKAGES:M-ri_docs}
ALL_TARGET += rdoc
INSTALL_TARGET += install-doc
.endif
# Fix path for JIT compiler to not use shims in ports obj bin dir
CONFIGURE_ENV += ac_cv_path_MJIT_CC=`which ${CC}`
WANTLIB-main += curses yaml-0
post-extract:
${POST_EXTRACT}
pre-configure:
${FIX_RIPPER}
pre-install:
${PRE_INSTALL}
post-install:
${FIX_RBCONFIG}
do-test:
cd ${WRKSRC} && make check
.include <bsd.port.mk>

2
lang/ruby/3.1/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (ruby-3.1.0.tar.gz) = UKBQTG7ctNYc5rjP292qlXBxlfqw7Ne16SZUsqlBKFQ=
SIZE (ruby-3.1.0.tar.gz) = 20103517

View File

@ -0,0 +1,36 @@
$OpenBSD: patch-common_mk,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Enable verbose mode when building.
Don't regenerate rdoc documentation during install.
Index: common.mk
--- common.mk.orig
+++ common.mk
@@ -7,7 +7,7 @@ dll: $(LIBRUBY_SO)
.SUFFIXES: .rbinc .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=@)
@@ -302,7 +302,7 @@ ext/configure-ext.mk: $(PREP) all-incs $(MKFILES) $(RB
configure-ext: $(EXTS_MK)
build-ext: $(EXTS_MK)
- $(Q)$(MAKE) -f $(EXTS_MK) $(mflags) libdir="$(libdir)" LIBRUBY_EXTS=$(LIBRUBY_EXTS) \
+ $(Q)$(MAKE) -f $(EXTS_MK) V=1 $(mflags) libdir="$(libdir)" LIBRUBY_EXTS=$(LIBRUBY_EXTS) \
EXTENCS="$(ENCOBJS)" UPDATE_LIBRARIES=no $(EXTSTATIC)
$(Q)$(MAKE) $(EXTS_NOTE)
@@ -546,7 +546,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)

View File

@ -0,0 +1,19 @@
$OpenBSD: patch-compile_c,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Disable peephole optimizer on mips64 and sparc64, since it occasionally
segfaults.
Index: compile.c
--- compile.c.orig
+++ compile.c
@@ -2906,6 +2906,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);

View File

@ -0,0 +1,28 @@
$OpenBSD: patch-configure,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
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
@@ -30742,7 +30742,7 @@ fi
;; #(
openbsd*|mirbsd*) :
- LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
+ LIBRUBY_SO='lib$(RUBY_SO_NAME).so.'${LIBruby31_VERSION}
;; #(
solaris*) :
@@ -32366,7 +32366,7 @@ else
else
- arch="${target_cpu}-${target_os}"
+ arch="${target_cpu}-openbsd"
fi
cat >>confdefs.h <<_ACEOF

View File

@ -0,0 +1,25 @@
$OpenBSD: patch-ext_etc_etc_c,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Use shadow versions of password functions.
Index: ext/etc/etc.c
--- ext/etc/etc.c.orig
+++ ext/etc/etc.c
@@ -218,7 +218,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
@@ -248,7 +248,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

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-ext_extmk_rb,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Build extensions in verbose mode by default.
Index: ext/extmk.rb
--- ext/extmk.rb.orig
+++ ext/extmk.rb
@@ -646,7 +646,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=@)"

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-ext_ripper_depend,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Allow overriding CFLAGS for ripper extension.
Index: ext/ripper/depend
--- ext/ripper/depend.orig
+++ ext/ripper/depend
@@ -48,6 +48,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
ripper.o: $(RUBY_EXTCONF_H)
ripper.o: $(arch_hdrdir)/ruby/config.h

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-lib_fileutils_rb,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Make FileUtils.mkdir_p act more like mkdir(1) -p, by not attempting
to create directories that already exist. This fixes systrace
warnings when building ports.
Index: lib/fileutils.rb
--- lib/fileutils.rb.orig
+++ lib/fileutils.rb
@@ -218,7 +218,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

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-lib_mkmf_rb,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Ignore linker warnings when compiling native extensions.
Index: lib/mkmf.rb
--- lib/mkmf.rb.orig
+++ lib/mkmf.rb
@@ -423,7 +423,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

View File

@ -0,0 +1,18 @@
$OpenBSD: patch-lib_rubygems_commands_install_command_rb,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Make gem binaries on ruby 3.1 use a 31 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
@@ -20,7 +20,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,

View File

@ -0,0 +1,13 @@
$OpenBSD: patch-lib_rubygems_dependency_installer_rb,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Index: lib/rubygems/dependency_installer.rb
--- lib/rubygems/dependency_installer.rb.orig
+++ lib/rubygems/dependency_installer.rb
@@ -20,7 +20,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?

View File

@ -0,0 +1,22 @@
$OpenBSD: patch-lib_rubygems_ext_ext_conf_builder_rb,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
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/ext_conf_builder.rb
--- lib/rubygems/ext/ext_conf_builder.rb.orig
+++ lib/rubygems/ext/ext_conf_builder.rb
@@ -30,6 +30,11 @@ class Gem::Ext::ExtConfBuilder < Gem::Ext::Builder
siteconf.puts "RbConfig::MAKEFILE_CONFIG['#{dir}'] = dest_path"
siteconf.puts "RbConfig::CONFIG['#{dir}'] = dest_path"
end
+ unless Process.euid == 0
+ %w[INSTALL INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM].each do |ins|
+ siteconf.puts "RbConfig::MAKEFILE_CONFIG['#{ins}'] = RbConfig::CONFIG['#{ins}'] = RbConfig::CONFIG['#{ins}'].gsub(/-o root -g bin/, '')"
+ end
+ end
siteconf.close

View File

@ -0,0 +1,17 @@
$OpenBSD: patch-template_builtin_binary_inc_tmpl,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
Ensure proper alignment of builtin binary arrays to fix crash on mips64.
compile.c accesses the start of these arrays as struct ibf_header.
Index: template/builtin_binary.inc.tmpl
--- template/builtin_binary.inc.tmpl.orig
+++ template/builtin_binary.inc.tmpl
@@ -6,7 +6,7 @@
% ary = RubyVM.enum_for(:each_builtin).to_a
% ary.each{|feature, iseq|
-static const unsigned char <%= feature %>_bin[] = {
+static const unsigned char <%= feature %>_bin[] __attribute__((aligned(8))) = {
% iseq \
% . to_binary \
% . each_byte \

View File

@ -0,0 +1,16 @@
$OpenBSD: patch-thread_pthread_h,v 1.1.1.1 2022/01/04 19:46:40 jeremy Exp $
base-gcc doesn't support __thread
Index: thread_pthread.h
--- thread_pthread.h.orig
+++ thread_pthread.h
@@ -72,7 +72,7 @@ typedef struct rb_global_vm_lock_struct {
#if __STDC_VERSION__ >= 201112
#define RB_THREAD_LOCAL_SPECIFIER _Thread_local
-#elif defined(__GNUC__)
+#elif defined(__clang__)
/* note that ICC (linux) and Clang are covered by __GNUC__ */
#define RB_THREAD_LOCAL_SPECIFIER __thread
#else

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.)

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.

View File

@ -0,0 +1,19 @@
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/ruby31 ${PREFIX}/bin/ruby
ln -sf ${PREFIX}/bin/bundle31 ${PREFIX}/bin/bundle
ln -sf ${PREFIX}/bin/bundler31 ${PREFIX}/bin/bundler
ln -sf ${PREFIX}/bin/erb31 ${PREFIX}/bin/erb
ln -sf ${PREFIX}/bin/gem31 ${PREFIX}/bin/gem
ln -sf ${PREFIX}/bin/irb31 ${PREFIX}/bin/irb
ln -sf ${PREFIX}/bin/rdoc31 ${PREFIX}/bin/racc
ln -sf ${PREFIX}/bin/rake31 ${PREFIX}/bin/rake
ln -sf ${PREFIX}/bin/rdoc31 ${PREFIX}/bin/rbs
ln -sf ${PREFIX}/bin/rdoc31 ${PREFIX}/bin/rdbg
ln -sf ${PREFIX}/bin/rdoc31 ${PREFIX}/bin/rdoc
ln -sf ${PREFIX}/bin/ri31 ${PREFIX}/bin/ri
ln -sf ${PREFIX}/bin/typeprof31 ${PREFIX}/bin/typeprof
The ruby-shims package is also available to automatically select an
appropriate Ruby version per-project directory or system-wide.

2690
lang/ruby/3.1/pkg/PLIST-main Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,16 @@
If you set up the symlinks to make ruby 3.1 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/racc
rm ${PREFIX}/bin/rake
rm ${PREFIX}/bin/rbs
rm ${PREFIX}/bin/rdbg
rm ${PREFIX}/bin/rdoc
rm ${PREFIX}/bin/ri
rm ${PREFIX}/bin/typeprof