[arch-commits] Commit in sagemath/trunk (PKGBUILD sagemath-gap-4.10.1.patch)

Antonio Rojas arojas at archlinux.org
Fri Mar 29 12:58:38 UTC 2019


    Date: Friday, March 29, 2019 @ 12:58:37
  Author: arojas
Revision: 446007

Use upstream GAP patch, enable multi-threaded build

Modified:
  sagemath/trunk/PKGBUILD
  sagemath/trunk/sagemath-gap-4.10.1.patch

---------------------------+
 PKGBUILD                  |    3 
 sagemath-gap-4.10.1.patch |  384 ++++++++++++++++++++++++++++++++++++++++++--
 2 files changed, 369 insertions(+), 18 deletions(-)

Modified: PKGBUILD
===================================================================
--- PKGBUILD	2019-03-29 12:36:48 UTC (rev 446006)
+++ PKGBUILD	2019-03-29 12:58:37 UTC (rev 446007)
@@ -59,7 +59,7 @@
             '22f5e44a42c8276025b8512f45cac1c36d576c29c7fd9d36fde8b19ff87867d8'
             '961bfb5694b67d425d21240d71490cb71714b5207c23448c89be0966512ff8f9'
             'a42f3b152b1aedb8abf16bc70971419919d1fe30328574e7fef8305f9d07d938'
-            '99066a3a11c102dee5183acf86b3f6200e9c3db8fe15e52cf391ecd6f72846c1')
+            '9ec56a3788e32c54f35abeaeedf7cadf6670fa10d39007050b23b93d3c35278e')
 
 prepare(){
   cd sage-$pkgver
@@ -107,6 +107,7 @@
   export CC=gcc
   export SAGE_ROOT="$PWD"
   export SAGE_SRC="$PWD"
+  export SAGE_NUM_THREADS=10
   python2 setup.py build
 }
 

Modified: sagemath-gap-4.10.1.patch
===================================================================
--- sagemath-gap-4.10.1.patch	2019-03-29 12:36:48 UTC (rev 446006)
+++ sagemath-gap-4.10.1.patch	2019-03-29 12:58:37 UTC (rev 446007)
@@ -1,31 +1,381 @@
+diff --git a/src/sage/interfaces/tests.py b/src/sage/interfaces/tests.py
+index 6bcbfef..fc77f12 100644
+--- a/src/sage/interfaces/tests.py
++++ b/src/sage/interfaces/tests.py
+@@ -33,8 +33,8 @@ Test that write errors to stderr are handled gracefully by GAP
+     sage: kwds = dict(shell=True, stdout=f, stderr=f)
+     sage: subprocess.call("echo syntax error | ecl", **kwds)
+     0
+-    sage: subprocess.call("echo syntax error | gap", **kwds)
+-    0
++    sage: subprocess.call("echo syntax error | gap", **kwds) in (0, 1)
++    True
+     sage: subprocess.call("echo syntax error | gp", **kwds)
+     0
+     sage: subprocess.call("echo syntax error | ipython", **kwds) in (0, 1, 120)
 diff --git a/src/sage/libs/gap/gap_includes.pxd b/src/sage/libs/gap/gap_includes.pxd
-index 864a13b385..8a2c22ed4a 100644
+index 864a13b..f624ccd 100644
 --- a/src/sage/libs/gap/gap_includes.pxd
 +++ b/src/sage/libs/gap/gap_includes.pxd
-@@ -77,8 +77,8 @@ cdef extern from "<gap/io.h>":
+@@ -10,14 +10,14 @@
+ ###############################################################################
  
- cdef extern from "<gap/libgap-api.h>":
-     ctypedef void (*CallbackFunc)()
+ 
+-cdef extern from "<gap/system.h>":
++cdef extern from "gap/system.h" nogil:
+     ctypedef char Char
+     ctypedef int Int
+     ctypedef unsigned int UInt
+     ctypedef void* Obj
+ 
+ 
+-cdef extern from "<gap/ariths.h>":
++cdef extern from "gap/ariths.h" nogil:
+     Obj SUM(Obj, Obj)
+     Obj DIFF(Obj, Obj)
+     Obj PROD(Obj, Obj)
+@@ -28,12 +28,12 @@ cdef extern from "<gap/ariths.h>":
+     bint LT(Obj opL, Obj opR)
+ 
+ 
+-cdef extern from "<gap/bool.h>":
++cdef extern from "gap/bool.h" nogil:
+     cdef Obj GAP_True "True"
+     cdef Obj GAP_False "False"
+ 
+ 
+-cdef extern from "<gap/calls.h>":
++cdef extern from "gap/calls.h" nogil:
+     bint IS_FUNC(Obj)
+     Obj CALL_0ARGS(Obj f)              # 0 arguments
+     Obj CALL_1ARGS(Obj f, Obj a1)      # 1 argument
+@@ -45,49 +45,47 @@ cdef extern from "<gap/calls.h>":
+     Obj CALL_XARGS(Obj f, Obj args)   # more than 6 arguments
+ 
+ 
+-cdef extern from "<gap/gasman.h>":
++cdef extern from "gap/gasman.h" nogil:
+     Obj NewBag "NewBag"(UInt type, UInt size)
+     void MarkBag(Obj bag)
+     UInt CollectBags(UInt size, UInt full)
+ 
+ 
+-cdef extern from "<gap/gasman_intern.h>":
++cdef extern from "gap/gasman_intern.h" nogil:
+     void CallbackForAllBags(void (*func)(Obj))
+ 
+ 
+-cdef extern from "<gap/gvars.h>":
++cdef extern from "gap/gvars.h" nogil:
+     UInt GVarName "GVarName"(char* name)
+     void AssGVar "AssGVar"(UInt gvar, Obj val)
+ 
+ 
+-cdef extern from "<gap/integer.h>":
++cdef extern from "gap/integer.h" nogil:
+     Int IS_INT(Obj)
+ 
+ 
+-cdef extern from "<gap/intobj.h>":
++cdef extern from "gap/intobj.h" nogil:
+     bint IS_INTOBJ(Obj obj)
+     Obj INTOBJ_INT(Int)
+     Int INT_INTOBJ(Obj)
+ 
+ 
+-cdef extern from "<gap/io.h>":
++cdef extern from "gap/io.h" nogil:
+     UInt OpenOutputStream(Obj stream)
+     UInt CloseOutput()
+ 
+ 
+-cdef extern from "<gap/libgap-api.h>":
+-    ctypedef void (*CallbackFunc)()
 -    void GAP_Initialize(int argc, char ** argv, char ** env,
 -        CallbackFunc, CallbackFunc)
+-    Obj GAP_EvalString(const char *) except *
+-    Obj GAP_EvalStringNoExcept "GAP_EvalString"(const char *)
+-    Obj GAP_ValueGlobalVariable(const char *)
+-
+-
+-cdef extern from "<gap/libgap-api.h>" nogil:
++cdef extern from "gap/libgap-api.h" nogil:
+     """
+     #define sig_GAP_Enter()  {int t = GAP_Enter(); if (!t) sig_error();}
+     """
++    ctypedef void (*GAP_CallbackFunc)()
 +    void GAP_Initialize(int argc, char ** argv,
-+        CallbackFunc, CallbackFunc, int handleSignals)
-     Obj GAP_EvalString(const char *) except *
-     Obj GAP_EvalStringNoExcept "GAP_EvalString"(const char *)
-     Obj GAP_ValueGlobalVariable(const char *)
++            GAP_CallbackFunc markBagsCallback, GAP_CallbackFunc errorCallback,
++            int handleSignals)
++    Obj GAP_EvalString(const char *) except *
++    Obj GAP_EvalStringNoExcept "GAP_EvalString"(const char *)
++    Obj GAP_ValueGlobalVariable(const char *)
+     cdef void GAP_EnterStack()
+     cdef void GAP_LeaveStack()
+     cdef int GAP_Enter() except 0
+@@ -96,7 +94,7 @@ cdef extern from "<gap/libgap-api.h>" nogil:
+     cdef int GAP_Error_Setjmp() except 0
+ 
+ 
+-cdef extern from "<gap/lists.h>":
++cdef extern from "gap/lists.h" nogil:
+     bint IS_LIST(Obj lst)
+     int LEN_LIST(Obj lst)
+     Obj ELM_LIST(Obj lst, int pos)
+@@ -104,15 +102,15 @@ cdef extern from "<gap/lists.h>":
+     void ASS_LIST(Obj lst, int pos, Obj elt)
+ 
+ 
+-cdef extern from "<gap/listfunc.h>":
++cdef extern from "gap/listfunc.h" nogil:
+     void AddList(Obj list, Obj obj)
+ 
+ 
+-cdef extern from "<gap/macfloat.h>":
++cdef extern from "gap/macfloat.h" nogil:
+     double VAL_MACFLOAT(Obj obj)
+ 
+ 
+-cdef extern from "<gap/objects.h>":
++cdef extern from "gap/objects.h" nogil:
+     bint IS_MUTABLE_OBJ(Obj obj)
+     Obj SHALLOW_COPY_OBJ(Obj obj)
+     Obj CopyObj(Obj obj, int mut)
+@@ -121,28 +119,34 @@ cdef extern from "<gap/objects.h>":
+     UInt TNUM_OBJ(Obj obj)
+     char* TNAM_OBJ(Obj obj)
+ 
+-    cdef int T_INTPOS
+-    cdef int T_INTNEG
+-    cdef int T_RAT
+-    cdef int T_CYC
+-    cdef int T_FFE
+-    cdef int T_PERM2
+-    cdef int T_PERM4
+-    cdef int T_BOOL
+-    cdef int T_CHAR
+-    cdef int T_FUNCTION
+-    cdef int T_MACFLOAT
+-    cdef int T_PLIST
+-    cdef int T_PLIST_CYC
+-    cdef int T_BLIST
+-    cdef int T_STRING
+-    cdef int T_COMOBJ
+-    cdef int T_POSOBJ
+-    cdef int T_DATOBJ
+-    cdef int T_WPOBJ
+-
+-
+-cdef extern from "<gap/precord.h>":
++    cdef enum TNUM:
++        T_INT
++        T_INTPOS
++        T_INTNEG
++        T_RAT
++        T_CYC
++        T_FFE
++        T_MACFLOAT
++        T_PERM2
++        T_PERM4
++        T_TRANS2
++        T_TRANS4
++        T_PPERM2
++        T_PPERM4
++        T_BOOL
++        T_CHAR
++        T_FUNCTION
++        T_PLIST
++        T_PLIST_CYC
++        T_BLIST
++        T_STRING
++        T_COMOBJ
++        T_POSOBJ
++        T_DATOBJ
++        T_WPOBJ
++
++
++cdef extern from "gap/precord.h" nogil:
+     Obj NEW_PREC(int len)
+     int LEN_PREC(Obj rec)
+     int GET_RNAM_PREC(Obj rec, int i)
+@@ -150,14 +154,14 @@ cdef extern from "<gap/precord.h>":
+     void AssPRec(Obj rec, UInt rnam, Obj val)
+ 
+ 
+-cdef extern from "<gap/records.h>":
++cdef extern from "gap/records.h" nogil:
+     char* NAME_RNAM(UInt rnam)
+     bint IS_REC(Obj obj)
+     Obj ELM_REC(Obj rec, UInt rnam)
+     UInt RNamName(Char* name)
+ 
+ 
+-cdef extern from "<gap/stringobj.h>":
++cdef extern from "gap/stringobj.h" nogil:
+     char* CSTR_STRING(Obj list)
+     bint IS_STRING(Obj obj)
+     bint IsStringConv(Obj obj)
+diff --git a/src/sage/libs/gap/libgap.pyx b/src/sage/libs/gap/libgap.pyx
+index e78b88a..e66be59 100644
+--- a/src/sage/libs/gap/libgap.pyx
++++ b/src/sage/libs/gap/libgap.pyx
+@@ -232,15 +232,6 @@ from sage.misc.superseded import deprecated_function_alias, deprecation
+ ### Debugging ##############################################################
+ ############################################################################
+ 
+-
+-cdef void report(Obj bag):
+-    print(TNAM_OBJ(bag),  <int>SIZE_OBJ(bag))
+-
+-
+-cdef void print_gasman_objects():
+-    CallbackForAllBags(report)
+-
+-
+ from sage.misc.lazy_import import is_during_startup
+ if is_during_startup():
+     import sys, traceback
 diff --git a/src/sage/libs/gap/util.pyx b/src/sage/libs/gap/util.pyx
-index 97c383fdbe..20ecc82976 100644
+index 7f6a924..27609f8 100644
 --- a/src/sage/libs/gap/util.pyx
 +++ b/src/sage/libs/gap/util.pyx
-@@ -329,8 +329,8 @@ cdef initialize():
-             # Initialize GAP and capture any error messages. The
-             # initialization just prints any errors and does not
-             # use the error handler.
+@@ -14,19 +14,16 @@ Utility functions for GAP
+ 
+ from __future__ import print_function, absolute_import
+ 
+-import os
+-import signal
+-import warnings
++from libc.signal cimport signal, SIGCHLD, SIG_DFL
+ from posix.dlfcn cimport dlopen, dlclose, RTLD_NOW, RTLD_GLOBAL
+-from libc.string cimport strcpy, strlen
+ 
+ from cpython.exc cimport PyErr_Fetch, PyErr_Restore
+ from cpython.object cimport Py_LT, Py_LE, Py_EQ, Py_NE, Py_GT, Py_GE
+ from cpython.ref cimport PyObject, Py_XINCREF, Py_XDECREF
+-from cysignals.memory cimport sig_malloc
+-from cysignals.pysignals import containsignals
+-from cysignals.signals cimport sig_on, sig_off, sig_error
++from cysignals.signals cimport sig_on, sig_off
+ 
++import os
++import warnings
+ import sage.env
+ 
+ from .gap_includes cimport *
+@@ -105,7 +102,7 @@ cdef class ObjWrapper(object):
+             sage: hash(x)
+             0
+         """
+-        return <int>(self.value)
++        return <Py_hash_t>(self.value)
+ 
+ 
+ cdef ObjWrapper wrap_obj(Obj obj):
+@@ -197,7 +194,6 @@ def gap_root():
+ 
+ # To ensure that we call initialize_libgap only once.
+ cdef bint _gap_is_initialized = False
+-cdef extern char **environ
+ 
+ 
+ cdef char* _reset_error_output_cmd = """\
+@@ -216,33 +212,6 @@ MakeImmutable(libgap_errout);
+ """
+ 
+ 
+-cdef char** copy_environ(char** env):
+-    """
+-    Make a copy of the environment block given by ``env``.
+-
+-    Returns a pointer to the copy, which is the caller's responsibility to
+-    free.
+-    """
+-
+-    cdef char** env_copy
+-    cdef int envc = 0;
+-    cdef int idx
+-    cdef size_t size
+-
+-    while env[envc]:
+-        envc += 1
+-
+-    env_copy = <char**>sig_malloc((envc + 1) * sizeof(char*))
+-
+-    for idx in range(envc):
+-        size = strlen(env[idx]) + 1
+-        env_copy[idx] = <char*>sig_malloc(size)
+-        strcpy(env_copy[idx], env[idx])
+-
+-    env_copy[envc] = NULL
+-    return env_copy
+-
+-
+ cdef initialize():
+     """
+     Initialize the GAP library, if it hasn't already been
+@@ -253,7 +222,7 @@ cdef initialize():
+         sage: libgap(123)   # indirect doctest
+         123
+     """
+-    global _gap_is_initialized, environ
++    global _gap_is_initialized
+     if _gap_is_initialized: return
+     # Hack to ensure that all symbols provided by libgap are loaded into the
+     # global symbol table
+@@ -268,10 +237,9 @@ cdef initialize():
+                 "be loaded!")
+     dlclose(handle)
+ 
+-    # Define argv and environ variables, which we will pass in to
++    # Define argv variable, which we will pass in to
+     # initialize GAP. Note that we must pass define the memory pool
+     # size!
+-    cdef char** env
+     cdef char* argv[18]
+     argv[0] = "sage"
+     argv[1] = "-l"
+@@ -318,21 +286,15 @@ cdef initialize():
+ 
+     argv[argc] = NULL
+ 
+-    env = copy_environ(environ)
+-
+-    # Need to save/restore current SIGINT handling since GAP_Initialize
+-    # currently clobbers it; it doesn't matter what we set SIGINT to
+-    # temporarily.
+-    with containsignals():
+-        sig_on()
+-        try:
+-            # Initialize GAP and capture any error messages. The
+-            # initialization just prints any errors and does not
+-            # use the error handler.
 -            GAP_Initialize(argc, argv, env, &gasman_callback,
 -                           &error_handler)
-+            GAP_Initialize(argc, argv, &gasman_callback,
-+                           &error_handler, 1)
-         finally:
-             sig_off()
+-        finally:
+-            sig_off()
++    sig_on()
++    # Initialize GAP but disable their SIGINT handler
++    GAP_Initialize(argc, argv, gasman_callback, error_handler,
++                   handleSignals=False)
++    sig_off()
++
++    # Disable GAP's SIGCHLD handler ChildStatusChanged(), which calls
++    # waitpid() on random child processes.
++    signal(SIGCHLD, SIG_DFL)
  
+     # Set the ERROR_OUTPUT global in GAP to an output stream in which to
+     # receive error output
+diff --git a/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py b/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
+index b3312b8..6d81f0a 100644
+--- a/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
++++ b/src/sage/tests/books/judson-abstract-algebra/sylow-sage.py
+@@ -225,7 +225,7 @@ r"""
  
+ ~~~~~~~~~~~~~~~~~~~~~~ ::
+ 
+-    sage: gap.version()
++    sage: gap.version()  # random
+     '4.10.0'
+ 
+ ~~~~~~~~~~~~~~~~~~~~~~ ::



More information about the arch-commits mailing list