From 6174cf78a6ba29285e4c928fd07cad68241a7069 Mon Sep 17 00:00:00 2001 From: Sergey Cherevko Date: Fri, 4 Aug 2023 18:02:47 +0300 Subject: [PATCH] Fix build errors for MSVSphere 8.8 --- ...Restore-compatiblity-wih-Perl-5.26.0.patch | 78 ++++++++ ...-error-when-building-with-Ruby-3.1.2.patch | 28 +++ SOURCES/0003-Fix-build-if_ruby-dyn.patch | 184 ++++++++++++++++++ SPECS/vim.spec | 17 +- 4 files changed, 306 insertions(+), 1 deletion(-) create mode 100644 SOURCES/0001-Restore-compatiblity-wih-Perl-5.26.0.patch create mode 100644 SOURCES/0002-Fix-build-error-when-building-with-Ruby-3.1.2.patch create mode 100644 SOURCES/0003-Fix-build-if_ruby-dyn.patch diff --git a/SOURCES/0001-Restore-compatiblity-wih-Perl-5.26.0.patch b/SOURCES/0001-Restore-compatiblity-wih-Perl-5.26.0.patch new file mode 100644 index 0000000..dd18df9 --- /dev/null +++ b/SOURCES/0001-Restore-compatiblity-wih-Perl-5.26.0.patch @@ -0,0 +1,78 @@ +From 29a7470516c0532e21c9cffde3adfb291d6453a0 Mon Sep 17 00:00:00 2001 +From: Sergey Cherevko +Date: Fri, 4 Aug 2023 17:32:23 +0300 +Subject: [PATCH 1/3] Restore compatiblity wih Perl 5.26.0 + +--- + src/if_perl.xs | 48 ------------------------------------------------ + 1 file changed, 48 deletions(-) + +diff --git a/src/if_perl.xs b/src/if_perl.xs +index 7b45033..2d2803c 100644 +--- a/src/if_perl.xs ++++ b/src/if_perl.xs +@@ -37,13 +37,6 @@ + + #include "vim.h" + +-/* Work around for perl-5.18. +- * Don't include "perl\lib\CORE\inline.h" for now, +- * include it after Perl_sv_free2 is defined. */ +-#ifdef DYNAMIC_PERL +-# define PERL_NO_INLINE_FUNCTIONS +-#endif +- + /* Work around for using MSVC and ActivePerl 5.18. */ + #ifdef _MSC_VER + # define __inline__ __inline +@@ -616,47 +609,6 @@ static struct { + {"", NULL}, + }; + +-/* Work around for perl-5.18. +- * For now, only the definitions of S_SvREFCNT_dec are needed in +- * "perl\lib\CORE\inline.h". */ +-# if (PERL_REVISION == 5) && (PERL_VERSION >= 18) +-static void +-S_SvREFCNT_dec(pTHX_ SV *sv) +-{ +- if (LIKELY(sv != NULL)) { +- U32 rc = SvREFCNT(sv); +- if (LIKELY(rc > 1)) +- SvREFCNT(sv) = rc - 1; +- else +- Perl_sv_free2(aTHX_ sv, rc); +- } +-} +-# endif +- +-/* perl-5.26 also needs S_TOPMARK and S_POPMARK. */ +-# if (PERL_REVISION == 5) && (PERL_VERSION >= 26) +-PERL_STATIC_INLINE I32 +-S_TOPMARK(pTHX) +-{ +- DEBUG_s(DEBUG_v(PerlIO_printf(Perl_debug_log, +- "MARK top %p %" IVdf "\n", +- PL_markstack_ptr, +- (IV)*PL_markstack_ptr))); +- return *PL_markstack_ptr; +-} +- +-PERL_STATIC_INLINE I32 +-S_POPMARK(pTHX) +-{ +- DEBUG_s(DEBUG_v(PerlIO_printf(Perl_debug_log, +- "MARK pop %p %" IVdf "\n", +- (PL_markstack_ptr-1), +- (IV)*(PL_markstack_ptr-1)))); +- assert((PL_markstack_ptr > PL_markstack) || !"MARK underflow"); +- return *PL_markstack_ptr--; +-} +-# endif +- + /* + * Make all runtime-links of perl. + * +-- +2.39.2 + diff --git a/SOURCES/0002-Fix-build-error-when-building-with-Ruby-3.1.2.patch b/SOURCES/0002-Fix-build-error-when-building-with-Ruby-3.1.2.patch new file mode 100644 index 0000000..8cffd49 --- /dev/null +++ b/SOURCES/0002-Fix-build-error-when-building-with-Ruby-3.1.2.patch @@ -0,0 +1,28 @@ +From 1f8c90c2b7711707453faacd61eb9850a7470d5a Mon Sep 17 00:00:00 2001 +From: Sergey Cherevko +Date: Fri, 4 Aug 2023 18:22:47 +0300 +Subject: [PATCH 2/3] Fix build error when building with Ruby 3.1.2 + +--- + src/if_ruby.c | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/if_ruby.c b/src/if_ruby.c +index 5905424..1497104 100644 +--- a/src/if_ruby.c ++++ b/src/if_ruby.c +@@ -458,7 +458,11 @@ SIGNED_VALUE rb_num2long_stub(VALUE x) + { + return dll_rb_num2long(x); + } ++# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 26 ++VALUE rb_int2big_stub(intptr_t x) ++# else + VALUE rb_int2big_stub(SIGNED_VALUE x) ++# endif + { + return dll_rb_int2big(x); + } +-- +2.39.2 + diff --git a/SOURCES/0003-Fix-build-if_ruby-dyn.patch b/SOURCES/0003-Fix-build-if_ruby-dyn.patch new file mode 100644 index 0000000..0040b02 --- /dev/null +++ b/SOURCES/0003-Fix-build-if_ruby-dyn.patch @@ -0,0 +1,184 @@ +From f65ec60f45532418e141a1d4a1ce98aac89cb094 Mon Sep 17 00:00:00 2001 +From: Sergey Cherevko +Date: Fri, 4 Aug 2023 18:52:36 +0300 +Subject: [PATCH 3/3] Fix build if_ruby/dyn + +--- + src/Makefile | 2 +- + src/auto/configure | 1 + + src/config.mk.in | 1 + + src/configure.ac | 1 + + src/if_ruby.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++ + src/vim.h | 9 ++++++++ + 6 files changed, 65 insertions(+), 1 deletion(-) + +diff --git a/src/Makefile b/src/Makefile +index 85de383..a28ea39 100644 +--- a/src/Makefile ++++ b/src/Makefile +@@ -3177,7 +3177,7 @@ objects/if_python3.o: if_python3.c if_py_both.h + $(CCC_NF) $(PYTHON3_CFLAGS) $(PYTHON3_CFLAGS_EXTRA) $(ALL_CFLAGS) -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 +diff --git a/src/auto/configure b/src/auto/configure +index c1d477c..a5cb8d0 100755 +--- a/src/auto/configure ++++ b/src/auto/configure +@@ -664,6 +664,7 @@ NETBEANS_SRC + WORKSHOP_OBJ + WORKSHOP_SRC + RUBY_LIBS ++RUBY_CFLAGS_EXTRA + RUBY_CFLAGS + RUBY_PRO + RUBY_OBJ +diff --git a/src/config.mk.in b/src/config.mk.in +index 84c1590..85e9b95 100644 +--- a/src/config.mk.in ++++ b/src/config.mk.in +@@ -96,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@ +diff --git a/src/configure.ac b/src/configure.ac +index 7f55281..cecdd21 100644 +--- a/src/configure.ac ++++ b/src/configure.ac +@@ -1973,6 +1973,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) +diff --git a/src/if_ruby.c b/src/if_ruby.c +index 1497104..f83d0f9 100644 +--- a/src/if_ruby.c ++++ b/src/if_ruby.c +@@ -117,6 +117,20 @@ + # define rb_gc_writebarrier_unprotect rb_gc_writebarrier_unprotect_stub + #endif + ++#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 26 ++# define rb_ary_detransient rb_ary_detransient_stub ++#endif ++ ++# if RUBY_VERSION >= 30 ++# define rb_check_type rb_check_type_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 ++ + #include + #ifdef RUBY19_OR_LATER + # include +@@ -351,6 +365,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); +@@ -413,6 +430,12 @@ static void (*dll_ruby_sysinit) (int*, char***); + static int (*dll_rb_w32_snprintf)(char*, size_t, const char*, ...); + # endif + # endif ++#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 26 ++static void (*dll_rb_ary_detransient) (VALUE); ++#endif ++# if RUBY_VERSION >= 31 ++static void (*dll_rb_unexpected_type) (VALUE, int) ATTRIBUTE_NORETURN; ++# endif + # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 + static char * (*dll_rb_string_value_ptr) (volatile VALUE*); + static VALUE (*dll_rb_float_new) (double); +@@ -507,6 +530,26 @@ void rb_gc_writebarrier_unprotect_stub(VALUE obj) + dll_rb_gc_writebarrier_unprotect(obj); + } + # 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 ++ ++# if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 26 ++void rb_ary_detransient_stub(VALUE x) ++{ ++ dll_rb_ary_detransient(x); ++} + # endif + + static HINSTANCE hinstRuby = NULL; /* Instance of ruby.dll */ +@@ -547,6 +590,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}, +@@ -612,6 +658,12 @@ static struct + {"rb_w32_snprintf", (RUBY_PROC*)&dll_rb_w32_snprintf}, + # endif + # endif ++#if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 26 ++ {"rb_ary_detransient", (RUBY_PROC*)&dll_rb_ary_detransient}, ++#endif ++# if RUBY_VERSION >= 31 ++ {"rb_unexpected_type", (RUBY_PROC*)&dll_rb_unexpected_type}, ++# endif + # if defined(DYNAMIC_RUBY_VER) && DYNAMIC_RUBY_VER >= 18 + {"rb_string_value_ptr", (RUBY_PROC*)&dll_rb_string_value_ptr}, + # if DYNAMIC_RUBY_VER <= 19 +diff --git a/src/vim.h b/src/vim.h +index df396ec..6dd66f0 100644 +--- a/src/vim.h ++++ b/src/vim.h +@@ -2087,6 +2087,15 @@ typedef struct stat stat_T; + + #if defined(__GNUC__) && !defined(__MINGW32__) + # define USE_PRINTF_FORMAT_ATTRIBUTE ++# define likely(x) __builtin_expect((x), 1) ++# define unlikely(x) __builtin_expect((x), 0) ++# define ATTRIBUTE_COLD __attribute__((cold)) ++# define ATTRIBUTE_NORETURN __attribute__((noreturn)) ++#else ++# define unlikely(x) (x) ++# define likely(x) (x) ++# define ATTRIBUTE_COLD ++# define ATTRIBUTE_NORETURN + #endif + + typedef enum +-- +2.39.2 + diff --git a/SPECS/vim.spec b/SPECS/vim.spec index af6d3f5..4127e37 100644 --- a/SPECS/vim.spec +++ b/SPECS/vim.spec @@ -24,7 +24,7 @@ Summary: The VIM editor URL: http://www.vim.org/ Name: vim Version: %{baseversion}.%{patchlevel} -Release: 19%{?dist}.4 +Release: 19%{?dist}.4.inferit License: Vim and MIT Source0: ftp://ftp.vim.org/pub/vim/unix/vim-%{baseversion}-%{patchlevel}.tar.bz2 Source1: vim.sh @@ -113,6 +113,11 @@ Patch3039: 0001-patch-8.2.5023-substitute-overwrites-allocated-buffe.patch # CVE-2022-1927 vim: buffer over-read in utf_ptr2char() in mbyte.c Patch3040: 0001-patch-8.2.5037-cursor-position-may-be-invalid-after-.patch +# MSVSphere +Patch10000: 0001-Restore-compatiblity-wih-Perl-5.26.0.patch +Patch10001: 0002-Fix-build-error-when-building-with-Ruby-3.1.2.patch +Patch10002: 0003-Fix-build-if_ruby-dyn.patch + # gcc is no longer in buildroot by default BuildRequires: gcc @@ -329,6 +334,10 @@ perl -pi -e "s,bin/nawk,bin/awk,g" runtime/tools/mve.awk %patch3038 -p1 -b .cve1785 %patch3039 -p1 -b .cve1897 %patch3040 -p1 -b .cve1927 +# MSVSphere +%patch10000 -p1 +%patch10001 -p1 +%patch10002 -p1 %build %if 0%{?rhel} > 7 @@ -847,6 +856,12 @@ touch %{buildroot}/%{_datadir}/%{name}/vimfiles/doc/tags %{_datadir}/icons/locolor/*/apps/* %changelog +* Fri Aug 04 2023 Sergey Cherevko - 2:8.0.1763-19.4.inferit +- Restore compatiblity with Perl 5.26.0 +- Fix build error when building with Ruby 3.1.2 +- Fix build if_ruby/dyn +- Rebuilt for MSVSphere 8.8 + * Wed Jul 26 2023 MSVSphere Packaging Team - 2:8.0.1763-19.4 - Rebuilt for MSVSphere 8.8