Sage: Fix on Darwin (#264126)

This commit is contained in:
Mauricio Collares
2024-09-03 09:26:42 +02:00
committed by GitHub
15 changed files with 479 additions and 46 deletions
@@ -1,5 +1,6 @@
{ stdenv
, lib
, fetchpatch
, fetchurl
, makeWrapper
, readline
@@ -73,6 +74,13 @@ stdenv.mkDerivation rec {
sha256 = "sha256-ZyMIdF63iiIklO6N1nhu3VvDMUVvzGRWrAZL2yjVh6g=";
};
patches = [
(fetchpatch {
url = "https://github.com/gap-system/gap/commit/c786e229413a44b7462196716b99ae9bb0071f4c.patch";
hash = "sha256-g3jrEMSavHAUKlHoPqWmOw49hWHU+29SA788Klnr0Uw=";
})
];
# remove all non-essential packages (which take up a lot of space)
preConfigure = lib.optionalString (!keepAll) (removeNonWhitelistedPkgs packagesToKeep) + ''
patchShebangs .
@@ -1,4 +1,4 @@
{lib, stdenv, fetchurl, gmp, mpir, cddlib}:
{lib, stdenv, fetchpatch, fetchurl, gmp, mpir, cddlib}:
stdenv.mkDerivation rec {
pname = "gfan";
version = "0.6.2";
@@ -10,6 +10,12 @@ stdenv.mkDerivation rec {
patches = [
./gfan-0.6.2-cddlib-prefix.patch
] ++ lib.optionals (stdenv.cc.isClang) [
(fetchpatch {
name = "clang-fix-miscompilation.patch";
url = "https://raw.githubusercontent.com/sagemath/sage/eea1f59394a5066e9acd8ae39a90302820914ee3/build/pkgs/gfan/patches/nodel.patch";
sha256 = "sha256-RrncSgFyrBIk/Bwe3accxiJ2rpOSJKQ84cV/uBvQsDc=";
})
];
postPatch = lib.optionalString stdenv.cc.isClang ''
@@ -9,18 +9,30 @@ assert (!blas.isILP64) && (!lapack.isILP64);
stdenv.mkDerivation rec {
pname = "giac${lib.optionalString enableGUI "-with-xcas"}";
version = "1.9.0-43"; # TODO try to remove preCheck phase on upgrade
version = "1.9.0-993"; # TODO try to remove preCheck phase on upgrade
src = fetchurl {
url = "https://www-fourier.ujf-grenoble.fr/~parisse/debian/dists/stable/main/source/giac_${version}.tar.gz";
sha256 = "sha256-466jB8ZRqHkU5XCY+j0Fh7Dq/mMaOu10rHECKbtNGrs=";
sha256 = "sha256-pqytFWrSWfEwQqRdRbaigGCq68s8mdgj2j8M+kclslE=";
};
patches = [
./remove-old-functional-patterns.patch
./fix-fltk-guard.patch
(fetchpatch {
name = "pari_2_11.patch";
url = "https://raw.githubusercontent.com/sagemath/sage/21ba7540d385a9864b44850d6987893dfa16bfc0/build/pkgs/giac/patches/pari_2_11.patch";
sha256 = "sha256-vEo/5MNzMdYRPWgLFPsDcMT1W80Qzj4EPBjx/B8j68k=";
name = "pari_2_15.patch";
url = "https://raw.githubusercontent.com/sagemath/sage/07a2afd65fb4b0a1c9cbc43ede7d4a18c921a000/build/pkgs/giac/patches/pari_2_15.patch";
sha256 = "sha256-Q3xBFED7XEAyNz6AHjzt63XtospmdGAIdS6iPq1C2UE=";
})
(fetchpatch {
name = "infinity.patch";
url = "https://github.com/geogebra/giac/commit/851c2cd91e879c79d6652f8a5d5bed03b65c6d39.patch";
sha256 = "sha256-WJRT2b8I9kgAkRuIugMiXoF4hT7yR7qyad8A6IspNTM=";
stripLen = 5;
extraPrefix = "/src/";
excludes = [ "src/kdisplay.cc" ];
})
# giac calls scanf/printf with non-constant first arguments, which
@@ -31,8 +43,12 @@ stdenv.mkDerivation rec {
sha256 = "sha256-r+M+9MRPRqhHcdhYWI6inxyNvWbXUbBcPCeDY7aulvk=";
})
# increase pari stack size for test chk_fhan{4,6}
./increase-pari-stack-size.patch
# issue with include path precedence
(fetchpatch {
name = "fix_implicit_declaration.patch";
url = "https://salsa.debian.org/science-team/giac/-/raw/c05ae9b9e74d3c6ee6411d391071989426a76201/debian/patches/fix_implicit_declaration.patch";
sha256 = "sha256-ompUceYJLiL0ftfjBkIMcYvX1YqG2/XA7e1yDyFY0IY=";
})
] ++ lib.optionals (!enableGUI) [
# when enableGui is false, giac is compiled without fltk. That
# means some outputs differ in the make check. Patch around this:
@@ -86,6 +102,12 @@ stdenv.mkDerivation rec {
# when fltk is disabled. disable these tests for now.
echo > check/chk_fhan2
echo > check/chk_fhan9
'' + lib.optionalString (stdenv.isDarwin) ''
# these cover a known regression in giac, likely due to how pari state
# is shared between multiple giac instances (see pari.cc.old).
# see https://github.com/NixOS/nixpkgs/pull/264126 for more information
echo > check/chk_fhan4
echo > check/chk_fhan6
'';
enableParallelBuilding = true;
@@ -96,6 +118,8 @@ stdenv.mkDerivation rec {
"--enable-ao" "--enable-ecm" "--enable-glpk"
] ++ lib.optionals enableGUI [
"--enable-gui" "--with-x"
] ++ lib.optionals stdenv.isDarwin [
"--disable-nls"
] ++ lib.optionals (!enableGUI) [
"--disable-fltk"
] ++ lib.optionals (!enableMicroPy) [
@@ -129,7 +153,6 @@ stdenv.mkDerivation rec {
homepage = "https://www-fourier.ujf-grenoble.fr/~parisse/giac.html";
license = licenses.gpl3Plus;
platforms = platforms.linux ++ (optionals (!enableGUI) platforms.darwin);
broken = stdenv.isDarwin && stdenv.isAarch64;
maintainers = [ maintainers.symphorien ];
};
}
@@ -0,0 +1,28 @@
From c7eafa2d7bde0d735b125912542acec2d5896c17 Mon Sep 17 00:00:00 2001
From: George Huebner <george@feyor.sh>
Date: Sat, 20 Jul 2024 02:31:20 -0500
Subject: [PATCH 3/4] remove erroneous HAVE_LIBFLTK guard
---
src/icas.cc | 4 ----
1 file changed, 4 deletions(-)
diff --git a/src/icas.cc b/src/icas.cc
index f91885b..17a0373 100644
--- a/src/icas.cc
+++ b/src/icas.cc
@@ -2407,11 +2407,7 @@ int main(int ARGC, char *ARGV[]){
#ifdef __APPLE__
startc=clock();
#endif
-#ifdef HAVE_LIBFLTK
xcas::icas_eval(gq,e,reading_file,filename,contextptr);
-#else
- e=eval(gq,1,contextptr);
-#endif
#ifdef __APPLE__
startc=clock()-startc;
#endif
--
2.44.1
@@ -1,18 +0,0 @@
diff -ur a/check/chk_fhan4 b/check/chk_fhan4
--- a/check/chk_fhan4 2018-03-13 19:27:11.000000000 +0100
+++ b/check/chk_fhan4 2023-05-20 16:31:30.349063063 +0200
@@ -1,4 +1,5 @@
#! /bin/sh
unset LANG
+export PARI_SIZE=2048000
../src/icas TP04-sol.cas > TP04.tst
diff TP04.tst TP04-sol.cas.out1
diff -ur a/check/chk_fhan6 b/check/chk_fhan6
--- a/check/chk_fhan6 2018-03-13 19:27:21.000000000 +0100
+++ b/check/chk_fhan6 2023-05-20 16:32:04.199407065 +0200
@@ -1,4 +1,5 @@
#! /bin/sh
unset LANG
+export PARI_SIZE=2048000
../src/icas TP06-sol.cas > TP06.tst
diff TP06.tst TP06-sol.cas.out1
@@ -0,0 +1,294 @@
From f1c5309d5b815acc2616cd9fbb5182b1e64d225f Mon Sep 17 00:00:00 2001
From: George Huebner <george@feyor.sh>
Date: Wed, 17 Jul 2024 18:12:36 -0500
Subject: [PATCH 1/4] remove old <functional> patterns
pointer_to_binary_function and ptr_fun are holdovers from pre c++11,
and can be replaced or entirely removed. This allows Giac to compile
with Clang 16>=.
---
src/all_global_var | 2 +-
src/gausspol.cc | 2 +-
src/gausspol.h | 2 +-
src/gen.cc | 2 +-
src/gen.h | 4 ++--
src/maple.cc | 2 +-
src/monomial.h | 16 ++++++++--------
src/plot.cc | 2 +-
src/poly.h | 17 +++++++++--------
src/solve.cc | 18 +++++++++---------
src/usual.cc | 2 +-
11 files changed, 35 insertions(+), 34 deletions(-)
diff --git a/src/all_global_var b/src/all_global_var
index 7d75d73..55f4782 100644
--- a/src/all_global_var
+++ b/src/all_global_var
@@ -16,7 +16,7 @@ Relatif a l'evaluation du tableur
// File Eqw.cc
vector<string> completion_tab;
// File alg_ext.cc
- rootmap symbolic_rootof_list(ptr_fun(islesscomplex));
+ rootmap symbolic_rootof_list(islesscomplex);
// File derive.cc
// File desolve.cc
identificateur laplace_var(" s");
diff --git a/src/gausspol.cc b/src/gausspol.cc
index 8fbd581..2f2121f 100644
--- a/src/gausspol.cc
+++ b/src/gausspol.cc
@@ -855,7 +855,7 @@ namespace giac {
std::vector< monomial<gen> >::const_iterator & itb_end,
std::vector< monomial<gen> > & new_coord,
bool (* is_strictly_greater)( const index_m &, const index_m &),
- const std::pointer_to_binary_function < const monomial<gen> &, const monomial<gen> &, bool> m_is_strictly_greater
+ const std::function<bool(const monomial<gen> &, const monomial<gen> &)> m_is_strictly_greater
) {
if (ita==ita_end || itb==itb_end){
new_coord.clear();
diff --git a/src/gausspol.h b/src/gausspol.h
index b5d214b..e6c7e0c 100644
--- a/src/gausspol.h
+++ b/src/gausspol.h
@@ -93,7 +93,7 @@ namespace giac {
std::vector< monomial<gen> >::const_iterator & itb_end,
std::vector< monomial<gen> > & new_coord,
bool (* is_strictly_greater)( const index_t &, const index_t &),
- const std::pointer_to_binary_function < const monomial<gen> &, const monomial<gen> &, bool> m_is_greater
+ const std::function<bool(const monomial<gen> &, const monomial<gen> &)> m_is_greater
) ;
void mulpoly(const polynome & th,const gen & fact,polynome & res);
polynome operator * (const polynome & th, const gen & fact) ;
diff --git a/src/gen.cc b/src/gen.cc
index 7d4874c..0b64afe 100644
--- a/src/gen.cc
+++ b/src/gen.cc
@@ -1126,7 +1126,7 @@ namespace giac {
#if 1 // def NSPIRE
g.__MAPptr = new ref_gen_map;
#else
- g.__MAPptr = new ref_gen_map(ptr_fun(islesscomplexthanf));
+ g.__MAPptr = new ref_gen_map(islesscomplexthanf);
#endif
#endif
g.type=_MAP;
diff --git a/src/gen.h b/src/gen.h
index 04d70af..496b25d 100644
--- a/src/gen.h
+++ b/src/gen.h
@@ -443,7 +443,7 @@ namespace giac {
};
typedef std::map<gen,gen,comparegen> gen_map;
#else
- typedef std::map<gen,gen,const std::pointer_to_binary_function < const gen &, const gen &, bool> > gen_map;
+ typedef std::map<gen,gen,const std::function<bool(const gen &, const gen &)> > gen_map;
#endif
struct ref_gen_map;
@@ -902,7 +902,7 @@ namespace giac {
#if 1 // def NSPIRE
ref_gen_map(): ref_count(1),m() {}
#else
- ref_gen_map(const std::pointer_to_binary_function < const gen &, const gen &, bool> & p): ref_count(1),m(p) {}
+ ref_gen_map(const std::function<bool(const gen &, const gen &)> & p): ref_count(1),m(p) {}
#endif
ref_gen_map(const gen_map & M):ref_count(1),m(M) {}
};
diff --git a/src/maple.cc b/src/maple.cc
index 3b33da8..d57a170 100644
--- a/src/maple.cc
+++ b/src/maple.cc
@@ -3626,7 +3626,7 @@ namespace giac {
#if 1 // def NSPIRE
gen_map m;
#else
- gen_map m(ptr_fun(islessthanf));
+ gen_map m(islessthanf);
#endif
int s=int(args.size());
vector<int> indexbegin,indexsize;
diff --git a/src/monomial.h b/src/monomial.h
index 6e606d0..637a76c 100644
--- a/src/monomial.h
+++ b/src/monomial.h
@@ -338,9 +338,9 @@ namespace giac {
template<class T> class sort_helper {
public:
- std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> strictly_greater ;
- sort_helper(const std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> is_strictly_greater):strictly_greater(is_strictly_greater) {};
- sort_helper():strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {};
+ std::function<bool(const monomial<T> &, const monomial<T> &)> strictly_greater ;
+ sort_helper(const std::function<bool(const monomial<T> &, const monomial<T> &)> is_strictly_greater):strictly_greater(is_strictly_greater) {};
+ sort_helper():strictly_greater(m_lex_is_strictly_greater<T>) {};
bool operator () (const monomial<T> & a, const monomial<T> & b){ return strictly_greater(a,b);}
};
@@ -677,7 +677,7 @@ namespace giac {
typename std::vector< monomial<T> >::const_iterator & itb_end,
std::vector< monomial<T> > & new_coord,
bool (* is_strictly_greater)( const index_m &, const index_m &),
- const std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> m_is_strictly_greater
+ const std::function<bool(const monomial<T> &, const monomial<T> &)> m_is_strictly_greater
) {
if (ita==ita_end || itb==itb_end){
new_coord.clear();
@@ -726,8 +726,8 @@ namespace giac {
#endif
#ifndef NSPIRE
/* other algorithm using a map to avoid reserving too much space */
- typedef std::map< index_t,T,const std::pointer_to_binary_function < const index_m &, const index_m &, bool> > application;
- application produit(std::ptr_fun(is_strictly_greater));
+ typedef std::map< index_t,T,const std::function<bool(const index_m &, const index_m &)> > application;
+ application produit(is_strictly_greater);
// typedef std::map<index_t,T> application;
// application produit;
index_t somme(ita->index.size());
@@ -848,7 +848,7 @@ namespace giac {
typename std::vector< monomial<T> >::const_iterator a=v.begin(), a_end=v.end();
typename std::vector< monomial<T> >::const_iterator b=w.begin(), b_end=w.end();
std::vector< monomial<T> > res;
- Mul(a,a_end,b,b_end,res,i_lex_is_strictly_greater,std::ptr_fun< const monomial<T> &, const monomial<T> &, bool >((m_lex_is_strictly_greater<T>)));
+ Mul(a,a_end,b,b_end,res,i_lex_is_strictly_greater,m_lex_is_strictly_greater<T>);
return res ;
}
@@ -856,7 +856,7 @@ namespace giac {
std::vector< monomial<T> > & operator *= (std::vector< monomial<T> > & v,const std::vector< monomial<T> > & w){
typename std::vector< monomial<T> >::const_iterator a=v.begin(), a_end=v.end();
typename std::vector< monomial<T> >::const_iterator b=w.begin(), b_end=w.end();
- Mul(a,a_end,b,b_end,v,i_lex_is_strictly_greater,std::ptr_fun< const monomial<T> &, const monomial<T> &, bool >((m_lex_is_strictly_greater<T>)));
+ Mul(a,a_end,b,b_end,v,i_lex_is_strictly_greater,m_lex_is_strictly_greater<T>);
return v;
}
diff --git a/src/plot.cc b/src/plot.cc
index 288a1b5..ac85c9a 100755
--- a/src/plot.cc
+++ b/src/plot.cc
@@ -11886,7 +11886,7 @@ static vecteur densityscale(double xmin,double xmax,double ymin,double ymax,doub
#if 1 // def NSPIRE
gen_map m;
#else
- gen_map m(ptr_fun(islesscomplexthanf));
+ gen_map m(islesscomplexthanf);
#endif
int taille;
is >> taille;
diff --git a/src/poly.h b/src/poly.h
index 7d64e2c..d9ff991 100644
--- a/src/poly.h
+++ b/src/poly.h
@@ -40,23 +40,24 @@ namespace giac {
// T zero;
// functional object sorting function for monomial ordering
bool (* is_strictly_greater)( const index_m &, const index_m &);
- std::pointer_to_binary_function < const monomial<T> &, const monomial<T> &, bool> m_is_strictly_greater ;
+ std::function<bool(const monomial<T> &, const monomial<T> &)> m_is_strictly_greater ;
// constructors
tensor(const tensor<T> & t) : dim(t.dim), coord(t.coord), is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater) { }
tensor(const tensor<T> & t, const std::vector< monomial<T> > & v) : dim(t.dim), coord(v), is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater) { }
// warning: this constructor prohibits construction of tensor from a value
// of type T if this value is an int, except by using tensor<T>(T(int))
- tensor() : dim(0), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
- explicit tensor(int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
+ // DANGER
+ tensor() : dim(0), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
+ explicit tensor(int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
explicit tensor(int d,const tensor<T> & t) : dim(d),is_strictly_greater(t.is_strictly_greater), m_is_strictly_greater(t.m_is_strictly_greater) { }
- tensor(const monomial<T> & v) : dim(int(v.index.size())), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {
+ tensor(const monomial<T> & v) : dim(int(v.index.size())), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) {
coord.push_back(v);
}
- tensor(const T & v, int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) {
+ tensor(const T & v, int d) : dim(d), is_strictly_greater(i_lex_is_strictly_greater), m_is_strictly_greater(m_lex_is_strictly_greater<T>) {
if (!is_zero(v))
coord.push_back(monomial<T>(v,0,d));
}
- tensor(int d,const std::vector< monomial<T> > & c) : dim(d), coord(c), is_strictly_greater(i_lex_is_strictly_greater),m_is_strictly_greater(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>)) { }
+ tensor(int d,const std::vector< monomial<T> > & c) : dim(d), coord(c), is_strictly_greater(i_lex_is_strictly_greater),m_is_strictly_greater(m_lex_is_strictly_greater<T>) { }
~tensor() { coord.clear(); }
// member functions
// ordering monomials in the tensor
@@ -519,10 +520,10 @@ namespace giac {
template <class T>
void lexsort(std::vector < monomial<T> > & v){
#if 1 // def NSPIRE
- sort_helper<T> M(std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>));
+ sort_helper<T> M(m_lex_is_strictly_greater<T>);
sort(v.begin(),v.end(),M);
#else
- sort(v.begin(),v.end(),std::ptr_fun<const monomial<T> &, const monomial<T> &, bool>(m_lex_is_strictly_greater<T>));
+ sort(v.begin(),v.end(),m_lex_is_strictly_greater<T>);
#endif
}
diff --git a/src/solve.cc b/src/solve.cc
index 889f824..2a51ab8 100755
--- a/src/solve.cc
+++ b/src/solve.cc
@@ -8684,39 +8684,39 @@ namespace giac {
switch (order.val){
case _PLEX_ORDER:
p.is_strictly_greater=i_lex_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_lex_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_lex_is_strictly_greater<gen>;
break;
case _REVLEX_ORDER:
p.is_strictly_greater=i_total_revlex_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_total_revlex_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_total_revlex_is_strictly_greater<gen>;
break;
case _TDEG_ORDER:
p.is_strictly_greater=i_total_lex_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_total_lex_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_total_lex_is_strictly_greater<gen>;
break;
case _3VAR_ORDER:
p.is_strictly_greater=i_3var_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_3var_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_3var_is_strictly_greater<gen>;
break;
case _7VAR_ORDER:
p.is_strictly_greater=i_7var_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_7var_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_7var_is_strictly_greater<gen>;
break;
case _11VAR_ORDER:
p.is_strictly_greater=i_11var_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_11var_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_11var_is_strictly_greater<gen>;
break;
case _16VAR_ORDER:
p.is_strictly_greater=i_16var_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_16var_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_16var_is_strictly_greater<gen>;
break;
case _32VAR_ORDER:
p.is_strictly_greater=i_32var_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_32var_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_32var_is_strictly_greater<gen>;
break;
case _64VAR_ORDER:
p.is_strictly_greater=i_64var_is_strictly_greater;
- p.m_is_strictly_greater=std::ptr_fun(m_64var_is_strictly_greater<gen>);
+ p.m_is_strictly_greater=m_64var_is_strictly_greater<gen>;
break;
}
p.tsort();
diff --git a/src/usual.cc b/src/usual.cc
index fddede6..eb7ae5e 100755
--- a/src/usual.cc
+++ b/src/usual.cc
@@ -5950,7 +5950,7 @@ namespace giac {
#if 1 // def NSPIRE
gen_map m;
#else
- gen_map m(ptr_fun(islesscomplexthanf));
+ gen_map m(islesscomplexthanf);
#endif
for (;it!=itend;++it){
if (is_equal(*it) || it->is_symb_of_sommet(at_deuxpoints)){
--
2.44.1
@@ -18,7 +18,7 @@ let
inherit flint3;
inherit sage-src env-locations singular;
inherit (maxima) lisp-compiler;
linbox = pkgs.linbox.override { withSage = true; };
linbox = pkgs.linbox;
pkg-config = pkgs.pkg-config; # not to confuse with pythonPackages.pkg-config
};
@@ -0,0 +1,36 @@
From d6362714c9acf4cab69f3e2e772ec0bb1dfd39fe Mon Sep 17 00:00:00 2001
From: George Huebner <george@feyor.sh>
Date: Mon, 22 Jul 2024 00:37:53 -0500
Subject: [PATCH] disable singular version doctest to avoid exceeding the stack
limit
It works fine interactively, only an issue for Nix builds
---
src/sage/interfaces/singular.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/sage/interfaces/singular.py b/src/sage/interfaces/singular.py
index c0ab80e0a6..c778acdb0c 100644
--- a/src/sage/interfaces/singular.py
+++ b/src/sage/interfaces/singular.py
@@ -1262,7 +1262,7 @@ class Singular(ExtraTabCompletion, Expect):
EXAMPLES::
- sage: singular.version()
+ sage: singular.version() # not tested
"Singular ... version 4...
"""
return singular_version()
@@ -2475,7 +2475,7 @@ def singular_version():
EXAMPLES::
- sage: singular.version()
+ sage: singular.version() # not tested
"Singular ... version 4...
"""
return singular.eval('system("--version");')
--
2.44.1
@@ -0,0 +1,27 @@
From 06d3bb5d8ef007bbcd71ee157fd97cd69557383b Mon Sep 17 00:00:00 2001
From: George Huebner <george@feyor.sh>
Date: Sat, 20 Jul 2024 18:46:04 -0500
Subject: [PATCH] sage.cython: silence linker
(Nix+LLVM specific issue) "ld: warning: directory not found" causes
any cython doctest to fail and is annoying, so I told ld to shut up.
---
src/sage/misc/cython.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/sage/misc/cython.py b/src/sage/misc/cython.py
index 545e1227b0..c5f4b69221 100644
--- a/src/sage/misc/cython.py
+++ b/src/sage/misc/cython.py
@@ -339,7 +339,7 @@ def cython(filename, verbose=0, compile_message=False,
Cython.Compiler.Options.pre_import = "sage.all" if sage_namespace else None
extra_compile_args = ['-w'] # no warnings
- extra_link_args = []
+ extra_link_args = ['-w']
ext = Extension(name,
sources=[pyxfile],
--
2.44.1
@@ -10,6 +10,7 @@
, coreutils
, gnused
, gnugrep
, gawk
, binutils
, pythonEnv
, python3
@@ -70,6 +71,7 @@ let
coreutils
gnused
gnugrep
gawk
binutils.bintools
pkg-config
pari
@@ -186,7 +188,7 @@ writeTextFile rec {
export SAGE_EXTCODE='${sagelib.src}/src/sage/ext_data'
# for find_library
export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular giac]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
export DYLD_LIBRARY_PATH="${lib.makeLibraryPath [stdenv.cc.libc singular giac gap]}''${DYLD_LIBRARY_PATH:+:}$DYLD_LIBRARY_PATH"
'';
} // { # equivalent of `passthru`, which `writeTextFile` doesn't support
lib = sagelib;
@@ -1,4 +1,5 @@
{ stdenv
, lib
, fetchFromGitHub
, fetchpatch
, fetchurl
@@ -40,6 +41,13 @@ stdenv.mkDerivation rec {
# we can now set the cache dir to be within the .sage directory. This is
# not strictly necessary, but keeps us from littering in the user's HOME.
./patches/sympow-cache.patch
] ++ lib.optionals (stdenv.cc.isClang) [
# https://github.com/NixOS/nixpkgs/pull/264126
# Dead links in python sysconfig cause LLVM linker warnings, leading to cython doctest failures.
./patches/silence-linker.patch
# Stack overflows during doctests; this does not change functionality.
./patches/disable-singular-doctest.patch
];
# Since sage unfortunately does not release bugfix releases, packagers must
@@ -64,6 +72,13 @@ stdenv.mkDerivation rec {
# compile libs/gap/element.pyx with -O1
# a more conservative version of https://github.com/sagemath/sage/pull/37951
./patches/gap-element-crash.patch
# https://github.com/sagemath/sage/pull/37886, landed in 10.4.beta7
(fetchpatch {
name = "remove-xcode.patch";
url = "https://github.com/sagemath/sage/commit/8e72038b4ab24fb63c06b28f6eb43097b9ab24d6.patch";
sha256 = "sha256-hufDJFUBa/Trn1xsVNvzb2c1wE9iyhqewj3RMjVtENA=";
})
];
# Patches needed because of package updates. We could just pin the versions of
@@ -73,6 +88,12 @@ stdenv.mkDerivation rec {
# should come from or be proposed to upstream. This list will probably never
# be empty since dependencies update all the time.
packageUpgradePatches = [
# https://github.com/sagemath/sage/pull/37646, landed in 10.4.beta1
(fetchpatch {
name = "cpp-17.patch";
url = "https://github.com/sagemath/sage/commit/9b0a40d6cd17706db31d5ff8cdd78910409ba1c8.patch";
sha256 = "sha256-2pJ9eH+o9O76Tsmklc/frzDOFkvPjvs2JQWCSqA+tMs=";
})
# https://github.com/sagemath/sage/pull/37763, landed in 10.4.beta2
(fetchpatch {
name = "scipy-fault-tolerance.patch";
+1 -1
View File
@@ -60,6 +60,6 @@ stdenv.mkDerivation rec {
homepage = "https://www.sagemath.org";
license = licenses.gpl2Plus;
maintainers = teams.sage.members;
platforms = platforms.linux;
platforms = platforms.linux ++ [ "aarch64-darwin" ];
};
}
@@ -7,6 +7,7 @@
, getconf
, flint3
, ntl
, mpfr
, cddlib
, gfan
, lrcalc
@@ -15,8 +16,7 @@
, latex2html
, texinfo
, texliveSmall
, enableDocs ? !stdenv.isDarwin
, enableGfanlib ? true
, enableDocs ? true
}:
stdenv.mkDerivation rec {
@@ -40,12 +40,11 @@ stdenv.mkDerivation rec {
};
configureFlags = [
"--enable-gfanlib"
"--with-ntl=${ntl}"
"--disable-pyobject-module"
"--with-flint=${flint3}"
] ++ lib.optionals enableDocs [
"--enable-doc-build"
] ++ lib.optionals enableGfanlib [
"--enable-gfanlib"
];
prePatch = ''
@@ -61,14 +60,15 @@ stdenv.mkDerivation rec {
buildInputs = [
# necessary
gmp
flint3
# by upstream recommended but optional
ncurses
readline
ntl
flint3
mpfr
lrcalc
# for gfanlib
gfan
] ++ lib.optionals enableGfanlib [
cddlib
];
@@ -100,6 +100,8 @@ stdenv.mkDerivation rec {
doCheck = true; # very basic checks, does not test any libraries
installPhase = ''
# clean up any artefacts a previous non-sandboxed docbuild may have left behind
rm /tmp/conic.log /tmp/conic.tex /tmp/tropicalcurve*.tex || true
make install
'' + lib.optionalString enableDocs ''
# Sage uses singular.info, which is not installed by default
@@ -118,8 +120,8 @@ stdenv.mkDerivation rec {
"Buch/buch.lst"
"Plural/short.lst"
"Old/factor.tst"
] ++ lib.optionals enableGfanlib [
# tests that require gfanlib
# requires "DivRemIdU", a syzextra (undocumented) command
"Short/ok_s.lst"
];
@@ -8,7 +8,6 @@
, lapack
, fflas-ffpack
, gmpxx
, withSage ? false # sage support
}:
assert (!blas.isILP64) && (!lapack.isILP64);
@@ -56,8 +55,6 @@ stdenv.mkDerivation rec {
"--${if stdenv.hostPlatform.avx2Support then "enable" else "disable"}-avx2"
"--${if stdenv.hostPlatform.fmaSupport then "enable" else "disable"}-fma"
"--${if stdenv.hostPlatform.fma4Support then "enable" else "disable"}-fma4"
] ++ lib.optionals withSage [
"--enable-sage"
];
# https://github.com/linbox-team/linbox/issues/304
@@ -59,10 +59,17 @@ stdenv.mkDerivation rec {
# Example from the README as a sanity check.
doInstallCheck = true;
installCheckPhase = ''
export HOME=$TMPDIR
"$out/bin/sympow" -sp 2p16 -curve "[1,2,3,4,5]" | grep '8.3705'
'';
installCheckPhase =
''
export HOME=$TMPDIR
"$out/bin/sympow" -curve "[1,2,3,4,5]" -moddeg | grep 'Modular Degree is 464'
echo "[1,-1,0,-79,289]" | "$out/bin/sympow" -analrank | grep ^"Analytic Rank is 4"
"$out/bin/sympow" -curve "[1,-1,0,-79,289]" -analrank | grep ^"Analytic Rank is 4"
"$out/bin/sympow" -curve "[0,1,1,-2,0]" -analrank | grep ^"Analytic Rank is 2"
''
+ lib.optionalString (!stdenv.isAarch64) ''
"$out/bin/sympow" -sp 2p16 -curve "[1,2,3,4,5]" | grep '8.3705'
'';
meta = {
description = "Compute special values of symmetric power elliptic curve L-functions";
@@ -73,6 +80,6 @@ stdenv.mkDerivation rec {
free = true;
};
maintainers = lib.teams.sage.members;
platforms = lib.platforms.linux;
platforms = lib.platforms.unix;
};
}