[packages/parigp/DEVEL-2.13] - try with pari 2.13.1 - updated gmp-version and Math-Pari crash-workaround patches - added custom u

qboosh qboosh at pld-linux.org
Sat Jun 26 12:55:35 CEST 2021


commit 469b1919ebb5a0b5989461a53465891618704e8f
Author: Jakub Bogusz <qboosh at pld-linux.org>
Date:   Sat Jun 26 12:58:12 2021 +0200

    - try with pari 2.13.1
    - updated gmp-version and Math-Pari crash-workaround patches
    - added custom updated Math-Pari diff patch instead of patch from Math-Pari sources
    - added Math-Pari update patch with few updates for pari 2.13

 gmp-version.patch                     |   4 +-
 pari-Math-Pari-diff.patch             | 208 ++++++++++++++++++++++++++++++++++
 parigp.spec                           |  25 ++--
 perl-Math-Pari-crash-workaround.patch |  14 +--
 perl-Math-Pari-update.patch           |  68 +++++++++++
 5 files changed, 301 insertions(+), 18 deletions(-)
---
diff --git a/parigp.spec b/parigp.spec
index 59279ab..6baf152 100644
--- a/parigp.spec
+++ b/parigp.spec
@@ -2,8 +2,12 @@
 # Conditional build:
 %bcond_without	tex	# TeX documentation
 #
-# latest perl Math::Pari (2.030518) doesn't know of pari >= 2.12
-%define		pari_version		2.11.4
+# note: latest perl Math::Pari (2.030518) doesn't know of pari >= 2.12
+# 2.13.1 with updated Math-Pari diff patch + Math-Pari 2.030518 with update patch:
+# Failed 19/243 test programs. 176/1476 subtests failed.
+# compared to 2.11.4 with Math-Pari 2.11-diff-all patch:
+# Failed 20/229 test programs. 173/1477 subtests failed.
+%define		pari_version		2.13.1
 %define		gp2c_version		0.0.12
 # because of previous 2.x versions with 8 minor digits, keep trailing zeros in package Version
 %define		math_pari_version	2.03051800
@@ -12,12 +16,11 @@ Summary:	Number Theory-oriented Computer Algebra System
 Summary(pl.UTF-8):	Komputerowy system obliczeń algebraicznych zorientowany na metody teorii liczb
 Name:		parigp
 Version:	%{pari_version}
-Release:	19
+Release:	20
 License:	GPL v2+
 Group:		Applications/Math
-#Source0:	http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-%{pari_version}.tar.gz
-Source0:	http://pari.math.u-bordeaux.fr/pub/pari/OLD/2.11/pari-%{pari_version}.tar.gz
-# Source0-md5:	fb2968d7805424518fe44a59a2024afd
+Source0:	http://pari.math.u-bordeaux.fr/pub/pari/unix/pari-%{pari_version}.tar.gz
+# Source0-md5:	826064cf75af268be8a482ade6e27501
 Source1:	http://pari.math.u-bordeaux.fr/pub/pari/packages/galdata.tgz
 # Source1-md5:	f9f61b2930757a785b568e5d307a7d75
 Source2:	http://pari.math.u-bordeaux.fr/pub/pari/GP2C/gp2c-%{gp2c_version}.tar.gz
@@ -33,6 +36,9 @@ Patch4:		perl-Math-Pari-noproccpuinfo.patch
 Patch5:		%{name}-noproccpuinfo.patch
 Patch6:		gmp-version.patch
 Patch7:		Math-Pari-escape-left-braces-in-regex.patch
+Patch8:		perl-Math-Pari-update.patch
+# based on Math-Pari-%{math_pari_fversion}/patches/diff-2.11.0-all
+Patch10:	pari-Math-Pari-diff.patch
 URL:		http://pari.math.u-bordeaux.fr/
 BuildRequires:	autoconf
 BuildRequires:	ctags
@@ -178,7 +184,7 @@ Interfejs Perla do biblioteki PARI.
 
 %prep
 %setup -q -n pari-%{pari_version} -a 2 -a 3
-patch -p1 < Math-Pari-%{math_pari_fversion}/patches/diff-2.11.0-all
+%patch10 -p1
 %patch0 -p1
 %patch2 -p1
 %patch5 -p1
@@ -187,6 +193,7 @@ cd Math-Pari-%{math_pari_fversion}
 %patch3 -p1
 %patch4 -p1
 %patch7 -p0
+%patch8 -p1
 
 %build
 # pari & parigp
@@ -291,7 +298,7 @@ rm -rf $RPM_BUILD_ROOT
 %files
 %defattr(644,root,root,755)
 %doc AUTHORS CHANGES* COMPAT NEW README examples/Inputrc %{?with_tex:doc/*.pdf}
-%attr(755,root,root) %{_bindir}/gp-2.11
+%attr(755,root,root) %{_bindir}/gp-2.13
 %attr(755,root,root) %{_bindir}/gp
 %attr(755,root,root) %{_bindir}/gphelp
 %attr(755,root,root) %{_bindir}/tex2mail
@@ -310,7 +317,7 @@ rm -rf $RPM_BUILD_ROOT
 %files -n pari
 %defattr(644,root,root,755)
 %attr(755,root,root) %{_libdir}/libpari-gmp.so.*.*.*
-%attr(755,root,root) %ghost %{_libdir}/libpari-gmp.so.6
+%attr(755,root,root) %ghost %{_libdir}/libpari-gmp.so.7
 %{_libdir}/parigp
 
 %files -n pari-devel
diff --git a/gmp-version.patch b/gmp-version.patch
index 445c345..db94943 100644
--- a/gmp-version.patch
+++ b/gmp-version.patch
@@ -1,5 +1,5 @@
---- pari-2.11.4/config/gmp_version.c.orig	2021-06-25 21:33:14.999293627 +0200
-+++ pari-2.11.4/config/gmp_version.c	2021-06-25 21:33:52.912421567 +0200
+--- pari-2.13.1/config/gmp_version.c.orig	2021-06-24 16:59:33.222993655 +0200
++++ pari-2.13.1/config/gmp_version.c	2021-06-24 17:08:35.866720568 +0200
 @@ -3,9 +3,5 @@
  void f(void) { mpn_gcdext(NULL,NULL, NULL, NULL, 0, NULL, 0); }
  int main()
diff --git a/pari-Math-Pari-diff.patch b/pari-Math-Pari-diff.patch
new file mode 100644
index 0000000..a603401
--- /dev/null
+++ b/pari-Math-Pari-diff.patch
@@ -0,0 +1,208 @@
+--- pari-2.13.1/src/language/anal.c.orig	2020-10-26 13:43:04.000000000 +0100
++++ pari-2.13.1/src/language/anal.c	2021-06-26 11:47:46.571531691 +0200
+@@ -159,6 +159,10 @@ findentry(const char *s, long len, entre
+       if (!strncmp(t, s, len) && !t[len]) return ep;
+     }
+   /* not found */
++  if (foreignAutoload) {	/* Try to autoload. */
++    ep = foreignAutoload(s,len);
++    if(ep) return ep;
++  }  /* not found */
+   if (insert) { ep = initep(s,len); insertep(ep, T, hash); }
+   return ep;
+ }
+@@ -214,7 +218,7 @@ gp_read_str_prec(const char *s, long pre
+ /* valid return type */
+ static int
+ isreturn(char c)
+-{ return c == 'l' || c == 'v' || c == 'i' || c == 'm' || c == 'u'; }
++{ return c == 'l' || c == 'v' || c == 'i' || c == 'm' || c == 'u' || c == 'x'; }
+ 
+ /* if is known that 2 commas follow s; base-10 signed integer followed
+  * by comma? */
+@@ -241,7 +245,7 @@ check_proto(const char *code)
+ {
+   long arity = 0;
+   const char *s = code;
+-  if (isreturn(*s)) s++;
++  if (isreturn(*s)) { if(*s == 'x') { arity++; } s++; }
+   while (*s && *s != '\n') switch (*s++)
+   {
+     case '&':
+@@ -329,7 +333,11 @@ install(void *f, const char *name, const
+   {
+     if (ep->valence != EpINSTALL)
+       pari_err(e_MISC,"[install] identifier '%s' already in use", name);
+-    pari_warn(warner, "[install] updating '%s' prototype; module not reloaded", name);
++    if (foreignFuncFree && ep->code && (*ep->code == 'x'))
++      (*foreignFuncFree)(ep); /* function created by foreign interpreter */
++    else
++      pari_warn(warner, "[install] updating '%s' prototype; module not reloaded", name);
++
+     if (ep->code) pari_free((void*)ep->code);
+   }
+   else
+diff -pru pari-2.9.0-ini/src/language/anal.h pari-2.9.0/src/language/anal.h
+--- pari-2.9.0-ini/src/language/anal.h	2016-10-01 04:23:18.000000000 -0700
++++ pari-2.9.0/src/language/anal.h	2019-03-06 02:48:18.136608900 -0800
+@@ -34,6 +34,9 @@ void   pari_fill_hashtable(entree **tabl
+ void compile_err(const char *msg, const char *str);
+ void compile_varerr(const char *str);
+ 
++extern entree * (*foreignAutoload)(const char*, long len);
++extern void (*foreignFuncFree)(entree *);
++
+ #ifdef STACK_CHECK
+ extern THREAD void *PARI_stack_limit;
+ #endif
+diff -pru pari-2.9.0-ini/src/language/compile.c pari-2.9.0/src/language/compile.c
+--- pari-2.9.0-ini/src/language/compile.c	2016-10-05 02:43:38.000000000 -0700
++++ pari-2.9.0/src/language/compile.c	2019-03-06 02:48:18.027408700 -0800
+@@ -519,9 +519,10 @@ detag(long n)
+ 
+ /* return type for GP functions */
+ static op_code
+-get_ret_type(const char **p, long arity, Gtype *t, long *flag)
++get_ret_type(const char **p, long arity, Gtype *t, long *flag, long *is_external)
+ {
+-  *flag = 0;
++  *flag = *is_external = 0;
++  if (**p == 'x') { (*p)++; *is_external = 1; }
+   if (**p == 'v') { (*p)++; *t=Gvoid; return OCcallvoid; }
+   else if (**p == 'i') { (*p)++; *t=Gsmall;  return OCcallint; }
+   else if (**p == 'l') { (*p)++; *t=Gsmall;  return OCcalllong; }
+@@ -1203,7 +1204,7 @@ compilefunc(entree *ep, long n, int mode
+   long j;
+   long x=tree[n].x, y=tree[n].y;
+   op_code ret_op;
+-  long ret_flag;
++  long ret_flag, is_external;
+   Gtype ret_typ;
+   char const *p,*q;
+   char c;
+@@ -1337,8 +1337,9 @@ compilefunc(entree *ep, long n, int mode
+   if (!ep->value)
+     compile_err("unknown function",tree[n].str);
+   nbopcodes = s_opcode.n;
+-  ret_op = get_ret_type(&p, ep->arity, &ret_typ, &ret_flag);
++  ret_op = get_ret_type(&p, ep->arity, &ret_typ, &ret_flag, &is_external);
+   j=1;
++  if (is_external) op_push(OCpushlong,(long)ep,n);	/* as in PPauto */
+   if (*p)
+   {
+     q=p;
+@@ -1661,8 +1663,8 @@ genclosure(entree *ep, const char *loc,
+   long arity=0, maskarg=0, maskarg0=0, stop=0, dovararg=0;
+   PPproto mod;
+   Gtype ret_typ;
+-  long ret_flag;
+-  op_code ret_op=get_ret_type(&code,ep->arity,&ret_typ,&ret_flag);
++  long ret_flag, is_external;
++  op_code ret_op=get_ret_type(&code,ep->arity,&ret_typ,&ret_flag,&is_external);
+   p=code;
+   while ((mod=parseproto(&p,&c,NULL))!=PPend)
+   {
+@@ -1705,6 +1707,7 @@ genclosure(entree *ep, const char *loc,
+   if (maskarg)  op_push_loc(OCcheckargs,maskarg,loc);
+   if (maskarg0) op_push_loc(OCcheckargs0,maskarg0,loc);
+   p=code;
++  if (is_external) op_push_loc(OCpushlong,(long)ep,loc);	/* as in PPauto */
+   while ((mod=parseproto(&p,&c,NULL))!=PPend)
+   {
+     switch(mod)
+@@ -2292,14 +2292,14 @@ optimizefunc(entree *ep, long n)
+   const char *p;
+   char c;
+   GEN arg = listtogen(y,Flistarg);
+-  long nb=lg(arg)-1, ret_flag;
++  long nb=lg(arg)-1, ret_flag, is_external /* ignored */;
+   if (is_func_named(ep,"if") && nb>=4)
+     ep=is_entry("_multi_if");
+   p = ep->code;
+   if (!p)
+     fl=0;
+   else
+-    (void) get_ret_type(&p, 2, &t, &ret_flag);
++    (void) get_ret_type(&p, 2, &t, &ret_flag, &is_external);
+   if (p && *p)
+   {
+     j=1;
+--- pari-2.13.1/src/language/eval.c.orig	2020-10-26 13:43:04.000000000 +0100
++++ pari-2.13.1/src/language/eval.c	2021-06-26 11:49:53.724176179 +0200
+@@ -139,6 +139,9 @@ pop_val(entree *ep)
+ void
+ freeep(entree *ep)
+ {
++  if (foreignFuncFree && ep->code && (*ep->code == 'x'))
++    (*foreignFuncFree)(ep); /* function created by foreign interpreter */
++
+   if (EpSTATIC(ep)) return; /* gp function loaded at init time */
+   if (ep->help) {pari_free((void*)ep->help); ep->help=NULL;}
+   if (ep->code) {pari_free((void*)ep->code); ep->code=NULL;}
+@@ -1672,7 +1675,8 @@ evalstate_reset(void)
+   reset_break();
+   compilestate_reset();
+   parsestate_reset();
+-  set_avma(pari_mainstack->top);
++  if (!cb_exception_resets_avma)
++    set_avma(pari_mainstack->top);
+ }
+ 
+ void
+diff -pru pari-2.9.0-ini/src/language/init.c pari-2.9.0/src/language/init.c
+--- pari-2.9.0-ini/src/language/init.c	2016-10-25 01:15:32.000000000 -0700
++++ pari-2.9.0/src/language/init.c	2019-03-06 03:00:07.190054300 -0800
+@@ -113,6 +113,9 @@ static pari_stack s_MODULES;
+ const long functions_tblsz = 135; /* size of functions_hash */
+ entree **functions_hash, **defaults_hash;
+ 
++entree* (*foreignAutoload)(const char*, long len); /* Autoloader         */
++void (*foreignFuncFree)(entree *);    /* How to free external entree.    */
++
+ char *(*cb_pari_fgets_interactive)(char *s, int n, FILE *f);
+ int (*cb_pari_get_line_interactive)(const char*, const char*, filtre_t *F);
+ void (*cb_pari_quit)(long);
+@@ -130,6 +133,9 @@ void (*cb_pari_start_output)();
+ 
+ const char * pari_library_path = NULL;
+ 
++int cb_exception_resets_avma = 0;
++int cb_exception_flushes_err = 0;
++
+ static THREAD GEN global_err_data;
+ THREAD jmp_buf *iferr_env;
+ const long CATCH_ALL = -1;
+@@ -1141,7 +1147,8 @@ pari_sigint(const char *time_s)
+   out_puts(pariErr, "user interrupt after ");
+   out_puts(pariErr, time_s);
+   out_term_color(pariErr, c_NONE);
+-  pariErr->flush();
++  if (!cb_exception_flushes_err)
++    pariErr->flush();
+   if (cb_pari_handle_exception)
+     recover = cb_pari_handle_exception(-1);
+   if (!recover && !block)
+@@ -1505,7 +1505,9 @@ pari_err_display(GEN err)
+     pari_free(s);
+   }
+   out_term_color(pariErr, c_NONE);
+-  pariErr->flush(); return 0;
++  if (!cb_exception_flushes_err)
++    pariErr->flush();
++  return 0;
+ }
+ 
+ void
+--- pari-2.9.0/src/headers/paricom.h-pre	2011-05-30 02:28:34.000000000 -0700
++++ pari-2.9.0/src/headers/paricom.h	2018-09-16 00:04:16.527215600 -0700
+@@ -92,6 +92,10 @@ extern void (*cb_pari_start_output)(void
+ extern const char *pari_library_path;
+ extern THREAD long *varpriority;
+ 
++#define CB_EXCEPTION_FLAGS 1
++extern int cb_exception_resets_avma;
++extern int cb_exception_flushes_err;
++
+ /* pari_init_opts */
+ enum {
+   INIT_JMPm = 1,
diff --git a/perl-Math-Pari-crash-workaround.patch b/perl-Math-Pari-crash-workaround.patch
index e0d507a..6e4d1b5 100644
--- a/perl-Math-Pari-crash-workaround.patch
+++ b/perl-Math-Pari-crash-workaround.patch
@@ -8,9 +8,9 @@ bless( do{\(my $o = POINTER_VAL)}, 'Math::Pari' );
 where POINTER_VAL is just value of pointer to already existing Pari
 object (which may be destroyed later!).
 
---- Math-Pari-2.030518/Pari.xs.orig	2019-04-20 05:02:34.000000000 +0200
-+++ Math-Pari-2.030518/Pari.xs	2021-06-26 09:51:04.478020090 +0200
-@@ -1377,6 +1377,13 @@ moveoffstack_newer_than(SV* sv)
+--- Math-Pari-2.01080605/Pari.xs.orig	2004-01-31 10:06:08.000000000 +0100
++++ Math-Pari-2.01080605/Pari.xs	2004-05-15 21:11:38.894463600 +0200
+@@ -1285,6 +1285,13 @@
    SV* nextsv;
    long ret=0;
    
@@ -24,16 +24,16 @@ object (which may be destroyed later!).
    for (sv1 = PariStack; sv1 != sv; sv1 = nextsv) {
      ret++;
      SV_OAVMA_switch(nextsv, sv1, GENmovedOffStack); /* Mark as moved off stack. */
-@@ -4285,7 +4292,7 @@ DESTROY(rv)
+@@ -3848,7 +3855,7 @@
  	 long oldavma;			 /* The value of avma on the entry
  					  * to function having the SV as
  					  * argument. */
 -	 long howmany;
 +	 long howmany = 0;
  	 SV_OAVMA_PARISTACK_get(sv, oldavma, ostack);
- 	 oldavma += myPARI_bot;
+ 	 oldavma += bot;
  #if 1
-@@ -4318,6 +4325,7 @@ DESTROY(rv)
+@@ -3881,6 +3888,7 @@
  	     /* Now fall through: */
  /* case (IV)GENfirstOnStack: */
  	     /* Now sv is the newest one on stack. */
@@ -41,7 +41,7 @@ object (which may be destroyed later!).
  	     onStack_dec;
  	     perlavma = oldavma;
  	     if (oldavma > sentinel) {
-@@ -4326,7 +4334,9 @@ DESTROY(rv)
+@@ -3889,7 +3897,9 @@
  		 avma = oldavma;	/* Mark the space on stack as free. */
  	     }
  	     PariStack = (SV*)ostack; /* The same on the Perl/PARI side. */
diff --git a/perl-Math-Pari-update.patch b/perl-Math-Pari-update.patch
new file mode 100644
index 0000000..da787de
--- /dev/null
+++ b/perl-Math-Pari-update.patch
@@ -0,0 +1,68 @@
+--- Math-Pari-2.030518/Pari.xs.orig	2021-06-24 18:30:57.496616128 +0200
++++ Math-Pari-2.030518/Pari.xs	2021-06-24 20:04:03.246355523 +0200
+@@ -1283,7 +1283,7 @@
+     /* add to output */
+     switch(d->context) {
+     case G_VOID:
+-    case G_SCALAR: sv_catpvf(d->acc, " %2d: %s\n",
++    case G_SCALAR: sv_catpvf(d->acc, " %2ld: %s\n",
+ 			     d->items - 1, SvPV_nolen(tmp));
+ 		   SvREFCNT_dec(tmp);     break;
+     case G_ARRAY:  av_push((AV*)d->acc,tmp); break;
+@@ -2036,11 +2036,11 @@
+ #  if PARI_VERSION_EXP < 2010000
+ #    define TAG_community	15	/* "The PARI community" */
+ #  else /* !(PARI_VERSION_EXP < 2010000) */
+-#    if PARI_VERSION_EXP < 2012000
++#    if PARI_VERSION_EXP < 2014000
+ #      define TAG_community	17	/* "The PARI community" */
+-#    else /* !(PARI_VERSION_EXP < 2012000) */
++#    else /* !(PARI_VERSION_EXP < 2014000) */
+ #      define TAG_community_unknown
+-#    endif	/* !(PARI_VERSION_EXP < 2012000) */
++#    endif	/* !(PARI_VERSION_EXP < 2014000) */
+ #  endif	/* !(PARI_VERSION_EXP < 2010000) */
+ #endif		/* !(PARI_VERSION_EXP < 2008000) */
+ 
+@@ -2060,7 +2060,7 @@
+ char *
+ added_sections()
+ {
+-#if PARI_VERSION_EXP < 2013000
++#if PARI_VERSION_EXP < 2014000
+    /* Suggestion on format (part of 2.10.0), only use short names: "4: functions related to COMBINATORICS\n13: L-FUNCTIONS" */
+    return "";
+ #else	/* !( PARI_VERSION_EXP < 2011000) */
+@@ -3823,7 +3823,7 @@
+ 	 switch (valence) {
+ 	 case 0:
+ 	     if (!ep->code) {
+-		 croak("Unsupported Pari function %s, interface 0 code NULL");
++		 croak("Unsupported Pari function %s, interface 0 code NULL", name);
+ 	     } else if (ep->code[0] == 'p' && ep->code[1] == 0) {
+ 		 DO_INTERFACE(0);
+ 	     } else if (ep->code[0] == 0) {
+@@ -3886,10 +3886,10 @@
+ 
+ 	 default: 
+ 	     if (!ep)
+-		 croak("Unsupported interface %d for \"direct-link\" Pari function %s",
++		 croak("Unsupported interface %ld for \"direct-link\" Pari function %s",
+ 		       valence, olds);
+ 	     if (!ep->code)
+-		 croak("Unsupported interface %d and no code for a Pari function %s",
++		 croak("Unsupported interface %ld and no code for a Pari function %s",
+ 		       valence, olds);
+ 	   flexible:
+ 	     s1 = s = ep->code;
+--- Math-Pari-2.030518/libPARI/Makefile.PL.orig	2021-06-24 21:41:42.021282480 +0200
++++ Math-Pari-2.030518/libPARI/Makefile.PL	2021-06-24 21:41:46.411258697 +0200
+@@ -317,7 +317,7 @@
+     $mp = 'mp.c';
+     my $kern = "$kernel_dir/none";
+     my @dep			# Copied from src/kernel/none/MakeLVL1.SH 2.2.10
+-      = "$kern/mp.c $kern/cmp.c $kern/gcdll.c $kern/ratlift.c $kern/gcd.c $kern/invmod.c $kern/mp_indep.c $kern/add.c";
++      = "$kern/mp.c $kern/cmp.c $kern/gcdll.c $kern/halfgcd.c $kern/ratlift.c $kern/invmod.c $kern/gcd.c $kern/mp_indep.c $kern/add.c";
+     -f "$main_paridir/src/kernel/$_" and push @dep, "$kernel_dir/$_" for "none/gcdext.c";	# When did it appear?  Was:  if $pari_version > 2004000
+     $create_mp = <<EOS;
+ mp.c: @dep
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/parigp.git/commitdiff/469b1919ebb5a0b5989461a53465891618704e8f



More information about the pld-cvs-commit mailing list