Skip to content

Commit

Permalink
patch 8.2.3922: cannot build with dynamic Ruby 3.1
Browse files Browse the repository at this point in the history
Problem:    Cannot build with dynamic Ruby 3.1.
Solution:   Add "_EXTRA" variables for CI.  Add missing functions. (Ozaki
            Kiichi, closes #9420)
  • Loading branch information
ichizok authored and brammool committed Dec 28, 2021
1 parent d9da86e commit 8bb3fe4
Show file tree
Hide file tree
Showing 10 changed files with 98 additions and 31 deletions.
4 changes: 2 additions & 2 deletions ci/config.mk.clang-12.sed
@@ -1,3 +1,3 @@
# Clang 12 (or Apple clang 13) and later makes a warning '-Wcompound-token-split-by-macro' enable by default.
/^PERL_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=compound-token-split-by-macro/
/^RUBY_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=compound-token-split-by-macro/
/^PERL_CFLAGS_EXTRA[[:blank:]]*=/s/$/ -Wno-error=compound-token-split-by-macro/
/^RUBY_CFLAGS_EXTRA[[:blank:]]*=/s/$/ -Wno-error=compound-token-split-by-macro/
2 changes: 1 addition & 1 deletion ci/config.mk.clang.sed
@@ -1,2 +1,2 @@
/^CFLAGS[[:blank:]]*=/s/$/ -Wno-error=missing-field-initializers/
/^RUBY_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=unknown-attributes -Wno-error=ignored-attributes/
/^RUBY_CFLAGS_EXTRA[[:blank:]]*=/s/$/ -Wno-error=unknown-attributes -Wno-error=ignored-attributes/
3 changes: 2 additions & 1 deletion ci/config.mk.sed
@@ -1,2 +1,3 @@
/^CFLAGS[[:blank:]]*=/s/$/ -Wall -Wextra -Wshadow -Werror/
/^PERL_CFLAGS[[:blank:]]*=/s/$/ -Wno-error=unused-function/
/^PERL_CFLAGS_EXTRA[[:blank:]]*=/s/$/ -Wno-error=unused-function/
/^RUBY_CFLAGS_EXTRA[[:blank:]]*=/s/$/ -Wno-error=unused-parameter/
25 changes: 13 additions & 12 deletions src/Makefile
Expand Up @@ -1491,13 +1491,14 @@ POST_DEFS = $(X_CFLAGS) $(MZSCHEME_CFLAGS) $(EXTRA_DEFS)

ALL_CFLAGS = $(PRE_DEFS) $(CFLAGS) $(PROFILE_CFLAGS) $(SANITIZER_CFLAGS) $(LEAK_CFLAGS) $(ABORT_CFLAGS) $(POST_DEFS)

ALL_IF_CFLAGS = $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(PYTHON3_CFLAGS) $(RUBY_CFLAGS) $(TCL_CFLAGS)
ALL_IF_CFLAGS_EXTRA = $(LUA_CFLAGS_EXTRA) $(PERL_CFLAGS_EXTRA) $(PYTHON_CFLAGS_EXTRA) $(PYTHON3_CFLAGS_EXTRA) $(RUBY_CFLAGS_EXTRA) $(TCL_CFLAGS_EXTRA)

# Exclude $CFLAGS for osdef.sh, for Mac 10.4 some flags don't work together
# with "-E".
OSDEF_CFLAGS = $(PRE_DEFS) $(POST_DEFS)

LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) \
$(RUBY_CFLAGS) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) \
$(PYTHON3_CFLAGS) $(TCL_CFLAGS) $(VTERM_CFLAGS) \
LINT_CFLAGS = -DLINT -I. $(PRE_DEFS) $(POST_DEFS) $(ALL_IF_CFLAGS) $(VTERM_CFLAGS) \
-Dinline= -D__extension__= -Dalloca=alloca

LINT_EXTRA = -D"__attribute__(x)="
Expand Down Expand Up @@ -3357,7 +3358,7 @@ objects/if_xcmdsrv.o: if_xcmdsrv.c
$(CCC) -o $@ if_xcmdsrv.c

objects/if_lua.o: if_lua.c
$(CCC_NF) $(LUA_CFLAGS) $(ALL_CFLAGS) -o $@ if_lua.c
$(CCC_NF) $(LUA_CFLAGS) $(ALL_CFLAGS) $(LUA_CFLAGS_EXTRA) -o $@ if_lua.c

objects/if_mzsch.o: if_mzsch.c $(MZSCHEME_EXTRA)
$(CCC) -o $@ $(MZSCHEME_CFLAGS_EXTRA) if_mzsch.c
Expand All @@ -3366,22 +3367,22 @@ mzscheme_base.c:
$(MZSCHEME_MZC) --c-mods mzscheme_base.c ++lib scheme/base

objects/if_perl.o: auto/if_perl.c
$(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) -o $@ auto/if_perl.c
$(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) $(PERL_CFLAGS_EXTRA) -o $@ auto/if_perl.c

objects/if_perlsfio.o: if_perlsfio.c
$(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) -o $@ if_perlsfio.c
$(CCC_NF) $(PERL_CFLAGS) $(ALL_CFLAGS) $(PERL_CFLAGS_EXTRA) -o $@ if_perlsfio.c

objects/if_python.o: if_python.c if_py_both.h
$(CCC_NF) $(PYTHON_CFLAGS) $(PYTHON_CFLAGS_EXTRA) $(ALL_CFLAGS) -o $@ if_python.c
$(CCC_NF) $(PYTHON_CFLAGS) $(ALL_CFLAGS) $(PYTHON_CFLAGS_EXTRA) -o $@ if_python.c

objects/if_python3.o: if_python3.c if_py_both.h
$(CCC_NF) $(PYTHON3_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) $(ALL_CFLAGS) -o $@ if_python3.c
$(CCC_NF) $(PYTHON3_CFLAGS) $(ALL_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) -o $@ if_python3.c

objects/if_ruby.o: if_ruby.c
$(CCC_NF) $(RUBY_CFLAGS) $(ALL_CFLAGS) -o $@ if_ruby.c
$(CCC_NF) $(RUBY_CFLAGS) $(ALL_CFLAGS) $(RUBY_CFLAGS_EXTRA) -o $@ if_ruby.c

objects/if_tcl.o: if_tcl.c
$(CCC_NF) $(TCL_CFLAGS) $(ALL_CFLAGS) -o $@ if_tcl.c
$(CCC_NF) $(TCL_CFLAGS) $(ALL_CFLAGS) $(TCL_CFLAGS_EXTRA) -o $@ if_tcl.c

objects/indent.o: indent.c
$(CCC) -o $@ indent.c
Expand Down Expand Up @@ -3459,10 +3460,10 @@ objects/ops.o: ops.c
$(CCC) -o $@ ops.c

objects/option.o: option.c optiondefs.h
$(CCC_NF) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(PYTHON3_CFLAGS) $(RUBY_CFLAGS) $(TCL_CFLAGS) $(ALL_CFLAGS) -o $@ option.c
$(CCC_NF) $(ALL_IF_CFLAGS) $(ALL_CFLAGS) $(ALL_IF_CFLAGS_EXTRA) -o $@ option.c

objects/optionstr.o: optionstr.c
$(CCC_NF) $(LUA_CFLAGS) $(PERL_CFLAGS) $(PYTHON_CFLAGS) $(PYTHON3_CFLAGS) $(RUBY_CFLAGS) $(TCL_CFLAGS) $(ALL_CFLAGS) -o $@ optionstr.c
$(CCC_NF) $(ALL_IF_CFLAGS) $(ALL_CFLAGS) $(ALL_IF_CFLAGS_EXTRA) -o $@ optionstr.c

objects/os_qnx.o: os_qnx.c $(VIM_H_DEPENDENCIES)
$(CCC) -o $@ os_qnx.c
Expand Down
12 changes: 12 additions & 0 deletions src/auto/configure
Expand Up @@ -662,28 +662,33 @@ CHANNEL_SRC
NETBEANS_OBJ
NETBEANS_SRC
RUBY_LIBS
RUBY_CFLAGS_EXTRA
RUBY_CFLAGS
RUBY_PRO
RUBY_OBJ
RUBY_SRC
vi_cv_path_ruby
TCL_LIBS
TCL_CFLAGS_EXTRA
TCL_CFLAGS
TCL_PRO
TCL_OBJ
TCL_SRC
vi_cv_path_tcl
PYTHON3_OBJ
PYTHON3_SRC
PYTHON3_CFLAGS_EXTRA
PYTHON3_CFLAGS
PYTHON3_LIBS
vi_cv_path_python3
PYTHON_OBJ
PYTHON_SRC
PYTHON_CFLAGS_EXTRA
PYTHON_CFLAGS
PYTHON_LIBS
vi_cv_path_python
PERL_LIBS
PERL_CFLAGS_EXTRA
PERL_CFLAGS
PERL_PRO
PERL_OBJ
Expand All @@ -700,6 +705,7 @@ MZSCHEME_PRO
MZSCHEME_OBJ
MZSCHEME_SRC
vi_cv_path_mzscheme
LUA_CFLAGS_EXTRA
LUA_CFLAGS
LUA_LIBS
LUA_PRO
Expand Down Expand Up @@ -5658,6 +5664,7 @@ $as_echo "yes" >&6; }




fi


Expand Down Expand Up @@ -6273,6 +6280,7 @@ fi




{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-pythoninterp argument" >&5
$as_echo_n "checking --enable-pythoninterp argument... " >&6; }
# Check whether --enable-pythoninterp was given.
Expand Down Expand Up @@ -6623,6 +6631,7 @@ fi




{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-python3interp argument" >&5
$as_echo_n "checking --enable-python3interp argument... " >&6; }
# Check whether --enable-python3interp was given.
Expand Down Expand Up @@ -6969,6 +6978,7 @@ fi




if test "$python_ok" = yes && test "$python3_ok" = yes; then
$as_echo "#define DYNAMIC_PYTHON 1" >>confdefs.h

Expand Down Expand Up @@ -7549,6 +7559,7 @@ fi




{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-rubyinterp argument" >&5
$as_echo_n "checking --enable-rubyinterp argument... " >&6; }
# Check whether --enable-rubyinterp was given.
Expand Down Expand Up @@ -7712,6 +7723,7 @@ fi




{ $as_echo "$as_me:${as_lineno-$LINENO}: checking --enable-cscope argument" >&5
$as_echo_n "checking --enable-cscope argument... " >&6; }
# Check whether --enable-cscope was given.
Expand Down
6 changes: 6 additions & 0 deletions src/config.mk.in
Expand Up @@ -41,6 +41,7 @@ LUA_LIBS = @LUA_LIBS@
LUA_SRC = @LUA_SRC@
LUA_OBJ = @LUA_OBJ@
LUA_CFLAGS = @LUA_CFLAGS@
LUA_CFLAGS_EXTRA = @LUA_CFLAGS_EXTRA@
LUA_PRO = @LUA_PRO@

MZSCHEME_LIBS = @MZSCHEME_LIBS@
Expand All @@ -60,22 +61,26 @@ PERL_SRC = @PERL_SRC@
PERL_OBJ = @PERL_OBJ@
PERL_PRO = @PERL_PRO@
PERL_CFLAGS = @PERL_CFLAGS@
PERL_CFLAGS_EXTRA = @PERL_CFLAGS_EXTRA@

PYTHON_SRC = @PYTHON_SRC@
PYTHON_OBJ = @PYTHON_OBJ@
PYTHON_CFLAGS = @PYTHON_CFLAGS@
PYTHON_CFLAGS_EXTRA = @PYTHON_CFLAGS_EXTRA@
PYTHON_LIBS = @PYTHON_LIBS@

PYTHON3_SRC = @PYTHON3_SRC@
PYTHON3_OBJ = @PYTHON3_OBJ@
PYTHON3_CFLAGS = @PYTHON3_CFLAGS@
PYTHON3_CFLAGS_EXTRA = @PYTHON3_CFLAGS_EXTRA@
PYTHON3_LIBS = @PYTHON3_LIBS@

TCL = @vi_cv_path_tcl@
TCL_SRC = @TCL_SRC@
TCL_OBJ = @TCL_OBJ@
TCL_PRO = @TCL_PRO@
TCL_CFLAGS = @TCL_CFLAGS@
TCL_CFLAGS_EXTRA = @TCL_CFLAGS_EXTRA@
TCL_LIBS = @TCL_LIBS@

NETBEANS_SRC = @NETBEANS_SRC@
Expand All @@ -91,6 +96,7 @@ RUBY_SRC = @RUBY_SRC@
RUBY_OBJ = @RUBY_OBJ@
RUBY_PRO = @RUBY_PRO@
RUBY_CFLAGS = @RUBY_CFLAGS@
RUBY_CFLAGS_EXTRA = @RUBY_CFLAGS_EXTRA@
RUBY_LIBS = @RUBY_LIBS@

AWK = @AWK@
Expand Down
6 changes: 6 additions & 0 deletions src/configure.ac
Expand Up @@ -781,6 +781,7 @@ if test "$enable_luainterp" = "yes" -o "$enable_luainterp" = "dynamic"; then
AC_SUBST(LUA_PRO)
AC_SUBST(LUA_LIBS)
AC_SUBST(LUA_CFLAGS)
AC_SUBST(LUA_CFLAGS_EXTRA)
fi


Expand Down Expand Up @@ -1201,6 +1202,7 @@ AC_SUBST(PERL_SRC)
AC_SUBST(PERL_OBJ)
AC_SUBST(PERL_PRO)
AC_SUBST(PERL_CFLAGS)
AC_SUBST(PERL_CFLAGS_EXTRA)
AC_SUBST(PERL_LIBS)

AC_MSG_CHECKING(--enable-pythoninterp argument)
Expand Down Expand Up @@ -1433,6 +1435,7 @@ fi

AC_SUBST(PYTHON_LIBS)
AC_SUBST(PYTHON_CFLAGS)
AC_SUBST(PYTHON_CFLAGS_EXTRA)
AC_SUBST(PYTHON_SRC)
AC_SUBST(PYTHON_OBJ)

Expand Down Expand Up @@ -1650,6 +1653,7 @@ fi

AC_SUBST(PYTHON3_LIBS)
AC_SUBST(PYTHON3_CFLAGS)
AC_SUBST(PYTHON3_CFLAGS_EXTRA)
AC_SUBST(PYTHON3_SRC)
AC_SUBST(PYTHON3_OBJ)

Expand Down Expand Up @@ -1946,6 +1950,7 @@ AC_SUBST(TCL_SRC)
AC_SUBST(TCL_OBJ)
AC_SUBST(TCL_PRO)
AC_SUBST(TCL_CFLAGS)
AC_SUBST(TCL_CFLAGS_EXTRA)
AC_SUBST(TCL_LIBS)

AC_MSG_CHECKING(--enable-rubyinterp argument)
Expand Down Expand Up @@ -2050,6 +2055,7 @@ AC_SUBST(RUBY_SRC)
AC_SUBST(RUBY_OBJ)
AC_SUBST(RUBY_PRO)
AC_SUBST(RUBY_CFLAGS)
AC_SUBST(RUBY_CFLAGS_EXTRA)
AC_SUBST(RUBY_LIBS)

AC_MSG_CHECKING(--enable-cscope argument)
Expand Down
57 changes: 47 additions & 10 deletions src/if_ruby.c
Expand Up @@ -73,35 +73,40 @@
# if RUBY_VERSION >= 19
// Ruby 1.9 defines a number of static functions which use rb_num2long and
// rb_int2big
# define rb_num2long rb_num2long_stub
# define rb_int2big rb_int2big_stub
# define rb_num2long rb_num2long_stub
# define rb_int2big rb_int2big_stub

# if RUBY_VERSION >= 30 || VIM_SIZEOF_INT < VIM_SIZEOF_LONG
// Ruby 1.9 defines a number of static functions which use rb_fix2int and
// rb_num2int if VIM_SIZEOF_INT < VIM_SIZEOF_LONG (64bit)
# define rb_fix2int rb_fix2int_stub
# define rb_num2int rb_num2int_stub
# define rb_fix2int rb_fix2int_stub
# define rb_num2int rb_num2int_stub
# endif
# endif

# if RUBY_VERSION == 21
// Ruby 2.1 adds new GC called RGenGC and RARRAY_PTR uses
// rb_gc_writebarrier_unprotect_promoted if USE_RGENGC
# define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub
# define rb_gc_writebarrier_unprotect_promoted rb_gc_writebarrier_unprotect_promoted_stub
# endif

# if RUBY_VERSION >= 22
# define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
# define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub
# endif

# if RUBY_VERSION >= 26
# define rb_ary_detransient rb_ary_detransient_stub
# define rb_ary_detransient rb_ary_detransient_stub
# endif

# if RUBY_VERSION >= 30
# define rb_check_type rb_check_type_stub
# define rb_num2uint rb_num2uint_stub
# define ruby_malloc_size_overflow ruby_malloc_size_overflow_stub
# define rb_check_type rb_check_type_stub
# define rb_num2uint rb_num2uint_stub
# define ruby_malloc_size_overflow ruby_malloc_size_overflow_stub
# endif

# if RUBY_VERSION >= 31
# define rb_debug_rstring_null_ptr rb_debug_rstring_null_ptr_stub
# define rb_unexpected_type rb_unexpected_type_stub
# endif

#endif // ifdef DYNAMIC_RUBY
Expand Down Expand Up @@ -173,6 +178,14 @@
# undef HAVE_DUP
#endif

// Avoid redefining TRUE/FALSE in vterm.h.
#ifdef TRUE
# undef TRUE
#endif
#ifdef FALSE
# undef FALSE
#endif

#include "vim.h"
#include "version.h"

Expand Down Expand Up @@ -411,6 +424,9 @@ static VALUE (*dll_rb_data_typed_object_alloc) (VALUE, void*, const rb_data_type
# else
static VALUE (*dll_rb_data_object_alloc) (VALUE, void*, RUBY_DATA_FUNC, RUBY_DATA_FUNC);
# endif
# if RUBY_VERSION >= 31
static void (*dll_rb_debug_rstring_null_ptr) (const char*);
# endif
static VALUE (*dll_rb_define_class_under) (VALUE, const char*, VALUE);
static void (*dll_rb_define_const) (VALUE,const char*,VALUE);
static void (*dll_rb_define_global_function) (const char*,VALUE(*)(),int);
Expand Down Expand Up @@ -485,6 +501,9 @@ static void (*dll_NtInitialize) (int*, char***);
static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...);
# endif
# endif
# if RUBY_VERSION >= 31
static void (*dll_rb_unexpected_type) (VALUE, int) ATTRIBUTE_NORETURN;
# endif
# if RUBY_VERSION >= 18
static char * (*dll_rb_string_value_ptr) (volatile VALUE*);
static VALUE (*dll_rb_float_new) (double);
Expand Down Expand Up @@ -629,6 +648,18 @@ ruby_malloc_size_overflow_stub(size_t x, size_t y)
dll_ruby_malloc_size_overflow(x, y);
}
# endif
# if RUBY_VERSION >= 31
void
rb_debug_rstring_null_ptr_stub(const char *func)
{
dll_rb_debug_rstring_null_ptr(func);
}
void
rb_unexpected_type_stub(VALUE self, int t)
{
dll_rb_unexpected_type(self, t);
}
# endif
# endif // ifndef PROTO

static HINSTANCE hinstRuby = NULL; // Instance of ruby.dll
Expand Down Expand Up @@ -671,6 +702,9 @@ static struct
# endif
# else
{"rb_data_object_alloc", (RUBY_PROC*)&dll_rb_data_object_alloc},
# endif
# if RUBY_VERSION >= 31
{"rb_debug_rstring_null_ptr", (RUBY_PROC*)&dll_rb_debug_rstring_null_ptr},
# endif
{"rb_define_class_under", (RUBY_PROC*)&dll_rb_define_class_under},
{"rb_define_const", (RUBY_PROC*)&dll_rb_define_const},
Expand Down Expand Up @@ -745,6 +779,9 @@ static struct
{"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf},
# endif
# endif
# if RUBY_VERSION >= 31
{"rb_unexpected_type", (RUBY_PROC*)&dll_rb_unexpected_type},
# endif
# if RUBY_VERSION >= 18
{"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr},
# if RUBY_VERSION <= 19
Expand Down
2 changes: 2 additions & 0 deletions src/version.c
Expand Up @@ -749,6 +749,8 @@ static char *(features[]) =

static int included_patches[] =
{ /* Add new patch number below this line */
/**/
3922,
/**/
3921,
/**/
Expand Down

0 comments on commit 8bb3fe4

Please sign in to comment.