Import Ruby 3.2.0

sparc64 compiler fix and arm64 testing from tb@

OK tb@
This commit is contained in:
jeremy 2022-12-26 03:03:57 +00:00
parent 651f5f3812
commit 034f7352a8
22 changed files with 16748 additions and 0 deletions

54
lang/ruby/3.2/Makefile Normal file
View File

@ -0,0 +1,54 @@
VERSION = 3.2.0
DISTNAME = ruby-${VERSION}
SHARED_LIBS = ruby32 0.0
NEXTVER = 3.3
PKGSPEC-main ?= ruby->=3.2.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
.if ${MACHINE_ARCH:Mamd64} || ${MACHINE_ARCH:Maarch64}
# Support YJIT JIT compiler on arches Ruby supports
BUILD_DEPENDS += lang/rust
WANTLIB-main += c++abi
.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
# Fix path for JIT compiler to not use shims in ports obj bin dir
CONFIGURE_ENV += ac_cv_path_MJIT_CC=`which ${CC}`
GEM_EXTENSIONS_DIR = lib/ruby/gems/${REV}/extensions/${MACHINE_ARCH:S/i386/x86/:S/amd64/x86_64/}-openbsd
SUBST_VARS += GEM_EXTENSIONS_DIR
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.2/distinfo Normal file
View File

@ -0,0 +1,2 @@
SHA256 (ruby-3.2.0.tar.gz) = 2qp44TYLJ4P5je7OtnetkA86NsD/puK2sZCQvnerwnI=
SIZE (ruby-3.2.0.tar.gz) = 20440715

View File

@ -0,0 +1,34 @@
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=@)
@@ -328,7 +328,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)" MINIRUBY="$(MINIRUBY)" UPDATE_LIBRARIES=no $(EXTSTATIC)
$(Q)$(MAKE) $(EXTS_NOTE)
@@ -572,7 +572,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,17 @@
Disable peephole optimizer on mips64 and sparc64, since it occasionally
segfaults.
Index: compile.c
--- compile.c.orig
+++ compile.c
@@ -2994,6 +2994,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,39 @@
Support arm64 coroutines.
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
@@ -29474,6 +29474,10 @@ esac
coroutine_type=x86
;; #(
+ aarch64-openbsd*) :
+
+ coroutine_type=arm64
+ ;; #(
*-openbsd*) :
coroutine_type=pthread
@@ -31683,7 +31687,7 @@ fi
;; #(
openbsd*|mirbsd*) :
- LIBRUBY_SO='lib$(RUBY_SO_NAME).$(SOEXT).$(MAJOR).'`expr ${MINOR} \* 10 + ${TEENY}`
+ LIBRUBY_SO='lib$(RUBY_SO_NAME).so.'${LIBruby32_VERSION}
;; #(
solaris*) :
@@ -33674,7 +33678,7 @@ then :
else $as_nop
- arch="${target_cpu}-${target_os}"
+ arch="${target_cpu}-openbsd"
fi
printf "%s\n" "#define RUBY_PLATFORM \"$arch\"" >>confdefs.h

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
@@ -223,7 +223,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
@@ -253,7 +253,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,14 @@
Build extensions in verbose mode by default.
Index: ext/extmk.rb
--- ext/extmk.rb.orig
+++ ext/extmk.rb
@@ -712,7 +712,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,14 @@
Allow overriding CFLAGS for ripper extension.
Index: ext/ripper/depend
--- ext/ripper/depend.orig
+++ ext/ripper/depend
@@ -45,6 +45,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,16 @@
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
@@ -381,7 +381,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,14 @@
Ignore linker warnings when compiling native extensions.
Index: lib/mkmf.rb
--- lib/mkmf.rb.orig
+++ lib/mkmf.rb
@@ -415,7 +415,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,16 @@
Make gem binaries on ruby 3.2 use a 32 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
@@ -22,7 +22,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,12 @@
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,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
@@ -40,6 +40,12 @@ class Gem::Ext::Builder
env << "sitelibdir=%s" % sitedir
end
+ unless Process.euid == 0
+ %w[INSTALL INSTALL_DATA INSTALL_SCRIPT INSTALL_PROGRAM].each do |ins|
+ env << "#{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 = [

View File

@ -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
@@ -56,7 +56,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"]
ensure
ENV["DESTDIR"] = destdir
end

View File

@ -0,0 +1,15 @@
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,14 @@
base-gcc doesn't support __thread
Index: thread_pthread.h
--- thread_pthread.h.orig
+++ thread_pthread.h
@@ -93,7 +93,7 @@ struct rb_thread_sched {
#ifndef RB_THREAD_LOCAL_SPECIFIER_IS_UNSUPPORTED
# 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
# endif

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/ruby32 ${PREFIX}/bin/ruby
ln -sf ${PREFIX}/bin/bundle32 ${PREFIX}/bin/bundle
ln -sf ${PREFIX}/bin/bundler32 ${PREFIX}/bin/bundler
ln -sf ${PREFIX}/bin/erb32 ${PREFIX}/bin/erb
ln -sf ${PREFIX}/bin/gem32 ${PREFIX}/bin/gem
ln -sf ${PREFIX}/bin/irb32 ${PREFIX}/bin/irb
ln -sf ${PREFIX}/bin/racc32 ${PREFIX}/bin/racc
ln -sf ${PREFIX}/bin/rake32 ${PREFIX}/bin/rake
ln -sf ${PREFIX}/bin/rbs32 ${PREFIX}/bin/rbs
ln -sf ${PREFIX}/bin/rdbg32 ${PREFIX}/bin/rdbg
ln -sf ${PREFIX}/bin/rdoc32 ${PREFIX}/bin/rdoc
ln -sf ${PREFIX}/bin/ri32 ${PREFIX}/bin/ri
ln -sf ${PREFIX}/bin/typeprof32 ${PREFIX}/bin/typeprof
The ruby-shims package is also available to automatically select an
appropriate Ruby version per-project directory or system-wide.

2828
lang/ruby/3.2/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.2 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