From bdd9d582bbb67712b9312709f9fdbdd43066dc2c Mon Sep 17 00:00:00 2001 From: oreo639 Date: Sat, 5 Apr 2025 02:42:27 -0700 Subject: [PATCH] linbox: fix build with gcc14 --- srcpkgs/linbox/patches/gcc14.patch | 432 +++++++++++++++++++++++++++++ srcpkgs/linbox/template | 2 +- 2 files changed, 433 insertions(+), 1 deletion(-) create mode 100644 srcpkgs/linbox/patches/gcc14.patch diff --git a/srcpkgs/linbox/patches/gcc14.patch b/srcpkgs/linbox/patches/gcc14.patch new file mode 100644 index 00000000000..b9adf7f294f --- /dev/null +++ b/srcpkgs/linbox/patches/gcc14.patch @@ -0,0 +1,432 @@ +Source: https://src.fedoraproject.org/rpms/linbox/blob/7389d46e81dc00dcb952b2ccbbbec3fb4fcc6c8b/f/0001-const_cast-missing.patch +Taken from: https://github.com/linbox-team/linbox/commit/b8f2d4ccdc0af4418d14f72caf6c4d01969092a3 + +From c614c401386ee8db014a9be56244888f7b282a18 Mon Sep 17 00:00:00 2001 +From: Jean-Guillaume Dumas +Date: Fri, 26 Jan 2024 16:31:56 +0100 +Subject: [PATCH] const_cast missing faster empty init + +--- + linbox/algorithms/gauss/gauss-nullspace.inl | 10 +- + .../matrix/sparsematrix/sparse-ell-matrix.h | 8 +- + .../matrix/sparsematrix/sparse-ellr-matrix.h | 18 +-- + linbox/ring/ntl/ntl-lzz_p.h | 11 +- + linbox/ring/ntl/ntl-lzz_pe.h | 143 +++++++++--------- + linbox/ring/ntl/ntl-zz_px.h | 6 + + 6 files changed, 104 insertions(+), 92 deletions(-) + +diff --git a/linbox/algorithms/gauss/gauss-nullspace.inl b/linbox/algorithms/gauss/gauss-nullspace.inl +index 0b70e1d7c..2d6032563 100644 +--- a/linbox/algorithms/gauss/gauss-nullspace.inl ++++ b/linbox/algorithms/gauss/gauss-nullspace.inl +@@ -2,7 +2,7 @@ + * Copyright (C) LinBox 2008 + * + * Written by Jean-Guillaume Dumas +- * Time-stamp: <27 Aug 20 15:17:09 Jean-Guillaume.Dumas@imag.fr> ++ * Time-stamp: <26 Jan 24 16:05:55 Jean-Guillaume.Dumas@imag.fr> + * + * + * ========LICENCE======== +@@ -104,11 +104,11 @@ namespace LinBox + + Permutation P(field(),(int)Nj); + +- // A.write( std::cerr << "A:=", Tag::FileFormat::Maple ) << ';' << std::endl; ++// A.write( std::cerr << "A:=", Tag::FileFormat::Maple ) << ';' << std::endl; + this->InPlaceLinearPivoting(Rank, Det, A, P, Ni, Nj ); + +- // P.write( std::cerr << "P:=", Tag::FileFormat::Maple ) << ';' << std::endl; +- // A.write( std::cerr << "Ua:=", Tag::FileFormat::Maple ) << ';' << std::endl; ++// P.write( std::cerr << "P:=", Tag::FileFormat::Maple ) << ';' << std::endl; ++// A.write( std::cerr << "Ua:=", Tag::FileFormat::Maple ) << ';' << std::endl; + + for(size_t i=0; i< Ni; ++i) { + if (A[i].size() == 0) { +@@ -123,7 +123,7 @@ namespace LinBox + } + } + +- // A.write( std::cerr << "Ub:=", Tag::FileFormat::Maple ) << ';' << std::endl; ++// A.write( std::cerr << "Ub:=", Tag::FileFormat::Maple ) << ';' << std::endl; + + return this->nullspacebasis(x, Rank, A, P); + } +diff --git a/linbox/matrix/sparsematrix/sparse-ell-matrix.h b/linbox/matrix/sparsematrix/sparse-ell-matrix.h +index 59006d6c5..2604f47b8 100644 +--- a/linbox/matrix/sparsematrix/sparse-ell-matrix.h ++++ b/linbox/matrix/sparsematrix/sparse-ell-matrix.h +@@ -1210,10 +1210,10 @@ namespace LinBox + _colid_beg = iter._colid_beg ; + _colid_it = iter._colid_it ; + _data_it = iter._data_it ; +- _data_beg = iter._data_beg ; +- _data_end = iter._data_end ; +- _field = iter._field ; +- _ld = iter._ld ; ++ const_cast(_data_beg) = iter._data_beg ; ++ const_cast(_data_end) = iter._data_end ; ++ const_cast(_field) = iter._field ; ++ const_cast(ld) = iter._ld ; + _row = iter._row ; + + return *this; +diff --git a/linbox/matrix/sparsematrix/sparse-ellr-matrix.h b/linbox/matrix/sparsematrix/sparse-ellr-matrix.h +index 498a5525d..a60943868 100644 +--- a/linbox/matrix/sparsematrix/sparse-ellr-matrix.h ++++ b/linbox/matrix/sparsematrix/sparse-ellr-matrix.h +@@ -1102,11 +1102,11 @@ namespace LinBox + _Iterator &operator = (const _Iterator &iter) + { + _data_it = iter._data_it ; +- _data_beg = iter._data_beg ; +- _data_end = iter._data_end ; +- _field = iter._field ; +- _rowid = iter._rowid; +- _ld = iter._ld ; ++ const_cast(_data_beg) = iter._data_beg ; ++ const_cast(_data_end)= iter._data_end ; ++ const_cast(_field) = iter._field ; ++ const_cast&>(_rowid) = iter._rowid; ++ const_cast(ld) = iter._ld ; + _row = iter._row ; + + return *this; +@@ -1252,10 +1252,10 @@ namespace LinBox + _colid_beg = iter._colid_beg ; + _colid_it = iter._colid_it ; + _data_it = iter._data_it ; +- _data_beg = iter._data_beg ; +- _data_end = iter._data_end ; +- _field = iter._field ; +- _ld = iter._ld ; ++ const_cast(_data_beg) = iter._data_beg ; ++ const_cast(_data_end) = iter._data_end ; ++ const_cast(_field) = iter._field ; ++ const_cast(ld)= iter._ld ; + _row = iter._row ; + + return *this; +diff --git a/linbox/ring/ntl/ntl-lzz_p.h b/linbox/ring/ntl/ntl-lzz_p.h +index 201baaa35..def3a23f7 100644 +--- a/linbox/ring/ntl/ntl-lzz_p.h ++++ b/linbox/ring/ntl/ntl-lzz_p.h +@@ -85,7 +85,7 @@ namespace Givaro + * @param x reference to Integer to contain output (reference returned). + * @param y constant reference to field element. + */ +- template <> ++ template <> + Integer& Caster(Integer& x, const NTL::zz_p& y) + { + return x = int64_t(rep(y)); +@@ -130,7 +130,7 @@ namespace LinBox + typedef NTL::zz_p Element ; + typedef Givaro::UnparametricOperations Father_t ; + typedef UnparametricRandIter RandIter; +- ++ + const Element zero,one,mOne ; + + +@@ -145,6 +145,11 @@ namespace LinBox + ,zero( NTL::to_zz_p(0)),one( NTL::to_zz_p(1)),mOne(-one) + {} + ++ Element &init (Element &x) const ++ { ++ return x = NTL::to_zz_p(0); ++ } ++ + Element& init(Element& x, const double& y) const + { + double z = fmod(y,(double)Element::modulus()); +@@ -153,7 +158,7 @@ namespace LinBox + return x = NTL::to_zz_p(static_cast(z)); //rounds towards 0 + } + +- Element &init (Element &x, const integer &y=0) const ++ Element &init (Element &x, const integer &y) const + { + NTL::ZZ tmp= NTL::to_ZZ(std::string(y).data()); + return x = NTL::to_zz_p(tmp); +diff --git a/linbox/ring/ntl/ntl-lzz_pe.h b/linbox/ring/ntl/ntl-lzz_pe.h +index 60b132a06..d53444b69 100644 +--- a/linbox/ring/ntl/ntl-lzz_pe.h ++++ b/linbox/ring/ntl/ntl-lzz_pe.h +@@ -96,18 +96,18 @@ namespace LinBox + NTL::zz_pE::init(irredPoly); + _f = irredPoly; + } +- ++ + NTL_zz_pE_Initialiser( const Integer & p, const NTL::zz_pX & f) { + NTL::zz_p::init((int64_t) p); + NTL::zz_pE::init(f); + _f = f; + } +- ++ + NTL_zz_pE_Initialiser(const NTL::zz_pX &f) { + NTL::zz_pE::init(f); + _f = f; + } +- ++ + const NTL::zz_pX& modulus() const { + return _f; + } +@@ -143,22 +143,22 @@ namespace LinBox + NTL_zz_pE (const integer &p, const integer &k) : + NTL_zz_pE_Initialiser(p,k),Father_t () + { +- init(const_cast(zero), 0); +- init(const_cast(one), 1); +- init(const_cast(mOne), p-1); ++ init(const_cast(zero), 0); ++ init(const_cast(one), 1); ++ init(const_cast(mOne), p-1); + } +- ++ + NTL_zz_pE (const integer &p, const NTL::zz_pX &f) : + NTL_zz_pE_Initialiser(p,f), Father_t() + { + init(const_cast(zero), 0); +- init(const_cast(one), 1); +- init(const_cast(mOne), p-1); ++ init(const_cast(one), 1); ++ init(const_cast(mOne), p-1); + } +- ++ + NTL_zz_pE(const NTL_zz_pE &F) : +- NTL_zz_pE_Initialiser(F.modulus()), Father_t(), +- zero(NTL::to_zz_pE(0)), one(NTL::to_zz_pE(1)), mOne(-one) ++ NTL_zz_pE_Initialiser(F.modulus()), Father_t(), ++ zero(NTL::to_zz_pE(0)), one(NTL::to_zz_pE(1)), mOne(-one) + { + } + +@@ -182,15 +182,15 @@ namespace LinBox + + bool isUnit (const Element& x) const + { +- if (isZero(x)) { +- return false; +- } +- +- NTL::zz_pX g, tmp; +- tmp = NTL::conv(x); +- NTL::GCD(g, tmp, modulus()); +- +- return g == 1; ++ if (isZero(x)) { ++ return false; ++ } ++ ++ NTL::zz_pX g, tmp; ++ tmp = NTL::conv(x); ++ NTL::GCD(g, tmp, modulus()); ++ ++ return g == 1; + } + + bool isMOne (const Element& x) const +@@ -207,7 +207,9 @@ namespace LinBox + return f; + } + +- Element & init(Element & x, integer n = 0) const ++ Element & init(Element & x) const { return x; } ++ ++ Element & init(Element & x, integer n) const + { // assumes n >= 0. + int e = exponent(); + n %= cardinality(); +@@ -215,14 +217,14 @@ namespace LinBox + //write(std::cout << "init-ed ", x) << std::endl; + return x; + } +- ++ + // documentation of NTL::conv: + // http://www.shoup.net/ntl/doc/conversions.txt + // XXX = long, ZZ, ZZ_p, ZZ_pE, ZZ_pX + template + Element &init(Element &x, const XXX &y) const { +- x = NTL::conv(y); +- return x; ++ x = NTL::conv(y); ++ return x; + } + + integer & convert(integer & x, const Element & y) const +@@ -279,81 +281,80 @@ namespace LinBox + x=one/x; + return x; + } +- ++ + Element& div(Element &x, const Element &y, const Element &z) const { +- NTL::zz_pX g, zx; +- conv(zx, z); +- NTL::GCD(g, zx, modulus()); +- +- NTL::zz_pE zg; +- conv(zg, zx / g); +- x = NTL::conv(NTL::conv(y) / g); +- x /= zg; +- +- return x; ++ NTL::zz_pX g, zx; ++ conv(zx, z); ++ NTL::GCD(g, zx, modulus()); ++ ++ NTL::zz_pE zg; ++ conv(zg, zx / g); ++ x = NTL::conv(NTL::conv(y) / g); ++ x /= zg; ++ ++ return x; + } +- ++ + Element& divin(Element &x, const Element &y) const { +- Element r; +- div(r, x, y); +- return x = r; ++ Element r; ++ div(r, x, y); ++ return x = r; + } + + bool isDivisor(const Element &x, const Element &y) const { +- if (isZero(y)) { +- return false; +- } +- +- if (isUnit(y)) { +- return true; +- } +- +- NTL::zz_pX a, b; +- conv(a, x); +- conv(b, y); +- +- NTL::zz_pX ga, gb; +- NTL::GCD(ga, a, modulus()); +- NTL::GCD(gb, b, modulus()); +- +- NTL::zz_pX r; +- r = ga % gb; +- return isZero(NTL::conv(r)); ++ if (isZero(y)) { ++ return false; ++ } ++ ++ if (isUnit(y)) { ++ return true; ++ } ++ ++ NTL::zz_pX a, b; ++ conv(a, x); ++ conv(b, y); ++ ++ NTL::zz_pX ga, gb; ++ NTL::GCD(ga, a, modulus()); ++ NTL::GCD(gb, b, modulus()); ++ NTL::zz_pX r; ++ r = ga % gb; ++ return isZero(NTL::conv(r)); + } +- ++ + Element& gcd(Element &g, const Element &a, const Element &b) const { + NTL::zz_pX r1, r2, x, y; + conv(x, a); + conv(y, b); +- ++ + NTL::GCD(r1, x, modulus()); + NTL::GCD(r2, y, r1); +- ++ + return g = NTL::conv(r2); + } +- ++ + Element& gcdin(Element &a, const Element &b) const { + NTL::zz_pE g; + gcd(g, a, b); + return a = g; + } +- ++ + Element& dxgcd(Element &g, Element &s, Element &t, Element &u, Element &v, const Element &a, const Element &b) const { + NTL::zz_pX gx, sx, tx, ux, vx, ax, bx; + conv(ax, a); + conv(bx, b); +- ++ + NTL::XGCD(gx, sx, tx, ax, bx); +- ++ + ux = ax / gx; + vx = bx / gx; +- ++ + conv(g, gx); + conv(s, sx); + conv(t, tx); + conv(u, ux); + conv(v, vx); +- ++ + return g; + } + +@@ -364,12 +365,12 @@ namespace LinBox + x=NTL::to_zz_pE(tmp); + return is; + } +- ++ + std::ostream& write( std::ostream& os ) const + { + return os << "Polynomial quotient ring using NTL::zz_pE"; + } +- ++ + std::ostream& write( std::ostream& os, const Element& x) const { + os << x; + return os; +@@ -429,7 +430,7 @@ namespace LinBox + uint64_t _seed; + const NTL_zz_pE& _ring; + }; // class UnparametricRandIters +- ++ + } // LinBox + + #endif //__LINBOX_ntl_lzz_pe_H +diff --git a/linbox/ring/ntl/ntl-zz_px.h b/linbox/ring/ntl/ntl-zz_px.h +index 6e7d5b2fd..340df9f95 100644 +--- a/linbox/ring/ntl/ntl-zz_px.h ++++ b/linbox/ring/ntl/ntl-zz_px.h +@@ -104,6 +104,12 @@ namespace LinBox + ,_CField(cf) + {} + ++ /** Initialize p to 0 */ ++ Element& init( Element& p ) const ++ { ++ return p = 0; ++ } ++ + /** Initialize p to the constant y (p = y*x^0) */ + template + Element& init( Element& p, const ANY& y ) const +-- +2.43.0 + diff --git a/srcpkgs/linbox/template b/srcpkgs/linbox/template index e6edacdd0a7..4fe38f7da78 100644 --- a/srcpkgs/linbox/template +++ b/srcpkgs/linbox/template @@ -1,7 +1,7 @@ # Template file for 'linbox' pkgname=linbox version=1.7.0 -revision=1 +revision=2 build_style=gnu-configure hostmakedepends="pkg-config" makedepends="fflas-ffpack"