summaryrefslogtreecommitdiff
path: root/template
diff options
context:
space:
mode:
Diffstat (limited to 'template')
-rw-r--r--template/Doxyfile.tmpl6
-rw-r--r--template/GNUmakefile.in15
-rw-r--r--template/Makefile.in209
-rw-r--r--template/builtin_binary.rbbin.tmpl (renamed from template/builtin_binary.inc.tmpl)17
-rw-r--r--template/configure-ext.mk.tmpl39
-rw-r--r--template/encdb.h.tmpl36
-rw-r--r--template/extinit.c.tmpl2
-rw-r--r--template/exts.mk.tmpl58
-rw-r--r--template/fake.rb.in32
-rw-r--r--template/id.c.tmpl5
-rw-r--r--template/id.h.tmpl8
-rw-r--r--template/known_errors.inc.tmpl8
-rw-r--r--template/limits.c.tmpl19
-rw-r--r--template/prelude.c.tmpl93
-rw-r--r--template/ruby-runner.h.in2
-rw-r--r--template/sizes.c.tmpl21
-rw-r--r--template/transdb.h.tmpl39
-rw-r--r--template/unicode_norm_gen.tmpl37
18 files changed, 390 insertions, 256 deletions
diff --git a/template/Doxyfile.tmpl b/template/Doxyfile.tmpl
index c801e0e79b..cea28d04c7 100644
--- a/template/Doxyfile.tmpl
+++ b/template/Doxyfile.tmpl
@@ -621,7 +621,7 @@ HIDE_FRIEND_COMPOUNDS = NO
HIDE_IN_BODY_DOCS = YES
# The INTERNAL_DOCS tag determines if documentation that is typed after a
-# \internal command is included. If the tag is set to NO then the documentation
+# @internal command is included. If the tag is set to NO then the documentation
# will be excluded. Set it to YES to include the internal documentation.
# The default value is: NO.
@@ -2359,10 +2359,6 @@ PREDEFINED += DEPRECATED(_)=_
PREDEFINED += DEPRECATED_BY(__,_)=_
PREDEFINED += ENUM_OVER_INT=1
PREDEFINED += ERRORFUNC(__,_)=_
-PREDEFINED += RJIT_FUNC_EXPORTED=
-PREDEFINED += RJIT_STATIC=extern
-PREDEFINED += RJIT_SYMBOL_EXPORT_BEGIN=
-PREDEFINED += RJIT_SYMBOL_EXPORT_END=
PREDEFINED += NOINLINE(_)=_
PREDEFINED += NORETURN(_)=_
PREDEFINED += PACKED_STRUCT_UNALIGNED(_)=_
diff --git a/template/GNUmakefile.in b/template/GNUmakefile.in
index 0c7f4e9dd0..452e7cdeef 100644
--- a/template/GNUmakefile.in
+++ b/template/GNUmakefile.in
@@ -1,10 +1,14 @@
gnumake = yes
+ifneq ($(filter notintermediate,$(.FEATURES)),)
+DOT_WAIT = .WAIT
+endif
+
ifeq ($(filter Makefile,$(MAKEFILE_LIST)),)
include Makefile
+endif
GNUmakefile: $(srcdir)/template/GNUmakefile.in
-endif
override silence := $(if $(findstring s,$(firstword $(MFLAGS))),yes,no)
@@ -14,10 +18,6 @@ endif
override order_only := |
-ifneq ($(filter notintermediate,$(.FEATURES)),)
-DOT_WAIT = .WAIT
-endif
-
# Needs the dependency when any Unicode tables data files exist.
override UNICODE_TABLES_DEPENDENTS = \
$(if $(or \
@@ -27,7 +27,8 @@ override UNICODE_TABLES_DEPENDENTS = \
$(UNICODE_TABLES_DATA_FILES)))),\
force,none)
+# extract NMake-style include list
+$(eval common_mk_includes := $(shell sed -n 's/^!include *//p' $(srcdir)/common.mk))
+
-include uncommon.mk
include $(srcdir)/defs/gmake.mk
-
-GNUmakefile: $(srcdir)/template/GNUmakefile.in
diff --git a/template/Makefile.in b/template/Makefile.in
index 1b490b23e9..7ce612e8e9 100644
--- a/template/Makefile.in
+++ b/template/Makefile.in
@@ -29,7 +29,7 @@ CPP = @CPP@
LD = @LD@
RUSTC = @RUSTC@
CARGO = @CARGO@
-YACC = $(BASERUBY) $(tooldir)/lrama/exe/lrama
+LRAMA = $(BASERUBY) $(tooldir)/lrama/exe/lrama
PURIFY =
AUTOCONF = autoconf
CONFIGURE = @CONFIGURE@
@@ -37,6 +37,8 @@ CONFIGURE = @CONFIGURE@
MKFILES = @MAKEFILES@
BASERUBY = @BASERUBY@
HAVE_BASERUBY = @HAVE_BASERUBY@
+DUMP_AST = @X_DUMP_AST@
+DUMP_AST_TARGET = @X_DUMP_AST_TARGET@
TEST_RUNNABLE = @TEST_RUNNABLE@
CROSS_COMPILING = @CROSS_COMPILING@
DOXYGEN = @DOXYGEN@
@@ -65,6 +67,10 @@ rubyarchhdrdir = @rubyarchhdrdir@
ruby_version = @ruby_version@
RUBY_VERSION_NAME = @RUBY_VERSION_NAME@
UNIVERSAL_ARCHNAMES = @UNIVERSAL_ARCHNAMES@
+BUILTIN_BINARY = @X_BUILTIN_BINARY@
+
+BUILTIN_GC = default
+modular_gc_dir = @modular_gc_dir@
TESTUI = console
TESTS =
@@ -73,7 +79,8 @@ DOCTARGETS = @RDOCTARGET@ @CAPITARGET@
EXTOUT = @EXTOUT@
TIMESTAMPDIR = $(EXTOUT)/.timestamp
-arch_hdrdir = $(EXTOUT)/include/$(arch)
+ext_hdrdir = $(EXTOUT)/include
+arch_hdrdir = $(ext_hdrdir)/$(arch)
VPATH = $(arch_hdrdir)/ruby:$(hdrdir)/ruby:$(srcdir):$(srcdir)/missing
empty =
@@ -88,27 +95,32 @@ cflags = @cflags@
optflags = @optflags@
debugflags = @debugflags@
warnflags = @warnflags@ @strict_warnflags@
+hardenflags = @hardenflags@
cppflags = @cppflags@
+incflags = @incflags@
RUBY_DEVEL = @RUBY_DEVEL@ # "yes" or empty
_RUBY_DEVEL_enabled = $(RUBY_DEVEL:no=)
-XCFLAGS = @XCFLAGS@ $(INCFLAGS) $(_RUBY_DEVEL_enabled:yes=-DRUBY_DEVEL=1)
+XCFLAGS = @XCFLAGS@ $(INCFLAGS) $(_RUBY_DEVEL_enabled:yes=-DRUBY_DEVEL=1) -Dmodular_gc_dir="$(modular_gc_dir)"
USE_RUBYGEMS = @USE_RUBYGEMS@
USE_RUBYGEMS_ = $(USE_RUBYGEMS:yes=)
CPPFLAGS = @CPPFLAGS@ $(USE_RUBYGEMS_:no=-DDISABLE_RUBYGEMS=1)
-RJIT_SUPPORT = @RJIT_SUPPORT@
-RJIT_CC = @RJIT_CC@
-RJIT_CFLAGS = @RJIT_CFLAGS@
-RJIT_OPTFLAGS = @RJIT_OPTFLAGS@
-RJIT_DEBUGFLAGS = @RJIT_DEBUGFLAGS@
-RJIT_LDSHARED = @RJIT_LDSHARED@
-RJIT_DLDFLAGS = $(XDLDFLAGS)
+TOP_BUILD_DIR=@abs_top_builddir@
+JIT_OBJ=@JIT_OBJ@
YJIT_SUPPORT=@YJIT_SUPPORT@
YJIT_LIBS=@YJIT_LIBS@
YJIT_OBJ=@YJIT_OBJ@
-YJIT_LIBOBJ = $(YJIT_LIBS:.a=.@OBJEXT@)
-CARGO_TARGET_DIR=@abs_top_builddir@/yjit/target
-YARP_BUILD_DIR=@abs_top_builddir@/yarp
+ZJIT_SUPPORT=@ZJIT_SUPPORT@
+ZJIT_LIBS=@ZJIT_LIBS@
+ZJIT_OBJ=@ZJIT_OBJ@
+JIT_CARGO_SUPPORT=@JIT_CARGO_SUPPORT@
+CARGO_TARGET_DIR=@abs_top_builddir@/target
CARGO_BUILD_ARGS=@CARGO_BUILD_ARGS@
+ZJIT_TEST_FEATURES=@ZJIT_TEST_FEATURES@
+JIT_RUST_FLAGS=@JIT_RUST_FLAGS@
+RUSTC_FLAGS=@RUSTC_FLAGS@
+RLIB_DIR=@RLIB_DIR@
+RUST_LIB=@RUST_LIB@
+RUST_LIBOBJ = $(RUST_LIB:.a=.@OBJEXT@)
LDFLAGS = @STATIC@ $(CFLAGS) @LDFLAGS@
EXE_LDFLAGS = $(LDFLAGS)
EXTLDFLAGS = @EXTLDFLAGS@
@@ -133,11 +145,15 @@ BUILTIN_TRANSSRCS = @BUILTIN_TRANSSRCS@
BUILTIN_TRANSOBJS = @BUILTIN_TRANSOBJS@
POSTLINK = @POSTLINK@
+LIBPATHENV = @LIBPATHENV@
+PRELOADENV = @PRELOADENV@
+
RUBY_BASE_NAME=@RUBY_BASE_NAME@
RUBY_API_VERSION=@RUBY_API_VERSION@
RUBY_INSTALL_NAME=@RUBY_INSTALL_NAME@
RUBY_SO_NAME=@RUBY_SO_NAME@
EXEEXT = @EXEEXT@
+BUILD_EXEEXT = @X_BUILD_EXEEXT@
LIBEXT = @LIBEXT@
PROGRAM=$(RUBY_INSTALL_NAME)$(EXEEXT)
RUBY = $(RUBY_INSTALL_NAME)
@@ -200,7 +216,8 @@ DTRACE_DEPENDENT_OBJS = array.$(OBJEXT) \
string.$(OBJEXT) \
symbol.$(OBJEXT) \
vm.$(OBJEXT) \
- $(YJIT_OBJ)
+ $(YJIT_OBJ) \
+ $(ZJIT_OBJ)
THREAD_MODEL = @THREAD_MODEL@
@@ -226,7 +243,6 @@ AR = @AR@
ARFLAGS = @ARFLAGS@$(empty)
RANLIB = @RANLIB@
AS = @AS@
-ASFLAGS = @ASFLAGS@ $(ARCH_FLAG) $(INCFLAGS)
IFCHANGE = $(SHELL) $(tooldir)/ifchange
OBJDUMP = @OBJDUMP@
OBJCOPY = @OBJCOPY@
@@ -251,7 +267,6 @@ INSTALLED_LIST= .installed.list
NEWLINE_C = enc/trans/newline.c
MINIPRELUDE_C = miniprelude.c
-GOLF_PRELUDE_C= golf_prelude.c
RBCONFIG = .rbconfig.time
MAINSRC = $(MAINOBJ:.$(OBJEXT)=.c)
@@ -271,6 +286,8 @@ ACTIONS_ENDGROUP = @$(NULLCMD)
DESTDIR = @DESTDIR@
+cleanlibs = @cleanlibs@
+
configure_args = @configure_args@
#### End of variables
@@ -278,6 +295,8 @@ ABI_VERSION_HDR = $(hdrdir)/ruby/internal/abi.h
CAT_DEPEND = sed -e 's/{\$$([^(){}]*)[^{}]*}//g' -e /AUTOGENERATED/q
+HASH_SIGN = \#
+
.SUFFIXES: .inc .h .c .y .i .$(ASMEXT) .$(DTRACE_EXT)
all:
@@ -292,13 +311,13 @@ all:
miniruby$(EXEEXT):
@-if test -f $@; then $(MV) -f $@ $@.old; $(RM) $@.old; fi
$(ECHO) linking $@
- $(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(MAINLIBS) $(LIBS) $(OUTFLAG)$@
+ $(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(NORMALMAINOBJ) $(MINIOBJS) $(COMMONOBJS) $(MAINLIBS) $(OUTFLAG)$@
$(Q) $(POSTLINK)
$(PROGRAM):
@$(RM) $@
$(ECHO) linking $@
- $(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(LIBS) $(EXTLIBS) $(OUTFLAG)$@
+ $(Q) $(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(EXTOBJS) $(LIBRUBYARG) $(MAINLIBS) $(EXTLIBS) $(OUTFLAG)$@
$(Q) $(POSTLINK)
$(PROGRAM): @XRUBY_LIBPATHENV_WRAPPER@
@@ -308,8 +327,6 @@ PRE_LIBRUBY_UPDATE = [ -n "$(LIBRUBY_SO_UPDATE)" ] || $(gnumake:yes=exec) $(RM)
# We must `rm' the library each time this rule is invoked because "updating" a
# MAB library on Apple/NeXT (see --enable-fat-binary in configure) is not
# supported.
-#
-# In YJIT builds, merge libyjit.a with libruby_static.a
$(LIBRUBY_A):
@$(RM) $@
@-[ -z "$(EXTSTATIC)" ] || $(PRE_LIBRUBY_UPDATE)
@@ -319,14 +336,15 @@ $(LIBRUBY_A):
verify-static-library: $(LIBRUBY_A)
$(ECHO) verifying static-library $@
- @$(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(LIBS) $(OUTFLAG)conftest$(EXEEXT)
+ @$(PURIFY) $(CC) $(EXE_LDFLAGS) $(XLDFLAGS) $(MAINOBJ) $(LIBRUBY_A) $(MAINLIBS) $(EXTLIBS) $(OUTFLAG)conftest$(EXEEXT)
@$(RMALL) conftest$(EXEEXT) conftest.c conftest.dSYM
$(LIBRUBY_SO):
@-[ -n "$(EXTSTATIC)" ] || $(PRE_LIBRUBY_UPDATE)
$(ECHO) linking shared-library $@
$(Q) $(LDSHARED) $(DLDFLAGS) $(OBJS) $(DLDOBJS) $(SOLIBS) $(EXTSOLIBS) $(OUTFLAG)$@
- -$(Q) $(OBJCOPY) -w -L '$(SYMBOL_PREFIX)Init_*' -L '$(SYMBOL_PREFIX)ruby_static_id_*' \
+ -$(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_*' $@
$(Q) $(POSTLINK)
@-$(MINIRUBY) -e 'so, *aliases = ARGV; aliases.uniq!; aliases.delete(File.basename(so)); \
@@ -339,13 +357,46 @@ $(LIBRUBY_$(LIBRUBY_WITH_EXT)): $(LIBRUBY_SO_UPDATE)
PKG_CONFIG = @PKG_CONFIG@
ruby_pc = @ruby_pc@
$(ruby_pc): config.status Makefile
- $(Q)./config.status --file=-:$(srcdir)/template/ruby.pc.in | \
+ $(Q) \
+ pkg="$(@libdirname@)/pkgconfig" prefix="$(prefix)"; \
+ if [ "$(LIBRUBY_RELATIVE)" = yes ]; then \
+ case "$$pkg" in "$$prefix"/?*) \
+ pkg="$${pkg#$$prefix/}"; \
+ prefix='$${pcfiledir}'`echo "/$${pkg}" | sed -e 's|/[^/][^/]*|/..|g'`; \
+ esac; \
+ fi; \
+ ./config.status --file=-:$(srcdir)/template/ruby.pc.in | \
sed -e 's/\$$(\([A-Za-z_][A-Za-z0-9_]*\))/$${\1}/g' \
- -e 's|^prefix=.*|prefix=$(prefix)|' \
+ -e "s|^prefix=.*|prefix=$$prefix|" \
> ruby.tmp.pc
$(Q)pkg_config=${PKG_CONFIG} && PKG_CONFIG_PATH=. $${pkg_config:-:} --print-errors ruby.tmp
$(Q)$(MV) -f ruby.tmp.pc $(ruby_pc)
+test-pc: install-data
+ set -ex; \
+ [ -z "$${pkg_config=$(PKG_CONFIG)}" ] && exit; \
+ export PKG_CONFIG_PATH=$(DESTDIR)/$(libdir)/pkgconfig$${PKG_CONFIG_PATH:+:$$PKG_CONFIG_PATH}; \
+ $${pkg_config} --exists $(ruby_pc:.pc=); \
+ path=`$${pkg_config} --variable=prefix $(ruby_pc:.pc=)`; \
+ if [ "$(LIBRUBY_RELATIVE)" = yes ]; then \
+ test "$$path" -ef "$(DESTDIR)$(prefix)"; \
+ else \
+ test "$$path" = "$(prefix)"; \
+ fi
+
+install-data: pkgconfig-data pre-install-data do-install-data post-install-data
+pre-install-data:: install-prereq
+do-install-data: $(PREP) pre-install-data
+ $(INSTRUBY) --make="$(MAKE)" $(INSTRUBY_ARGS) --install=data
+post-install-data::
+ @$(NULLCMD)
+
+modular-gc-precheck:
+ $(Q) if test -z $(modular_gc_dir); then \
+ echo "You must configure with --with-modular-gc to use modular GC"; \
+ exit 1; \
+ fi
+
pre-install-local:: pkgconfig-data
ruby-runner.h: template/ruby-runner.h.in config.status
@@ -358,7 +409,7 @@ install-cross: $(arch)-fake.rb $(RBCONFIG) rbconfig.rb $(arch_hdrdir)/ruby/confi
$(Q) sed '/^\$$:\.unshift/q' $(arch)-fake.rb > fake.rb
$(Q) $(BASERUBY) -p \
-e '~/^\s*CONFIG\["LDFLAGS"\]/ and' \
- -e '$$_[/(?=\s*"$$)/] = %q[ #{(CONFIG["LIBPATHFLAG"]%File.dirname(__FILE__)).strip}]' \
+ -e '$$_[/(?=\s*"$$)/] = %q[ #{CONFIG["LIBPATHFLAG"]%File.dirname(__FILE__)}]' \
rbconfig.rb > fake-rbconfig.rb
$(INSTALL_SCRIPT) fake.rb $(XRUBY_RUBYLIBDIR)/$(arch)/fake.rb
$(INSTALL_SCRIPT) fake-rbconfig.rb $(XRUBY_RUBYLIBDIR)/$(arch)/rbconfig.rb
@@ -382,8 +433,8 @@ $(MKFILES): config.status $(srcdir)/version.h $(ABI_VERSION_HDR)
$(MAKE) -f conftest.mk | grep '^AUTO_REMAKE$$' >/dev/null 2>&1 || \
{ echo "$@ updated, restart."; exit 1; }
-uncommon.mk: $(srcdir)/common.mk
- sed 's/{\$$([^(){}]*)[^{}]*}//g' $< > $@
+uncommon.mk: $(srcdir)/tool/prereq.status
+ sed -f $(srcdir)/tool/prereq.status $(srcdir)/common.mk $(common_mk_includes) > $@
.PHONY: reconfig
reconfig-args = $(srcdir)/$(CONFIGURE) $(yes_silence:yes=--silent) $(configure_args)
@@ -418,7 +469,7 @@ lex.c: defs/keywords
$(CP) $(srcdir)/lex.c.blt $@; \
else \
[ $(Q) ] && echo generating $@ || set -x; \
- gperf -C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? \
+ gperf -C -L ANSI-C -P -p -j1 -i 1 -g -o -t -N rb_reserved_word -k1,3,$$ $? \
| sed -f $(tooldir)/gperf.sed \
> $@.tmp && \
$(MV) $@.tmp $@ && \
@@ -426,7 +477,7 @@ lex.c: defs/keywords
$(CP) $@ $(srcdir)/lex.c.blt; \
fi
-JIS_PROPS_OPTIONS = -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property
+JIS_PROPS_OPTIONS = -L ANSI-C -k1,3 -7 -c -j1 -i1 -t -C -P -t --ignore-case -H onig_jis_property_hash -Q onig_jis_property_pool -N onig_jis_property
$(srcdir)/enc/jis/props.h: enc/jis/props.kwd
$(MAKEDIRS) $(@D)
@@ -442,13 +493,19 @@ $(srcdir)/enc/jis/props.h: enc/jis/props.kwd
$(CP) $@ $(?:.kwd=.h.blt); \
fi
+gc_impl.$(OBJEXT): gc/$(BUILTIN_GC).c probes.h
+ @$(ECHO) compiling $(srcdir)/gc/$(BUILTIN_GC).c
+ $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(srcdir)/gc/$(BUILTIN_GC).c
+
.c.$(OBJEXT):
@$(ECHO) compiling $<
$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $<
+PREFIXED_SYMBOL = name
+_PREFIXED_SYMBOL = TOKEN_PASTE($(SYMBOL_PREFIX),name)
.$(ASMEXT).$(OBJEXT):
@$(ECHO) assembling $<
- $(Q) $(CC) $(ASFLAGS) -DSYMBOL_PREFIX=$(SYMBOL_PREFIX) -o $@ -c $<
+ $(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ "-DPREFIXED_SYMBOL(name)=$($(SYMBOL_PREFIX)PREFIXED_SYMBOL)" -c $<
.c.$(ASMEXT):
@$(ECHO) translating $<
@@ -460,7 +517,11 @@ $(srcdir)/enc/jis/props.h: enc/jis/props.kwd
.d.h:
@$(ECHO) translating probes $<
- $(Q) $(DTRACE) -o $@.tmp -h -C $(INCFLAGS) -s $<
+ $(Q) set x -o $@.tmp -h -C $(INCFLAGS); \
+ for flag in $(CPPFLAGS); do case $$flag in -[DU]*) set "$$@" "$$flag";; esac; done; \
+ shift; \
+ $(Q1:0=:) set -x; \
+ $(DTRACE) "$$@" -s $<
$(Q) sed -e 's/RUBY_/RUBY_DTRACE_/g' -e 's/PROBES_H_TMP/RUBY_PROBES_H/' -e 's/(char \*/(const char */g' -e 's/, char \*/, const char */g' $@.tmp > $@
$(Q) $(RM) $@.tmp
@@ -478,8 +539,9 @@ probes.stamp: $(DTRACE_REBUILD_OBJS)
probes.$(OBJEXT): $(srcdir)/probes.d $(DTRACE_REBUILD:yes=probes.stamp)
@$(ECHO) processing probes in object files
- $(Q) $(RM) $@
- $(Q) $(DTRACE) -G -C $(INCFLAGS) -s $(srcdir)/probes.d -o $@ $(DTRACE_REBUILD_OBJS)
+ @# n.b. the dtrace script looks at the $CFLAGS environment variable to decide
+ @# how to assemble probes.o; so we need to actually _export_ $(CFLAGS)
+ $(Q) CC="$(CC)" CFLAGS="$(CFLAGS) $(XCFLAGS) $(CPPFLAGS)" $(DTRACE) -G -C $(INCFLAGS) -s $(srcdir)/probes.d -o $@ $(DTRACE_REBUILD_OBJS)
# DTrace static library hacks described here:
# https://marc.info/?l=opensolaris-dtrace-discuss&m=114761203110734&w=4
@@ -493,8 +555,8 @@ clean-local::
enc/encinit.c enc/encinit.$(OBJEXT) $(pkgconfig_DATA) \
ruby-runner.$(OBJEXT) ruby-runner.h \
|| $(NULLCMD)
- $(Q)find . \( -name '*.bc' -o -name '*.[is]' \) -delete
- -$(Q)$(RMALL) exe/ *.dSYM
+ $(Q)find . ! -type d \( -name '*.bc' -o -name '*.[is]' \) -exec rm -f {} + || true
+
distclean-local::
$(Q)$(RM) \
@@ -517,9 +579,9 @@ ext/realclean:: ext/realclean.sub
.bundle/distclean:: .bundle/distclean.sub
.bundle/realclean:: .bundle/realclean.sub
-ext/clean.sub .bundle/clean.sub:: ext/clean.mk
-ext/distclean.sub .bundle/distclean.sub:: ext/distclean.mk
-ext/realclean.sub .bundle/realclean.sub:: ext/realclean.mk
+.bundle/clean.sub:: ext/clean.mk
+.bundle/distclean.sub:: ext/distclean.mk
+.bundle/realclean.sub:: ext/realclean.mk
ext/clean.sub ext/distclean.sub ext/realclean.sub \
.bundle/clean.sub .bundle/distclean.sub .bundle/realclean.sub::
@@ -545,6 +607,15 @@ ext/distclean ext/realclean .bundle/distclean .bundle/realclean::
find "$$@" -type d -empty -exec $(RMDIRS) {} + 2> /dev/null || true
$(Q) $(RMDIRS) $(@D) 2> /dev/null || true
+.bundle/realclean::
+ @$(RMALL) $(tooldir)/bunlder/*.lock $(srcdir)/.bundle
+
+gc/clean gc/distclean gc/realclean::
+ - $(CHDIR) gc 2> /dev/null && for gc in */; do ($(CHDIR) $$gc && exec $(MAKE) TARGET_SO_DIR=./ $(@F)); done || $(NULLCMD)
+
+gc/distclean gc/realclean::
+ - $(CHDIR) gc 2> /dev/null && for gc in */; do $(RMDIR) $$gc; done || $(NULLCMD)
+
clean-enc distclean-enc realclean-enc:
@test -f "$(ENC_MK)" || exit 0; \
echo $(@:-enc=ing) encodings; \
@@ -577,7 +648,16 @@ update-benchmark-driver:
$(BENCHMARK_DRIVER_GIT_URL) benchmark-driver $(GIT_OPTS)
update-known-errors:
- errno --list | cut -d' ' -f1 | sort -u - $(srcdir)/defs/known_errors.def | \
+ errno --list | \
+ $(BASERUBY) -nl -e 'BEGIN {errs = {}}' \
+ -e '/^(E[A-Z_0-9]+)(?: +(?:\d+ +)?(.+))?/ =~ $$_ && errs[$$1] ||= $$2' \
+ -e 'END {' \
+ -e 'errs.delete("ELAST")' \
+ -e 'errs = errs.sort' \
+ -e 'errs << ["ELAST", "Largest errno"]' \
+ -e 'errs.each {|e,d| puts sprintf("%-15s %s", e, d).strip}' \
+ -e '}' \
+ $(srcdir)/defs/known_errors.def - | \
$(IFCHANGE) $(srcdir)/defs/known_errors.def -
INSNS = optinsn.inc optunifs.inc insns.inc insns_info.inc \
@@ -595,13 +675,14 @@ $(INSNS): $(srcdir)/insns.def vm_opts.h \
$(tooldir)/ruby_vm/loaders/opt_operand_def.rb \
$(tooldir)/ruby_vm/loaders/vm_opts_h.rb \
$(tooldir)/ruby_vm/models/attribute.rb \
- $(tooldir)/ruby_vm/models/bare_instructions.rb \
+ $(tooldir)/ruby_vm/models/bare_instruction.rb \
$(tooldir)/ruby_vm/models/c_expr.rb \
$(tooldir)/ruby_vm/models/instructions.rb \
- $(tooldir)/ruby_vm/models/instructions_unifications.rb \
- $(tooldir)/ruby_vm/models/operands_unifications.rb \
- $(tooldir)/ruby_vm/models/trace_instructions.rb \
+ $(tooldir)/ruby_vm/models/instructions_unification.rb \
+ $(tooldir)/ruby_vm/models/operands_unification.rb \
+ $(tooldir)/ruby_vm/models/trace_instruction.rb \
$(tooldir)/ruby_vm/models/typemap.rb \
+ $(tooldir)/ruby_vm/models/zjit_instruction.rb \
$(tooldir)/ruby_vm/scripts/converter.rb \
$(tooldir)/ruby_vm/scripts/insns2vm.rb \
$(tooldir)/ruby_vm/views/_attributes.erb \
@@ -609,15 +690,16 @@ $(INSNS): $(srcdir)/insns.def vm_opts.h \
$(tooldir)/ruby_vm/views/_comptime_insn_stack_increase.erb \
$(tooldir)/ruby_vm/views/_copyright.erb \
$(tooldir)/ruby_vm/views/_insn_entry.erb \
+ $(tooldir)/ruby_vm/views/_insn_leaf_info.erb \
$(tooldir)/ruby_vm/views/_insn_len_info.erb \
$(tooldir)/ruby_vm/views/_insn_name_info.erb \
$(tooldir)/ruby_vm/views/_insn_operand_info.erb \
- $(tooldir)/ruby_vm/views/_insn_sp_pc_dependency.erb \
$(tooldir)/ruby_vm/views/_insn_type_chars.erb \
$(tooldir)/ruby_vm/views/_leaf_helpers.erb \
$(tooldir)/ruby_vm/views/_notice.erb \
$(tooldir)/ruby_vm/views/_sp_inc_helpers.erb \
$(tooldir)/ruby_vm/views/_trace_instruction.erb \
+ $(tooldir)/ruby_vm/views/_zjit_instruction.erb \
$(tooldir)/ruby_vm/views/insns.inc.erb \
$(tooldir)/ruby_vm/views/insns_info.inc.erb \
$(tooldir)/ruby_vm/views/optinsn.inc.erb \
@@ -637,9 +719,44 @@ un-runnable:
$(Q) exit 1
LIBRUBY_FOR_LEAKED_GLOBALS = $(enable_shared:no=)
-yes-test-basic: $(DOT_WAIT) leaked-globals
-leaked-globals: $(COMMONOBJS) prog $(tooldir)/leaked-globals
+yes-test-basic: $(DOT_WAIT) test-leaked-globals
+leaked-globals: test-leaked-globals
+yes-test-leaked-globals-precheck: $(COMMONOBJS) prog $(tooldir)/leaked-globals
+test-leaked-globals: yes-test-leaked-globals
+yes-test-leaked-globals: yes-test-leaked-globals-precheck
+ $(ACTIONS_GROUP)
$(Q) $(XRUBY) $(tooldir)/leaked-globals \
SOEXT=$(SOEXT) NM="$(NM) -Pgp" SYMBOL_PREFIX=$(SYMBOL_PREFIX) \
+ SYMBOLS_IN_EMPTYLIB="@XSYMBOLS_IN_EMPTYLIB@" \
+ EXTSTATIC="$(EXTSTATIC)" \
PLATFORM=$(hdrdir)/ruby/$(PLATFORM_DIR).h $(srcdir)/configure.ac \
$(COMMONOBJS) $(LIBRUBY_FOR_LEAKED_GLOBALS:yes=$(LIBRUBY_SO))
+ $(ACTIONS_ENDGROUP)
+
+test-syntax-suggest-precheck: $(TEST_RUNNABLE)-test-syntax-suggest-precheck
+no-test-syntax-suggest-precheck:
+yes-test-syntax-suggest-precheck: main
+
+test-syntax-suggest-prepare: $(TEST_RUNNABLE)-test-syntax-suggest-prepare
+no-test-syntax-suggest-prepare: no-test-syntax-suggest-precheck
+yes-test-syntax-suggest-prepare: yes-test-syntax-suggest-precheck
+ $(ACTIONS_GROUP)
+ $(XRUBY) -C "$(srcdir)" bin/gem install --no-document \
+ --install-dir .bundle --conservative "rspec:~> 3"
+ $(ACTIONS_ENDGROUP)
+
+RSPECOPTS =
+SYNTAX_SUGGEST_SPECS =
+PREPARE_SYNTAX_SUGGEST = $(TEST_RUNNABLE)-test-syntax-suggest-prepare
+test-syntax-suggest: $(TEST_RUNNABLE)-test-syntax-suggest
+yes-test-syntax-suggest: $(PREPARE_SYNTAX_SUGGEST)
+ $(ACTIONS_GROUP)
+ $(XRUBY) -C $(srcdir) -Ispec/syntax_suggest:spec/lib .bundle/bin/rspec \
+ --require rspec/expectations \
+ --require spec_helper --require formatter_overrides --require spec_coverage \
+ $(RSPECOPTS) spec/syntax_suggest/$(SYNTAX_SUGGEST_SPECS)
+ $(ACTIONS_ENDGROUP)
+no-test-syntax-suggest:
+
+yesterday:
+ $(GIT_IN_SRC) reset --hard `TZ=UTC-9 $(GIT_LOG_FORMAT)%H -1 --before=00:00`
diff --git a/template/builtin_binary.inc.tmpl b/template/builtin_binary.rbbin.tmpl
index 2c2f071705..df835bbbf9 100644
--- a/template/builtin_binary.inc.tmpl
+++ b/template/builtin_binary.rbbin.tmpl
@@ -1,23 +1,28 @@
// -*- c -*-
// DO NOT MODIFY THIS FILE DIRECTLY.
// auto-generated file by tool/generic_erb.rb
-// with template/builtin_binary.inc.tmpl
+// with template/builtin_binary.rbbin.tmpl
% unless ARGV.include?('--cross=yes')
% ary = RubyVM.enum_for(:each_builtin).to_a
% ary.each{|feature, iseq|
+% bin = iseq.to_binary
-static const unsigned char <%= feature %>_bin[] = {
-% iseq \
-% . to_binary \
+static const union {
+ unsigned char binary[<%= bin.bytesize %>];
+ uint32_t align_as_ibf_header;
+} <%= feature %>_builtin = {
+ .binary = {
+% bin \
% . each_byte \
% . each_slice(12) {|a|
- <%= a.map{ '0x%02x,' % _1 }.join(' ') %>
+ <%= a.map{ '0x%02x,' % _1 }.join(' ') %>
% }
+ }
};
% }
#define BUILTIN_BIN(feature) \
- { #feature, feature ## _bin, sizeof(feature ## _bin), }
+ { #feature, feature ## _builtin.binary, sizeof(feature ## _builtin.binary), }
static const struct builtin_binary builtin_binary[] = {
% ary.each{|feature, |
BUILTIN_BIN(<%= feature %>),
diff --git a/template/configure-ext.mk.tmpl b/template/configure-ext.mk.tmpl
index bc192a37ce..b4e999fe8e 100644
--- a/template/configure-ext.mk.tmpl
+++ b/template/configure-ext.mk.tmpl
@@ -7,25 +7,49 @@ ECHO = $(ECHO1:0=@echo)
<%
srcdir = miniruby = script_args = nil
+with_exts = []
+without_exts = []
opt = OptionParser.new do |o|
o.on('--srcdir=SRCDIR') {|v| srcdir = v}
o.on('--miniruby=MINIRUBY') {|v| miniruby = v}
o.on('--script-args=MINIRUBY') {|v| script_args = v}
+ o.on('--with-ext=ext[,...]', Array) {|v| with_exts.concat(v)}
+ o.on('--without-ext=ext[,...]', Array) {|v| without_exts.concat(v)}
o.order!(ARGV)
end
srcdir ||= File.dirname(File.dirname(__FILE__))
-exts = {}
-[
- ["exts", "ext", "--extstatic $(EXTSTATIC)"],
- ["gems", ".bundle/gems", "--no-extstatic"],
-].each do |t, d, o|
- exts[t] = [o, Dir.glob("#{srcdir}/#{d}/*/").map {|n| n[(srcdir.size+1)..-2]}]
+script_args ||= ""
+
+filter = proc do |ext|
+ next false unless with_exts.empty? or !with_exts.any? {|w| File.fnmatch?(w, ext)}
+ without_exts.empty? or !without_exts.any? {|w| File.fnmatch?(w, ext)}
end
+exts = {
+ exts: [
+ "--extstatic $(EXTSTATIC)",
+ Dir.glob("ext/**/extconf.rb", base: srcdir).filter_map do |d|
+ d if filter[File.basename(d = d[%r[\Aext/[^/]+]])]
+ end.uniq
+ ],
+ gems: [
+ "--no-extstatic",
+ Dir.glob(".bundle/gems/**/extconf.rb", base: srcdir).grep_v(/test/).filter_map do |d|
+ d if filter[File.basename(d = d[%r[\A\.bundle/gems/[^/]+]])]
+ end.uniq
+ ],
+}
%>
MINIRUBY = <%=miniruby%>
SCRIPT_ARGS = <%=script_args.gsub("#", "\\#").gsub(/\A|[\s"']\K--jobserver-auth=[^\s'"]*/, "")%>
EXTMK_ARGS = $(SCRIPT_ARGS) --gnumake=$(gnumake) --extflags="$(EXTLDFLAGS)" \
- --make-flags="MINIRUBY='$(MINIRUBY)'"
+ --make-flags="MINIRUBY='$(MINIRUBY)'" \
+<% unless with_exts.empty? -%>
+ --with-ext=<%= with_exts.join(',') %> \
+<% end -%>
+<% unless without_exts.empty? -%>
+ --without-ext=<%= without_exts.join(',') %> \
+<% end -%>
+ # EXTMK_ARGS
all: exts gems
exts:
@@ -33,7 +57,6 @@ gems:
% exts.each do |t, (o, dirs)|
% dirs.each do |d|
-% next if Dir.glob("#{srcdir}/#{d}/**/extconf.rb").empty?
<%=t%>: <%=d%>/exts.mk
<%=d%>/exts.mk: FORCE
$(Q)$(MINIRUBY) $(srcdir)/ext/extmk.rb --make='$(MAKE)' \
diff --git a/template/encdb.h.tmpl b/template/encdb.h.tmpl
index 8e658f7985..fe6af95747 100644
--- a/template/encdb.h.tmpl
+++ b/template/encdb.h.tmpl
@@ -33,35 +33,27 @@ encdirs << 'enc' if encdirs.empty?
files = {}
encdirs.each do |encdir|
next unless File.directory?(encdir)
- Dir.open(encdir) {|d| d.grep(/.+\.[ch]\z/)}.sort_by {|e|
+ Dir.glob("*.[ch]", base: encdir).sort_by {|e|
e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten
}.each do |fn|
next if files[fn]
files[fn] = true
- open(File.join(encdir,fn)) do |f|
+ File.open(File.join(encdir, fn)) do |f|
name = nil
- skip_ifndef_ruby = false
- encoding_def = false
f.each_line do |line|
- case line
- when /^#ifndef RUBY/
- skip_ifndef_ruby = true
- when /^#endif/
- skip_ifndef_ruby = false
- end
- next if skip_ifndef_ruby
- encoding_def = true if /^OnigEncodingDefine/ =~ line
- if encoding_def && /"(.*?)"/ =~ line
- encoding_def = false
- if name
- lines << %[ENC_SET_BASE("#$1", "#{name}");]
- else
- name = $1
+ if (/^#ifndef RUBY/ =~ line)..(/^#endif/ =~ line)
+ elsif /^OnigEncodingDefine/.match?(line)
+ if (n = f.gets("\n\};")[/"(.*?)"/, 1]) # swallow the initializer block
+ if name
+ lines << %[ENC_SET_BASE("#{n}", "#{name}");]
+ else
+ name = n
+ end
+ check_duplication(defs, n, fn, f.lineno)
+ next if BUILTIN_ENCODINGS[name]
+ encodings << n
+ count += 1
end
- check_duplication(defs, $1, fn, f.lineno)
- next if BUILTIN_ENCODINGS[name]
- encodings << $1
- count += 1
else
case line
when /^\s*rb_enc_register\(\s*"([^"]+)"/
diff --git a/template/extinit.c.tmpl b/template/extinit.c.tmpl
index 7a9c910633..e0b076b03c 100644
--- a/template/extinit.c.tmpl
+++ b/template/extinit.c.tmpl
@@ -1,5 +1,5 @@
%# -*- C -*-
-% extinits = ARGV.map {|n| [n[%r[[^/.]+(?=\.[^/]*)?\z]], n]}
+% extinits = ARGV.map {|n| [n.tr('/', '_'), n]}
#include "ruby/ruby.h"
#define init(func, name) { \
diff --git a/template/exts.mk.tmpl b/template/exts.mk.tmpl
index 29c29df37c..e482808f54 100644
--- a/template/exts.mk.tmpl
+++ b/template/exts.mk.tmpl
@@ -22,14 +22,19 @@ end
confexts &&= File.read(confexts).scan(/^(?:ext|gem)s: (.*\.mk)/).flatten rescue nil
confexts ||= []
macros["old_extensions"] = []
+distclean = []
contpat = /(?>(?>[^\\\n]|\\.)*\\\n)*(?>[^\\\n]|\\.)*/
Dir.glob("{ext,.bundle/gems}/*/exts.mk") do |e|
gem = e.start_with?(".bundle/gems/")
+ dir = File.dirname(e)
s = File.read(e)
s.scan(/^(extensions|SUBMAKEOPTS|EXT[A-Z]+|MFLAGS|MESSAGE_(?:BEGIN|END)|NOTE_[A-Z]+)[ \t]*=[ \t]*(#{contpat})$/o) do |n, v|
v.gsub!(/\\\n[ \t]*/, ' ')
- next if v.empty?
+ if v.empty?
+ distclean << dir if n == "extensions"
+ next
+ end
n = "old_extensions" if n == "extensions" and !confexts.include?(e)
v = v.split
m = macros[n] ||= []
@@ -69,6 +74,17 @@ Dir.glob("{ext,.bundle/gems}/*/exts.mk") do |e|
end
end
deps.uniq!
+macros["cleandirs"] = distclean.map {|d| "#{d}/."}
+deps.map! {|d|
+ /\A(?:dist|real)?clean(?=:)/ =~ d ? d + " $(cleandirs:/.=/#{$&})" : d
+}
+
+# NOTE: Only if extensions are configured as static and dynamic heterogeneously
+# (e.g. --with-static-linked-ext=foo or ext/Setup can mix static and dynamic
+# extensions), EXTOBJS may contain both extinit.o and dmyext.o. In such case,
+# prefer extinit.o, which does actual Init_${ext} function calls for statically
+# linked extensions, and drop dmyext.o, which does nothing but just to make the
+# linker happy.
if objs = macros["EXTOBJS"] and objs.any? {|e|e.start_with?("ext/extinit.")}
objs.delete_if {|e|e.start_with?("dmyext.")}
end
@@ -93,14 +109,15 @@ def self.column
@erbout[/^.*\z/].scan(/\t|([^\t]+)/) {|s,| w += (s ? s.size : 8 - w % 8)}
w
end
-targets = %w[all static install install-so install-rb clean distclean realclean]
objext = RbConfig::CONFIG["OBJEXT"]
+sep = RbConfig::CONFIG['BUILD_FILE_SEPARATOR']
+sep = nil if sep and sep.empty?
if gnumake
submake = "$(MAKE) -C $(@D)"
else
- submake = "cd $(@D) && "
- exec = RbConfig::CONFIG["exec"] and !exec.empty? and submake << exec << " "
- submake << "$(MAKE)"
+ submake = ["cd", (sep ? "$(@D:/=#{sep})" : "$(@D)"), "&&"]
+ exec = RbConfig::CONFIG["exec"] and !exec.empty? and submake << exec
+ submake = (submake << "$(MAKE)").join(" ")
mflags = " $(MFLAGS)"
end
-%>
@@ -138,24 +155,27 @@ ext/extinit.<%=objext%>:
% exts = (macros["extensions"] + macros["old_extensions"])
% exts.map! {|e|e.chomp("/.")}.sort
-% targets.each do |tgt|
+% %w[all static install install-so install-rb].each do |tgt|
% exts.each do |d|
-% t = "#{d}/#{tgt}"
-% if /^(dist|real)?clean$/ =~ tgt
-% deps = exts.select {|e|e.start_with?("#{d}/")}.map {|e|"#{e}/#{tgt}"}
-% pd = ' ' + deps.join(' ') unless deps.empty?
-% else
-% pext = File.dirname(d)
-% pd = " #{pext}/#{tgt}" if exts.include?(pext)
-% end
-<%=t%>:<%=pd%>
-% if /^(dist|real)clean$/ =~ tgt
+% pext = File.dirname(d)
+<%=d%>/<%=tgt%>:<% if exts.include?(pext) %> <%=pext%>/<%=tgt%><% end %>
+ $(Q)<%= submake %><%=mflags%> V=$(V) $(@F)
+% end
+% end
+% distclean = exts | distclean
+% %w[clean distclean realclean].each do |tgt|
+% distclean.each do |d|
+% deps = exts.select {|e|e.start_with?("#{d}/")}.map {|e|"#{e}/#{tgt}"}
+<%=d%>/<%=tgt%>:<% unless deps.empty? %> <%=deps.join(' ')%><% end %>
+% unless tgt == "clean"
$(ECHO) $(@F)ing $(@D)
% end
+% if exts.include?(d)
$(Q)<%= submake %><%=mflags%> V=$(V) $(@F)
-% if /^(dist|real)clean$/ =~ tgt
- $(Q)$(RM) <%=t[%r[\A(?:\.[^/]+/)?(?:[^/]+/){2}]]%>exts.mk
- $(Q)$(RMDIRS) $(@D)
+% end
+% unless tgt == "clean"
+ $(Q)$(RM) <%=d[%r[\A(?:\.[^/]+/)?(?:[^/]+/)?[^/]+]]%>/exts.mk
+ -$(Q)$(RMDIRS) $(@D)
% end
% end
% end
diff --git a/template/fake.rb.in b/template/fake.rb.in
index e7706a88ae..fed640aee7 100644
--- a/template/fake.rb.in
+++ b/template/fake.rb.in
@@ -9,6 +9,7 @@ while /\A(\w+)=(.*)/ =~ ARGV[0]
end
if inc = arg['i']
src = inc == '-' ? STDIN.read : File.read(inc)
+ src.tr!("\r", " ")
src.gsub!(/^#.*\n/, '')
else
src = ""
@@ -21,12 +22,11 @@ def src.value(name)
end
arg['versions'] = version = {}
File.read(File.join(arg['srcdir'], 'version.c')).
- scan(/rb_define_global_const\("(RUBY_\w+)",[^;]*?\bMK(?:INT|(STR))\(([^()]*)\)/m) do |n, s, v|
+ scan(/rb_define_(?:global_)?const\((mRuby, *)?"(?(1)|RUBY_)(\w+)",[^;]*?\bMK(?:INT|(STR))\(([^()]*)\)/m) do |_, n, s, v|
version[n] = arg[v] || src.value(v) || (s ? v : 0)
end
-arg['RUBY_DESCRIPTION_WITH_RJIT'] = src.value('description_with_rjit') || 'description_with_rjit'
-arg['RUBY_DESCRIPTION_WITH_YJIT'] = src.value('description_with_yjit') || 'description_with_yjit'
-%>baseruby="<%=arg['BASERUBY']%>"
+-%>
+baseruby="<%=arg['BASERUBY']%>"
_\
=begin
_=
@@ -39,19 +39,27 @@ exec $ruby "$r" "$@"
class Object
remove_const :CROSS_COMPILING if defined?(CROSS_COMPILING)
CROSS_COMPILING = RUBY_PLATFORM
+ options = remove_const(:RUBY_DESCRIPTION)[/( \+[^\[\]\+]+)*(?= \[\S+\]\z)/]
constants.grep(/^RUBY_/) {|n| remove_const n}
% arg['versions'].each {|n, v|
- <%=n%> = <%if n=='RUBY_DESCRIPTION' %>case
- when RubyVM.const_defined?(:RJIT) && RubyVM::RJIT.enabled?
- <%=arg['RUBY_DESCRIPTION_WITH_RJIT'].inspect%>
- when RubyVM.const_defined?(:YJIT) && RubyVM::YJIT.enabled?
- <%=arg['RUBY_DESCRIPTION_WITH_YJIT'].inspect%>
- else
- <%=v.inspect%>
- end<%else%><%=v.inspect%><%end%>
+ RUBY_<%=n%> = <%if n=='DESCRIPTION'
+ v1, v2 = v.split(/(?= \[\S+\]\z)/)
+ %><%=v1.dump.chomp('"')%>#{options}<%=
+ v2.dump[1..-1]%>.freeze<%
+ else%><%=v.inspect%><%end%>
+% }
+end
+v=$VERBOSE;$VERBOSE=nil;module Ruby; end;$VERBOSE=v
+module Ruby
+ constants.each {|n| remove_const n}
+% arg['versions'].each {|n, v|
+ <%=n%> = ::RUBY_<%=n%>
% }
end
builddir = File.dirname(File.expand_path(__FILE__))
+libpathenv = libpathenv = "<%=arg['LIBPATHENV']%>"
+preloadenv = preloadenv = "<%=arg['PRELOADENV']%>"
+libruby_so = libruby_so = "<%=arg['LIBRUBY_SO']%>"
srcdir = "<%=arg['srcdir']%>"
top_srcdir = File.realpath(srcdir, builddir)
fake = File.join(top_srcdir, "tool/fake.rb")
diff --git a/template/id.c.tmpl b/template/id.c.tmpl
index 5b9e879730..d40f143065 100644
--- a/template/id.c.tmpl
+++ b/template/id.c.tmpl
@@ -1,5 +1,5 @@
%# -*- c -*-
-/* DO NOT EDIT THIS FILE DIRECTLY */
+/* DO NOT EDIT THIS FILE DIRECTLY: source is at template/id.c.tmpl */
/**********************************************************************
id.c -
@@ -22,7 +22,8 @@ ops = ids[:token_op].uniq {|id, op, token| token && op}
static const struct {
unsigned short token;
- const char name[3], term;
+ RBIMPL_ATTR_NONSTRING() const char name[3];
+ const char term;
} op_tbl[] = {
% ops.each do |_id, op, token|
% next unless token
diff --git a/template/id.h.tmpl b/template/id.h.tmpl
index 4f7053885f..eb37e15073 100644
--- a/template/id.h.tmpl
+++ b/template/id.h.tmpl
@@ -1,5 +1,5 @@
%# -*- c -*-
-/* DO NOT EDIT THIS FILE DIRECTLY */
+/* DO NOT EDIT THIS FILE DIRECTLY: source is at template/id.h.tmpl */
/**********************************************************************
id.h -
@@ -19,15 +19,14 @@ types = ids.keys.grep(/^[A-Z]/)
#define RUBY_ID_H
enum ruby_id_types {
- RUBY_ID_STATIC_SYM = 0x01,
RUBY_ID_LOCAL = 0x00,
+ RUBY_ID_STATIC_SYM = 0x01,
RUBY_ID_INSTANCE = (0x01<<1),
RUBY_ID_GLOBAL = (0x03<<1),
RUBY_ID_ATTRSET = (0x04<<1),
RUBY_ID_CONST = (0x05<<1),
RUBY_ID_CLASS = (0x06<<1),
- RUBY_ID_JUNK = (0x07<<1),
- RUBY_ID_INTERNAL = RUBY_ID_JUNK,
+ RUBY_ID_INTERNAL = (0x07<<1),
RUBY_ID_SCOPE_SHIFT = 4,
RUBY_ID_SCOPE_MASK = (~(~0U<<(RUBY_ID_SCOPE_SHIFT-1))<<1)
};
@@ -41,7 +40,6 @@ enum ruby_id_types {
#define ID_ATTRSET RUBY_ID_ATTRSET
#define ID_CONST RUBY_ID_CONST
#define ID_CLASS RUBY_ID_CLASS
-#define ID_JUNK RUBY_ID_JUNK
#define ID_INTERNAL RUBY_ID_INTERNAL
#define symIFUNC ID2SYM(idIFUNC)
diff --git a/template/known_errors.inc.tmpl b/template/known_errors.inc.tmpl
index c3aee77477..4d453395ca 100644
--- a/template/known_errors.inc.tmpl
+++ b/template/known_errors.inc.tmpl
@@ -4,8 +4,12 @@
* template/known_errors.inc.tmpl and defs/known_errors.def.
*/
-% error_names = ARGF.read.split(/\s+/)
-% error_names.each do |name|
+% error_names = ARGF.readlines.map {|line| [$1, $2] if /\A([A-Z]\S+)(?:\s+(\S.*))?/ =~ line}.compact
+% error_names.each do |name, doc|
+#if 0
+ /* <% if doc %>"<%= doc %>"<% else %>\<%= name %><% end %> error */
+ rb_define_const(rb_mErrno, "<%=name%>", e<%=name%>);
+#endif
#ifdef <%=name%>
defined_error("<%=name%>", <%=name%>)
#else
diff --git a/template/limits.c.tmpl b/template/limits.c.tmpl
index de35354829..f7867ded9a 100644
--- a/template/limits.c.tmpl
+++ b/template/limits.c.tmpl
@@ -51,11 +51,26 @@
# include <float.h>
#endif
+/*
+ * Document-const: LIMITS
+ *
+ * A Hash with the bounds of numeric types available to the \C compiler
+ * used to build Ruby. To access this constant, first run
+ * <code>require 'rbconfig/sizeof'</code>.
+ *
+ * require 'rbconfig/sizeof'
+ * RUBY_PLATFORM # => "x64-mingw-ucrt"
+ * RbConfig::LIMITS.fetch_values('FIXNUM_MAX', 'LONG_MAX')
+ * # => [1073741823, 2147483647]
+ *
+ */
+
void
Init_limits(void)
{
VALUE h = rb_hash_new();
- rb_define_const(rb_define_module("RbConfig"), "LIMITS", h);
+ VALUE mRbConfig = rb_define_module("RbConfig");
+ rb_define_const(mRbConfig, "LIMITS", h);
#ifdef HAVE_LONG_LONG
#ifndef ULLONG_MAX
@@ -67,7 +82,7 @@ Init_limits(void)
#define MAX2NUM(name) ULONG2NUM(name ## _MAX)
#define MIN2NUM(name) LONG2NUM(name ## _MIN)
#endif
-#define DEFINE(k, v) rb_hash_aset(h, rb_str_new_cstr(#k), v)
+#define DEFINE(k, v) rb_hash_aset(h, rb_usascii_str_new_lit(#k), v)
% limits.each do |type|
#ifdef <%= type %>_MAX
diff --git a/template/prelude.c.tmpl b/template/prelude.c.tmpl
index aa8b0c1fef..04f65ec5e3 100644
--- a/template/prelude.c.tmpl
+++ b/template/prelude.c.tmpl
@@ -21,16 +21,11 @@ class Prelude
def initialize(output, preludes, vpath)
@output = output
@vpath = vpath
- @prelude_count = 0
@builtin_count = 0
@preludes = {}
@mains = preludes.map do |filename|
- if prelude = filename.end_with?("golf_prelude.rb")
- @prelude_count += 1
- else
- @builtin_count += 1
- end
- translate(filename, (filename unless prelude))[0]
+ @builtin_count += 1
+ translate(filename, filename)[0]
end
@preludes.delete_if {|_, (_, _, lines, sub)| sub && lines.empty?}
end
@@ -43,7 +38,10 @@ class Prelude
lineno = 0
result = [@preludes.size, @vpath.strip(filename), lines, sub]
@vpath.foreach(filename) do |line|
- line.force_encoding("ASCII-8BIT") if line.respond_to?(:force_encoding)
+ if line.respond_to?(:force_encoding)
+ enc = line.encoding
+ line.force_encoding("ASCII-8BIT")
+ end
line.rstrip!
lineno += 1
@preludes[filename] ||= result
@@ -55,7 +53,7 @@ class Prelude
if line.size > LINE_LIMIT
raise "#{filename}:#{lines.size+1}: too long line"
end
- line.sub!(/require(_relative)?\s*\(?\s*(["'])(.*?)(?:\.rb)?\2\)?/) do
+ line.sub!(/require(_relative)?\s*\(?\s*([\"\'])(.*?)(?:\.rb)?\2\)?/) do
orig, rel, path = $&, $2, $3
if rel
path = File.join(File.dirname(filename), path)
@@ -71,6 +69,7 @@ class Prelude
orig
end
end
+ comment.force_encoding(enc) if enc and comment
lines << [line, comment]
end
result << (start_line || 1)
@@ -89,6 +88,7 @@ Prelude.new(output, ARGV, vpath).instance_eval do
#include "internal/ruby_parser.h"
#include "internal/warnings.h"
#include "iseq.h"
+#include "ruby/internal/attr/nonstring.h"
#include "ruby/ruby.h"
#include "vm_core.h"
@@ -108,12 +108,12 @@ static const struct {
% size += line.size
% next
% end
- char L<%=beg%><%=%>[<%=size%><%=%>]; /* <%=beg+1%>..<%=n%> */
+ RBIMPL_ATTR_NONSTRING() char L<%=beg%><%=%>[<%=size%><%=%>]; /* <%=beg+1%>..<%=n%> */
% size = line.size
% beg = n
% }
% if size > 0
- char L<%=beg%><%=%>[<%=size%><%=%>]; /* <%=beg+1%>..<%=lines.size+1%> */
+ RBIMPL_ATTR_NONSTRING() char L<%=beg%><%=%>[<%=size%><%=%>]; /* <%=beg+1%>..<%=lines.size+1%> */
% end
} prelude_code<%=i%><%=%> = {
% size = 0
@@ -133,89 +133,38 @@ static const struct {
COMPILER_WARNING_POP
-% unless preludes.empty?
#define PRELUDE_NAME(n) rb_usascii_str_new_static(prelude_name##n, sizeof(prelude_name##n)-1)
#define PRELUDE_CODE(n) rb_utf8_str_new_static(prelude_code##n.L0, sizeof(prelude_code##n))
-static rb_ast_t *
-prelude_ast(VALUE name, VALUE code, int line)
-{
- rb_ast_t *ast = rb_parser_compile_string_path(rb_parser_new(), name, code, line);
- if (!ast || !ast->body.root) {
- if (ast) rb_ast_dispose(ast);
- rb_exc_raise(rb_errinfo());
- }
- return ast;
-}
-
% end
% if @builtin_count > 0
-#define PRELUDE_AST(n, name_str, start_line) \
+#define PRELUDE_MATCH(n) \
(((sizeof(prelude_name<%='##'%><%=%>n) - prefix_len - 2) == namelen) && \
- (strncmp(prelude_name<%='##'%><%=%>n + prefix_len, feature_name, namelen) == 0) ? \
- prelude_ast((name_str) = PRELUDE_NAME(n), PRELUDE_CODE(n), start_line) : 0)
+ (strncmp(prelude_name<%='##'%><%=%>n + prefix_len, feature_name, namelen) == 0))
-rb_ast_t *
-rb_builtin_ast(const char *feature_name, VALUE *name_str)
+VALUE
+rb_builtin_find(const char *feature_name, VALUE *name_str, int *start_line)
{
const size_t prefix_len = rb_strlen_lit("<internal:");
size_t namelen = strlen(feature_name);
- rb_ast_t *ast = 0;
+
+#define PRELUDE_FOUND(n, l) \
+ (*name_str = PRELUDE_NAME(n), *start_line = (l), PRELUDE_CODE(n))
% @preludes.each_value do |i, prelude, lines, sub, start_line|
% if sub
- if ((ast = PRELUDE_AST(<%=i%><%=%>, *name_str, <%=start_line%>)) != 0) return ast;
+ if (PRELUDE_MATCH(<%=i%>)) return PRELUDE_FOUND(<%=i%>, <%=start_line%>);
% end
% end
- return ast;
-}
+#undef PRELUDE_FOUND
-% end
-% if @prelude_count > 0
-COMPILER_WARNING_PUSH
-#if GCC_VERSION_SINCE(4, 2, 0)
-COMPILER_WARNING_ERROR(-Wmissing-field-initializers)
-#endif
-static void
-prelude_eval(VALUE code, VALUE name, int line)
-{
- static const rb_compile_option_t optimization = {
- TRUE, /* unsigned int inline_const_cache; */
- TRUE, /* unsigned int peephole_optimization; */
- FALSE,/* unsigned int tailcall_optimization; */
- TRUE, /* unsigned int specialized_instruction; */
- TRUE, /* unsigned int operands_unification; */
- TRUE, /* unsigned int instructions_unification; */
- TRUE, /* unsigned int frozen_string_literal; */
- FALSE, /* unsigned int debug_frozen_string_literal; */
- FALSE, /* unsigned int coverage_enabled; */
- 0, /* int debug_level; */
- };
-
- rb_ast_t *ast = prelude_ast(name, code, line);
- rb_iseq_eval(rb_iseq_new_with_opt(&ast->body, name, name, Qnil, line,
- NULL, 0, ISEQ_TYPE_TOP, &optimization));
- rb_ast_dispose(ast);
+ return Qnil;
}
-COMPILER_WARNING_POP
-% end
%end
% init_name = @output && @output[/\w+(?=_prelude.c\b)/] || 'prelude'
void
Init_<%=init_name%><%=%>(void)
{
-%unless @prelude_count.zero?
-% preludes.each do |i, prelude, lines, sub, start_line|
-% next if sub
- prelude_eval(PRELUDE_CODE(<%=i%><%=%>), PRELUDE_NAME(<%=i%><%=%>), <%=start_line%><%=%>);
-% end
-
-#if 0
-% preludes.length.times {|i|
- printf("%.*s", (int)sizeof(prelude_code<%=i%><%=%>), prelude_code<%=i%><%=%>.L0);
-% }
-#endif
-%end
}
<%end -%>
diff --git a/template/ruby-runner.h.in b/template/ruby-runner.h.in
index fdfe88dcb9..b94086c565 100644
--- a/template/ruby-runner.h.in
+++ b/template/ruby-runner.h.in
@@ -1,9 +1,7 @@
#define ABS_SRCDIR "@abs_srcdir@"
#define BUILDDIR "@abs_top_builddir@"
#define LIBPATHENV "@LIBPATHENV@"
-#define PRELOADENV "@PRELOADENV@"
#define PATH_SEPARATOR "@PATH_SEPARATOR@"
#define PATH_SEP '@PATH_SEPARATOR@'
#define EXTOUT "@EXTOUT@"
#define ARCH "@arch@"
-#define SOEXT "@SOEXT@"
diff --git a/template/sizes.c.tmpl b/template/sizes.c.tmpl
index 31060f5fea..abc3b5c908 100644
--- a/template/sizes.c.tmpl
+++ b/template/sizes.c.tmpl
@@ -25,15 +25,30 @@ conditions = {
#endif
% end
+
+/*
+ * Document-const: SIZEOF
+ *
+ * A Hash with the byte size of \C types available to the compiler
+ * used to build Ruby. To access this constant, first run
+ * <code>require 'rbconfig/sizeof'</code>.
+ *
+ * require 'rbconfig/sizeof'
+ * RUBY_PLATFORM # => "x64-mingw-ucrt"
+ * RbConfig::SIZEOF.fetch_values('long', 'void*') # => [4, 8]
+ *
+ */
+
extern void Init_limits(void);
void
Init_sizeof(void)
{
VALUE s = rb_hash_new();
- rb_define_const(rb_define_module("RbConfig"), "SIZEOF", s);
+ VALUE mRbConfig = rb_define_module("RbConfig");
+ rb_define_const(mRbConfig, "SIZEOF", s);
-#define DEFINE(type, size) rb_hash_aset(s, rb_str_new_cstr(#type), INT2FIX(SIZEOF_##size))
-#define DEFINE_SIZE(type) rb_hash_aset(s, rb_str_new_cstr(#type), INT2FIX(sizeof(type)))
+#define DEFINE(type, size) rb_hash_aset(s, rb_usascii_str_new_lit(#type), INT2FIX(SIZEOF_##size))
+#define DEFINE_SIZE(type) rb_hash_aset(s, rb_usascii_str_new_lit(#type), INT2FIX(sizeof(type)))
% types.each do |type|
% if sizes[type]
diff --git a/template/transdb.h.tmpl b/template/transdb.h.tmpl
index 990a8639d0..22b5960cd8 100644
--- a/template/transdb.h.tmpl
+++ b/template/transdb.h.tmpl
@@ -1,4 +1,4 @@
-<%
+<% #-*- mode: ruby -*-
#
# static const rb_transcoder
# rb_from_US_ASCII = {
@@ -22,39 +22,34 @@ transdirs = transdirs.sort_by {|td|
files = {}
names_t = []
-converter_list = []
transdirs.each do |transdir|
names = Dir.entries(transdir)
- names_t += names.map {|n| /(?!\A)\.trans\z/ =~ n ? $` : nil }.compact
- names_c = names.map {|n| /(?!\A)\.c\z/ =~ n ? $` : nil }.compact
- (names_t & names_c).map {|n|
- "#{n}.c"
- }.sort_by {|e|
+ names_t += names.map {|n| n[/.+(?=\.trans\z)/]}.compact
+ names_c = names.map {|n| n[/.+(?=\.c\z)/]}.compact
+ (names_t & names_c).sort_by {|e|
e.scan(/(\d+)|(\D+)/).map {|n,a| a||[n.size,n.to_i]}.flatten
}.each do |fn|
next if files[fn]
files[fn] = true
- path = File.join(transdir,fn)
- open(path) do |f|
- transcoder_def = false
+ path = File.join(transdir, "#{fn}.c")
+ File.open(path) do |f|
f.each_line do |line|
- transcoder_def = true if /^static const rb_transcoder/ =~ line
- if transcoder_def && /"(.*?)"\s*,\s*"(.*?)"/ =~ line
- transcoder_def = false
- from_to = "%s to %s" % [$1, $2]
- if converters[from_to]
- raise ArgumentError, '%s:%d: transcode "%s" is already registered at %s:%d' %
- [path, f.lineno, from_to, *converters[from_to].values_at(3, 4)]
- else
- converters[from_to] = [$1, $2, fn[0..-3], path, f.lineno]
- converter_list << from_to
+ if (/^static const rb_transcoder/ =~ line)
+ if (/"(.*?)"\s*,\s*"(.*?)"/ =~ f.gets("\n\};")) # swallow the initializer block
+ from_to = [$1.freeze, $2.freeze].freeze
+ if converters[from_to]
+ raise ArgumentError,
+ '%s:%d: transcode "%s to %s" is already registered at %s:%d' %
+ [path, f.lineno, *from_to, *converters[from_to].values_at(3, 4)]
+ else
+ converters[from_to] = [fn, path, f.lineno]
+ end
end
end
end
end
end
end
-converter_list.each do |from_to|
- from, to, fn = *converters[from_to]
+converters.each do |(from, to), (fn)|
%>rb_declare_transcoder("<%=from%>", "<%=to%>", "<%=fn%>");
% end
diff --git a/template/unicode_norm_gen.tmpl b/template/unicode_norm_gen.tmpl
index a16712fbac..773a727cec 100644
--- a/template/unicode_norm_gen.tmpl
+++ b/template/unicode_norm_gen.tmpl
@@ -22,23 +22,6 @@ class Integer
end
end
-module Enumerable
- unless method_defined?(:each_slice)
- def each_slice(n)
- ary = []
- each do |i|
- ary << i
- if ary.size >= n
- yield ary
- ary = []
- end
- end
- yield ary unless ary.empty?
- self
- end
- end
-end
-
class Array
def to_UTF8() collect {|c| c.to_UTF8}.join('') end
@@ -112,6 +95,17 @@ accent_array = combining_class.keys + composition_table.keys.collect {|key| key.
composition_starters = composition_table.keys.collect {|key| key.first}
+# Special treatment for Unicode 16.0.0
+# Add characters that can be decomposed (even indirectly) so that
+# the first character in the decomposition is a an accent to accents.
+# We do this here up to two levels deep.
+# In the future, there may be even deeper levels.
+starter_accents = composition_starters & accent_array
+decomposition_table.each do |k, v|
+ accent_array << k if starter_accents.include? v.first
+ accent_array << k if starter_accents.include? decomposition_table[v.first]&.first
+end
+
hangul_no_trailing = []
0xAC00.step(0xD7A3, 28) {|c| hangul_no_trailing << c}
@@ -155,6 +149,9 @@ end
# frozen_string_literal: true
%# >
+Encoding::UNICODE_VERSION == <%= unicode_version.dump %><%=%> or
+ raise "Unicode version mismatch: <%= unicode_version %> expected but #{Encoding::UNICODE_VERSION}"
+
# automatically generated by template/unicode_norm_gen.tmpl
module UnicodeNormalize # :nodoc:
@@ -202,19 +199,19 @@ module UnicodeNormalize # :nodoc:
DECOMPOSITION_TABLE = {
% decomposition_table.each do |key, value|
- "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,
+ "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>",
% end
}.freeze
KOMPATIBLE_TABLE = {
% kompatible_table.each do |key, value|
- "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,
+ "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>",
% end
}.freeze
COMPOSITION_TABLE = {
% composition_table.each do |key, value|
- "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>"<%=%>,
+ "<%=key.to_UTF8%>"=>"<%=value.to_UTF8%>",
% end
}.freeze
end