commit:     cc8a349543ff2f0529cb43a31460c0636f7efc9c
Author:     NHOrus <jy6x2b32pie9 <AT> yahoo <DOT> com>
AuthorDate: Fri Feb 21 18:59:25 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Mon Feb 24 21:25:02 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cc8a3495

sci-libs/taucs: add 2.2.1, port to C23, fix musl build.

Fixes problem with breaking handwritten makefile and config generator
that uses mkdir to test for OS (Windows/Linux)
Also fixes other build problems with GCC-15
Correcting ebuild to work on musl system was unpleasant and it looks
ugly. Such is life with horrible, hand-written makefile generator

Closes: https://bugs.gentoo.org/886467
Closes: https://bugs.gentoo.org/898294
Closes: https://bugs.gentoo.org/832812
Closes: https://bugs.gentoo.org/898296
Signed-off-by: NHOrus <jy6x2b32pie9 <AT> yahoo.com>
Closes: https://github.com/gentoo/gentoo/pull/40691
Signed-off-by: Sam James <sam <AT> gentoo.org>

 sci-libs/taucs/Manifest                            |   1 +
 .../taucs/files/taucs-2.2-missing-include.patch    |  36 +++++++
 sci-libs/taucs/files/taucs-2.2.1-C23.patch         | 120 +++++++++++++++++++++
 .../taucs-2.2.1-allocate-memory-in-test.patch      |  24 +++++
 sci-libs/taucs/metadata.xml                        |   3 +
 sci-libs/taucs/taucs-2.2.1.ebuild                  |  84 +++++++++++++++
 6 files changed, 268 insertions(+)

diff --git a/sci-libs/taucs/Manifest b/sci-libs/taucs/Manifest
index 9b29e0457de2..9a15069f512d 100644
--- a/sci-libs/taucs/Manifest
+++ b/sci-libs/taucs/Manifest
@@ -1 +1,2 @@
+DIST taucs-2.2.1.tar.gz 1594127 BLAKE2B 
426f5a6f919415480a14d231233214d4e560ecfb257b67751fc26ce0897acab504ee50d0dd074dd99c9c0b74c1bcad2c2f88e8a9708107a5c2dfe52d452eba02
 SHA512 
727f05a7ea89cb74893905b17571ae9275db283e0fbe1d5538dfd72c0f9ed1a47325b1845b1e8b381793a513b4b538b35d503f5dbb63db222e1b01fd1169f1e9
 DIST taucs-2.2.tgz 1573863 BLAKE2B 
21cf7479d7ce1f27678431e0d3dcaea1b3f8b11071b44651207791d6980bf5be0ed51cab7915f9e8da88d5da777c0f03a8d058e2ac8881e0d0b244ddfd796f5c
 SHA512 
d8652de2da343dfd19c4278ac99313bcb577d976decdd3bd3875f0c9576832605b787feaef916eb4e82f22907c8bd029125c2ae56c827639e4d535ad62f20fcf

diff --git a/sci-libs/taucs/files/taucs-2.2-missing-include.patch 
b/sci-libs/taucs/files/taucs-2.2-missing-include.patch
new file mode 100644
index 000000000000..b5186aef3911
--- /dev/null
+++ b/sci-libs/taucs/files/taucs-2.2-missing-include.patch
@@ -0,0 +1,36 @@
+I don't know why he uses number of arguments to distinguish if
+it's windows or not. Add correct header, section off wrong
+mkdirs on Windows
+https://bugs.gentoo.org/898294
+--- a/configurator/taucs_config.c
++++ b/configurator/taucs_config.c
+@@ -1,6 +1,7 @@
+ #include <stdio.h>
+ #include <stdlib.h>
+ #include <string.h>
++#include <sys/stat.h>
+ 
+ #include "taucs_structure.h"
+ 
+@@ -242,8 +242,10 @@
+     sprintf(name,"%s%c%s",  configdir,pathsep,ostype);
+ 
+   if (win32) {
++#if defined _WIN32 || defined __CYGWIN__
+     mkdir(configdir);
+     mkdir(name);
++#endif
+   }
+   else {
+     mkdir(configdir,0777);
+@@ -301,8 +303,10 @@
+     sprintf(name,"%s%c%s",  configdir,pathsep,ostype);
+ 
+   if (win32) {
++#if defined _WIN32 || defined __CYGWIN__
+     mkdir(configdir);
+     mkdir(name);
++#endif
+   }
+   else {
+     mkdir(configdir,0777);

diff --git a/sci-libs/taucs/files/taucs-2.2.1-C23.patch 
b/sci-libs/taucs/files/taucs-2.2.1-C23.patch
new file mode 100644
index 000000000000..dec900f8603b
--- /dev/null
+++ b/sci-libs/taucs/files/taucs-2.2.1-C23.patch
@@ -0,0 +1,120 @@
+Port to C23. Various problems without the bug
+found in bumping package version
+--- a/src/taucs_ccs_ooc_llt.c
++++ b/src/taucs_ccs_ooc_llt.c
+@@ -281,7 +281,7 @@
+                              int            do_order,
+                              int            ipostorder[],
+                              double         given_mem,
+-                             void           (*sn_struct_handler)(),
++                             void           (*sn_struct_handler)(void* 
argument, int sn, int sn_up_size, int* sn_struct_ptr[]),
+                              void*          sn_struct_handler_arg
+                              )
+ {
+@@ -455,7 +455,7 @@
+                                  int do_order,
+                                  int do_column_to_sn_map,
+                                  double given_mem,
+-                                 void           (*sn_struct_handler)(),
++                                 void           (*sn_struct_handler)(void* 
argument, int sn, int sn_up_size, int* sn_struct_ptr[]),
+                                  void*          sn_struct_handler_arg
+                                  )
+ {
+--- a/src/taucs_vaidya.c
++++ b/src/taucs_vaidya.c
+@@ -3046,7 +3046,7 @@
+   int row, col;
+   int *pi1 = 0; /* warning */
+   double x, y, min, max, not;
+-  byte bool=1;
++  byte Bool=1;
+   edge *p,*dummy, *pe ,*max_pe;
+   int count = 0;
+  
+@@ -3116,18 +3116,18 @@
+         
+         for(minrho=1;minrho<maxdist;minrho++)
+           {
+-            bool = 1;
++            Bool = 1;
+             for(k=0;k<min(j,classes);k++)
+               {
+                 if 
((double)(findrho[(minrho+1)*classes+k]-findrho[minrho*classes+k]) > 
(findrho[minrho*classes+k])/x)
+-                  bool = 0;
++                  Bool = 0;
+               }
+-            if (bool)
++            if (Bool)
+               goto afterr;
+           }
+       
+       afterr:
+-        if (bool)
++        if (Bool)
+           {
+             for(i=0;i<n;i++)
+               if ((d[i] <= minrho) && (d[i] != -1) )
+--- a/progs/direct.c
++++ b/progs/direct.c
+@@ -691,7 +691,6 @@
+   /***********************************************************/
+ 
+   if (A->flags & TAUCS_SINGLE) {
+-    float snrm2_();
+     int one = 1;
+ 
+     NormErr = 0.0;
+@@ -704,7 +703,6 @@
+   } 
+ 
+   if (A->flags & TAUCS_DOUBLE) {
+-    double dnrm2_();
+     int one = 1;
+ 
+     NormErr = 0.0;
+@@ -718,7 +716,6 @@
+ 
+ #ifdef TAUCS_CONFIG_DCOMPLEX
+   if (A->flags & TAUCS_DCOMPLEX) {
+-    double dznrm2_();
+     int one = 1;
+     double* pX  = (double*) Xz;
+     double* pNX = (double*) NXz;
+--- a/progs/direct_coverage.c
++++ b/progs/direct_coverage.c
+@@ -729,7 +729,6 @@
+   /***********************************************************/
+ 
+   if (A->flags & TAUCS_SINGLE) {
+-    float snrm2_();
+     int one = 1;
+ 
+     NormErr = 0.0;
+@@ -742,7 +741,6 @@
+   } 
+ 
+   if (A->flags & TAUCS_DOUBLE) {
+-    double dnrm2_();
+     int one = 1;
+ 
+     NormErr = 0.0;
+@@ -755,7 +753,6 @@
+   }
+ 
+   if (A->flags & TAUCS_DCOMPLEX) {
+-    double dznrm2_();
+     int one = 1;
+     double* pX  = (double*) Xz;
+     double* pNX = (double*) NXz;
+diff '--color=auto' -ur taucs-2.2.1.old/progs/test_cilk_snmf.c 
taucs-2.2.1/progs/test_cilk_snmf.c
+--- taucs-2.2.1.old/progs/test_cilk_snmf.c     2025-02-21 22:18:08.370013676 
+0400
++++ taucs-2.2.1/progs/test_cilk_snmf.c 2025-02-21 22:18:37.175471226 +0400
+@@ -27,8 +27,6 @@
+ #define my_dnrm2 dnrm2
+ #endif
+ 
+-double my_dnrm2();
+-
+ int main()
+ {
+   int xyz = 30;

diff --git a/sci-libs/taucs/files/taucs-2.2.1-allocate-memory-in-test.patch 
b/sci-libs/taucs/files/taucs-2.2.1-allocate-memory-in-test.patch
new file mode 100644
index 000000000000..2aed8c1bc757
--- /dev/null
+++ b/sci-libs/taucs/files/taucs-2.2.1-allocate-memory-in-test.patch
@@ -0,0 +1,24 @@
+There may be more actions needed, before that memory was unallocated
+and nullptrs were dereferenced.
+--- a/progs/test_cilk_snmf.c
++++ b/progs/test_cilk_snmf.c
+@@ -54,6 +54,7 @@
+ 
+   Xd =(double*)malloc((A->n)*sizeof(double));
+   for(i=0; i<A->n; i++) (Xd)[i]=(float)((double)random()/RAND_MAX);
++  Bd =(double*)malloc((A->n)*sizeof(double));
+   taucs_ccs_times_vec(A,Xd,Bd);
+ 
+   taucs_ccs_order(A,&perm,&invperm,"metis");
+@@ -74,8 +75,11 @@
+     return 1;
+   }
+ 
++  PBd =(double*)malloc((A->n)*sizeof(double));
+   taucs_vec_permute(A->n,A->flags,Bd,PBd,perm);
++  NXd =(double*)malloc((A->n)*sizeof(double));
+   taucs_supernodal_solve_llt(L,PBd,NXd); /* direct solver */
++  PXd =(double*)malloc((A->n)*sizeof(double));
+   taucs_vec_ipermute(A->n,A->flags,PXd,NXd,perm);
+ 
+   {

diff --git a/sci-libs/taucs/metadata.xml b/sci-libs/taucs/metadata.xml
index db08cf08723b..dda4de5504d0 100644
--- a/sci-libs/taucs/metadata.xml
+++ b/sci-libs/taucs/metadata.xml
@@ -25,4 +25,7 @@
                * Multilevel-Support-Graph Preconditioners.
                * Utility Routines
        </longdescription>
+       <upstream>
+               <remote-id type="github">sivantoledo/taucs</remote-id>
+       </upstream>
 </pkgmetadata>

diff --git a/sci-libs/taucs/taucs-2.2.1.ebuild 
b/sci-libs/taucs/taucs-2.2.1.ebuild
new file mode 100644
index 000000000000..c8bc53a1478d
--- /dev/null
+++ b/sci-libs/taucs/taucs-2.2.1.ebuild
@@ -0,0 +1,84 @@
+# Copyright 1999-2025 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+inherit fortran-2 toolchain-funcs
+
+DESCRIPTION="C library of sparse linear solvers"
+HOMEPAGE="https://github.com/sivantoledo/taucs/";
+SRC_URI="https://github.com/sivantoledo/taucs/archive/v${PV}.tar.gz -> 
${P}.tar.gz"
+
+LICENSE="LGPL-2.1"
+SLOT="0"
+KEYWORDS="~amd64 ~x86 ~amd64-linux ~x86-linux"
+IUSE="doc"
+RESTRICT="test"
+
+RDEPEND="
+       sci-libs/metis
+       virtual/blas
+       virtual/lapack"
+DEPEND="${RDEPEND}"
+BDEPEND="virtual/pkgconfig"
+
+PATCHES=(
+       # bug 725588
+       "${FILESDIR}"/${PN}-2.2-respect-ar.patch
+       "${FILESDIR}"/${PN}-2.2-missing-include.patch
+       "${FILESDIR}"/${P}-C23.patch
+       "${FILESDIR}"/${P}-allocate-memory-in-test.patch
+)
+
+src_configure() {
+       cat > config/linux_shared.mk <<-EOF || die
+               AR=$(tc-getAR)
+               FC=$(tc-getFC)
+               CC=$(tc-getCC)
+               LD=$(tc-getFC)
+               RANLIB=$(tc-getRANLIB)
+               CFLAGS=${CFLAGS} -fPIC
+               FFLAGS=${FFLAGS} -fPIC
+               LDFLAGS=${LDFLAGS} -fPIC
+               LIBBLAS=$($(tc-getPKG_CONFIG) --libs blas)
+               LIBLAPACK=$($(tc-getPKG_CONFIG) --libs lapack)
+               LIBMETIS=$($(tc-getPKG_CONFIG) --libs metis)
+               LIBF77=
+       EOF
+       # no cat <<EOF because -o has a trailing space
+       cp config/linux.mk config/linux-musl.mk
+       cp config/linux_shared.mk config/linux-musl_shared.mk
+}
+
+src_compile() {
+       # not autotools configure. Uses difference in mkdir signature
+       # between windows and linux to recognize system.
+       CC="$(tc-getCC)" ./configure variant=_shared || die
+       emake
+
+       cd lib/linux$(usev elibc_musl -musl)_shared || die
+       $(tc-getFC) ${LDFLAGS} -shared -Wl,-soname=libtaucs.so.1 \
+               -Wl,--whole-archive libtaucs.a -Wl,--no-whole-archive \
+               $($(tc-getPKG_CONFIG) --libs blas lapack metis) \
+               -o libtaucs.so.1.0.0 \
+               || die "shared lib linking failed"
+}
+
+src_test() {
+       LD_LIBRARY_PATH=lib/linux$(usev elibc_musl -musl)_shared \
+               ./testscript variant=_shared || die "compile test failed"
+       if grep -q FAILED testscript.log; then
+               eerror "Test failed. See ${S}/testscript.log"
+               die "test failed"
+       fi
+}
+
+src_install() {
+       ln -s libtaucs.so.1.0.0 lib/linux$(usev elibc_musl 
-musl)_shared/libtaucs.so.1 || die
+       ln -s libtaucs.so.1 lib/linux$(usev elibc_musl 
-musl)_shared/libtaucs.so || die
+       dolib.so lib/linux$(usev elibc_musl -musl)_shared/libtaucs.so*
+
+       doheader build/*/*.h src/*.h
+
+       use doc && dodoc doc/*.pdf
+}

Reply via email to