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 7b56e1341c486422973dfa890158872200527b51 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 25 Dec 2021 20:31:40 -0800
Subject: [PATCH] Remove cuncsd, dorcsd, sorcsd, zuncsd

These functions don't work because their definitions involve code that isn't 
fortran 77 compliant. In order to get _flapack.so to link correctly, we need
to provide stub definitions for these functions, but they don't work. Remove
them to make sure people get an `AttributeError` if they try to use them 
rather than just having weird buggy code.

---
 scipy/linalg/__init__.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scipy/linalg/__init__.py b/scipy/linalg/__init__.py
index e88479b48..746bf3dce 100644
--- a/scipy/linalg/__init__.py
+++ b/scipy/linalg/__init__.py
@@ -191,6 +191,12 @@ Low-level routines
    `scipy.linalg.cython_lapack` -- Low-level LAPACK functions for Cython
 
 """  # noqa: E501
+from . import lapack
+del lapack.cuncsd
+del lapack.dorcsd
+del lapack.sorcsd
+del lapack.zuncsd
+del lapack
 
 from .misc import *
 from .basic import *
-- 
2.25.1


From 7b56e1341c486422973dfa890158872200527b51 Mon Sep 17 00:00:00 2001
From: Hood Chatham <roberthoodchatham@gmail.com>
Date: Sat, 25 Dec 2021 20:31:40 -0800
Subject: [PATCH] Remove cuncsd, dorcsd, sorcsd, zuncsd

These functions don't work because their definitions involve code that isn't 
fortran 77 compliant. In order to get _flapack.so to link correctly, we need
to provide stub definitions for these functions, but they don't work. Remove
them to make sure people get an `AttributeError` if they try to use them 
rather than just having weird buggy code.

---
 scipy/linalg/__init__.py | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/scipy/linalg/__init__.py b/scipy/linalg/__init__.py
index e88479b48..746bf3dce 100644
--- a/scipy/linalg/__init__.py
+++ b/scipy/linalg/__init__.py
@@ -191,6 +191,12 @@ Low-level routines
    `scipy.linalg.cython_lapack` -- Low-level LAPACK functions for Cython
 
 """  # noqa: E501
+from . import lapack
+del lapack.cuncsd
+del lapack.dorcsd
+del lapack.sorcsd
+del lapack.zuncsd
+del lapack
 
 from .misc import *
 from .basic import *
-- 
2.25.1

