With newer versions of emscripten, linker errors surface eariler.
This makes it easier to find function pointer cast errors without
having to execute the bad code path -- the errors happen when the
wasm modules are linked (at load time in the browser)

Anyways, this fixes more linker errors. Mostly the problems have
to do with LAPACK functions that take string arguments. Most
LAPACK functions that take string arguments use them as enums and
only care about the first character of the string. Because of the
way that f2c works, we need to replace these strings with the ascii
code of the first character so we should replace:

sTRSV( 'UPPER', 'NOTRANS', 'NONUNIT', J, H, LDH, Y, 1 )
==>
CALL sTRSV( 85, 78, 78, J, H, LDH, Y, 1 )

where 85 and 78 are the ascii codes of U and N. Various character
variables are subbed into being integer variables. The two
functions `ilaenv` and `xerbla` expect actual C strings as an
argument, but it is very annoying to produce C strings so instead
I added wrapper functions ilaenvf2c and xerblaf2c to clapack and
instead of calling ilaenv and xerbla we call the f2c versions.

Fix scipy linking errors. With newer versions of emscripten, linker errors surface eariler.
This makes it easier to find function pointer cast errors without
having to execute the bad code path -- the errors happen when the
wasm modules are linked (at load time in the browser)

Anyways, this fixes more linker errors. Mostly the problems have
to do with LAPACK functions that take string arguments. Most
LAPACK functions that take string arguments use them as enums and
only care about the first character of the string. Because of the
way that f2c works, we need to replace these strings with the ascii
code of the first character so we should replace:

sTRSV( 'UPPER', 'NOTRANS', 'NONUNIT', J, H, LDH, Y, 1 )
==>
CALL sTRSV( 85, 78, 78, J, H, LDH, Y, 1 )

where 85 and 78 are the ascii codes of U and N. Various character
variables are subbed into being integer variables. The two
functions `ilaenv` and `xerbla` expect actual C strings as an
argument, but it is very annoying to produce C strings so instead
I added wrapper functions ilaenvf2c and xerblaf2c to clapack and
instead of calling ilaenv and xerbla we call the f2c versions.

From 549ab1f7916e16222bdfc67a46f7a7b9b2125265 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 18 Dec 2021 11:41:15 -0800
Subject: [PATCH] gemm_ no const

cgemm, dgemm, sgemm, and zgemm are declared with `const` in slu_cdefs.h, but 
other places don't have the cosnt causing compile errors.
This patch drops the consts and fixes the problem.

---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
index 346f9af0a..8af19888f 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
@@ -272,9 +272,9 @@ extern void    ccheck_tempv(int, complex *);
 
 /*! \brief BLAS */
 
-extern int cgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const complex*, const complex*, const int*, const complex*,
-		  const int*, const complex*, complex*, const int*);
+extern int cgemm_( char*,  char*,  int*,  int*,  int*,
+                   complex*,  complex*,  int*,  complex*,
+		   int*,  complex*, complex*,  int*);
 extern int ctrsv_(char*, char*, char*, int*, complex*, int*,
                   complex*, int*);
 extern int ctrsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
index 934cd677a..33e869fb7 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
@@ -269,9 +269,9 @@ extern void    dcheck_tempv(int, double *);
 
 /*! \brief BLAS */
 
-extern int dgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const double*, const double*, const int*, const double*,
-		  const int*, const double*, double*, const int*);
+extern int dgemm_( char*,  char*,  int*,  int*,  int*,
+                   double*,  double*,  int*,  double*,
+		   int*,  double*, double*,  int*);
 extern int dtrsv_(char*, char*, char*, int*, double*, int*,
                   double*, int*);
 extern int dtrsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
index 1b6db977e..fee4bc1d6 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
@@ -269,9 +269,9 @@ extern void    scheck_tempv(int, float *);
 
 /*! \brief BLAS */
 
-extern int sgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const float*, const float*, const int*, const float*,
-		  const int*, const float*, float*, const int*);
+extern int sgemm_( char*,  char*,  int*,  int*,  int*,
+                   float*,  float*,  int*,  float*,
+		   int*,  float*, float*,  int*);
 extern int strsv_(char*, char*, char*, int*, float*, int*,
                   float*, int*);
 extern int strsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
index abb7d937e..6c572ff2b 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
@@ -272,9 +272,9 @@ extern void    zcheck_tempv(int, doublecomplex *);
 
 /*! \brief BLAS */
 
-extern int zgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const doublecomplex*, const doublecomplex*, const int*, const doublecomplex*,
-		  const int*, const doublecomplex*, doublecomplex*, const int*);
+extern int zgemm_( char*,  char*,  int*,  int*,  int*,
+                   doublecomplex*,  doublecomplex*,  int*,  doublecomplex*,
+		   int*,  doublecomplex*, doublecomplex*,  int*);
 extern int ztrsv_(char*, char*, char*, int*, doublecomplex*, int*,
                   doublecomplex*, int*);
 extern int ztrsm_(char*, char*, char*, char*, int*, int*,
-- 
2.25.1


From 549ab1f7916e16222bdfc67a46f7a7b9b2125265 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 18 Dec 2021 11:41:15 -0800
Subject: [PATCH] gemm_ no const

cgemm, dgemm, sgemm, and zgemm are declared with `const` in slu_cdefs.h, but 
other places don't have the cosnt causing compile errors.
This patch drops the consts and fixes the problem.

---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h | 6 +++---
 scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h | 6 +++---
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
index 346f9af0a..8af19888f 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_cdefs.h
@@ -272,9 +272,9 @@ extern void    ccheck_tempv(int, complex *);
 
 /*! \brief BLAS */
 
-extern int cgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const complex*, const complex*, const int*, const complex*,
-		  const int*, const complex*, complex*, const int*);
+extern int cgemm_( char*,  char*,  int*,  int*,  int*,
+                   complex*,  complex*,  int*,  complex*,
+		   int*,  complex*, complex*,  int*);
 extern int ctrsv_(char*, char*, char*, int*, complex*, int*,
                   complex*, int*);
 extern int ctrsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
index 934cd677a..33e869fb7 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_ddefs.h
@@ -269,9 +269,9 @@ extern void    dcheck_tempv(int, double *);
 
 /*! \brief BLAS */
 
-extern int dgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const double*, const double*, const int*, const double*,
-		  const int*, const double*, double*, const int*);
+extern int dgemm_( char*,  char*,  int*,  int*,  int*,
+                   double*,  double*,  int*,  double*,
+		   int*,  double*, double*,  int*);
 extern int dtrsv_(char*, char*, char*, int*, double*, int*,
                   double*, int*);
 extern int dtrsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
index 1b6db977e..fee4bc1d6 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_sdefs.h
@@ -269,9 +269,9 @@ extern void    scheck_tempv(int, float *);
 
 /*! \brief BLAS */
 
-extern int sgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const float*, const float*, const int*, const float*,
-		  const int*, const float*, float*, const int*);
+extern int sgemm_( char*,  char*,  int*,  int*,  int*,
+                   float*,  float*,  int*,  float*,
+		   int*,  float*, float*,  int*);
 extern int strsv_(char*, char*, char*, int*, float*, int*,
                   float*, int*);
 extern int strsm_(char*, char*, char*, char*, int*, int*,
diff --git a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
index abb7d937e..6c572ff2b 100644
--- a/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
+++ b/scipy/sparse/linalg/dsolve/SuperLU/SRC/slu_zdefs.h
@@ -272,9 +272,9 @@ extern void    zcheck_tempv(int, doublecomplex *);
 
 /*! \brief BLAS */
 
-extern int zgemm_(const char*, const char*, const int*, const int*, const int*,
-                  const doublecomplex*, const doublecomplex*, const int*, const doublecomplex*,
-		  const int*, const doublecomplex*, doublecomplex*, const int*);
+extern int zgemm_( char*,  char*,  int*,  int*,  int*,
+                   doublecomplex*,  doublecomplex*,  int*,  doublecomplex*,
+		   int*,  doublecomplex*, doublecomplex*,  int*);
 extern int ztrsv_(char*, char*, char*, int*, doublecomplex*, int*,
                   doublecomplex*, int*);
 extern int ztrsm_(char*, char*, char*, char*, int*, int*,
-- 
2.25.1

