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.

The original source files are missing some imports. gcc assumes implicit
function declaration, so the code compiles fine, but emscripten sets
 -Werror=implicit-function-declaration so it is a hard error.

--- a/BLAS/SRC/xerbla.c
+++ b/BLAS/SRC/xerbla.c
@@ -10,6 +10,8 @@
 		http://www.netlib.org/f2c/libf2c.zip
 */
 
+#include <stdio.h>
+
 #include "f2c.h"
 #include "blaswrap.h"

--- a/INSTALL/tstiee.c
+++ b/INSTALL/tstiee.c
@@ -10,6 +10,8 @@
 		http://www.netlib.org/f2c/libf2c.zip
 */
 
+#include <string.h>
+
 #include "f2c.h"
 #include "blaswrap.h"


From c1c714f1217ab6fba5ae1ceb6d0c4a9469490093 Mon Sep 17 00:00:00 2001
From: Michael Droettboom <mdboom@gmail.com>
Date: Fri, 18 Mar 2022 19:59:05 -0700
Subject: [PATCH 1/7] add missing import

The original source files are missing some imports. gcc assumes implicit
function declaration, so the code compiles fine, but emscripten sets
 -Werror=implicit-function-declaration so it is a hard error.
---
 BLAS/SRC/xerbla.c | 2 ++
 INSTALL/tstiee.c  | 2 ++
 2 files changed, 4 insertions(+)

diff --git a/BLAS/SRC/xerbla.c b/BLAS/SRC/xerbla.c
index 2d7baf5..da1d7fd 100644
--- a/BLAS/SRC/xerbla.c
+++ b/BLAS/SRC/xerbla.c
@@ -10,6 +10,8 @@
 		http://www.netlib.org/f2c/libf2c.zip
 */
 
+#include <stdio.h>
+
 #include "f2c.h"
 #include "blaswrap.h"
 
diff --git a/INSTALL/tstiee.c b/INSTALL/tstiee.c
index 2b5426f..89a41b8 100644
--- a/INSTALL/tstiee.c
+++ b/INSTALL/tstiee.c
@@ -10,6 +10,8 @@
 		http://www.netlib.org/f2c/libf2c.zip
 */
 
+#include <string.h>
+
 #include "f2c.h"
 #include "blaswrap.h"
 #include "string.h"
-- 
2.25.1

