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 16abd462459b36c73db23b776f1eb5ab2c0c7813 Mon Sep 17 00:00:00 2001
From: Hood <hood@mit.edu>
Date: Thu, 24 Jun 2021 14:55:10 -0700
Subject: [PATCH 09/10] xfail core ctypes tests that don't work

PyCode_SetExtra doesn't work and ctypes doesn't seem to work with variadic functions including PyUnicode_FromFormat/
---
 Lib/test/test_code.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index b9c4f8bdcb..31cb8876c8 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -396,6 +396,7 @@ def test_bad_index(self):
                               ctypes.c_voidp(100)), 0)
 
         def test_free_called(self):
+            raise unittest.SkipTest("PyCode_SetExtra is broken")
             # Verify that the provided free function gets invoked
             # when the code object is cleaned up.
             f = self.get_func()
@@ -405,6 +406,7 @@ def test_free_called(self):
             self.assertEqual(LAST_FREED, 100)
 
         def test_get_set(self):
+            raise unittest.SkipTest("PyCode_SetExtra is broken")
             # Test basic get/set round tripping.
             f = self.get_func()
 
@@ -421,6 +423,7 @@ def test_get_set(self):
             del f
 
         def test_free_different_thread(self):
+            raise unittest.SkipTest("Requires threading")
             # Freeing a code object on a different thread then
             # where the co_extra was set should be safe.
             f = self.get_func()
@@ -445,8 +448,8 @@ def test_main(verbose=None):
     from test import test_code
     run_doctest(test_code, verbose)
     tests = [CodeTest, CodeConstsTest, CodeWeakRefTest]
-    if check_impl_detail(cpython=True) and ctypes is not None:
-        tests.append(CoExtra)
+    # if check_impl_detail(cpython=True) and ctypes is not None:
+    #     tests.append(CoExtra)
     run_unittest(*tests)
 
 if __name__ == "__main__":
-- 
2.25.1


From 16abd462459b36c73db23b776f1eb5ab2c0c7813 Mon Sep 17 00:00:00 2001
From: Hood <hood@mit.edu>
Date: Thu, 24 Jun 2021 14:55:10 -0700
Subject: [PATCH 09/10] xfail core ctypes tests that don't work

PyCode_SetExtra doesn't work and ctypes doesn't seem to work with variadic functions including PyUnicode_FromFormat/
---
 Lib/test/test_code.py | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/Lib/test/test_code.py b/Lib/test/test_code.py
index b9c4f8bdcb..31cb8876c8 100644
--- a/Lib/test/test_code.py
+++ b/Lib/test/test_code.py
@@ -396,6 +396,7 @@ def test_bad_index(self):
                               ctypes.c_voidp(100)), 0)
 
         def test_free_called(self):
+            raise unittest.SkipTest("PyCode_SetExtra is broken")
             # Verify that the provided free function gets invoked
             # when the code object is cleaned up.
             f = self.get_func()
@@ -405,6 +406,7 @@ def test_free_called(self):
             self.assertEqual(LAST_FREED, 100)
 
         def test_get_set(self):
+            raise unittest.SkipTest("PyCode_SetExtra is broken")
             # Test basic get/set round tripping.
             f = self.get_func()
 
@@ -421,6 +423,7 @@ def test_get_set(self):
             del f
 
         def test_free_different_thread(self):
+            raise unittest.SkipTest("Requires threading")
             # Freeing a code object on a different thread then
             # where the co_extra was set should be safe.
             f = self.get_func()
@@ -445,8 +448,8 @@ def test_main(verbose=None):
     from test import test_code
     run_doctest(test_code, verbose)
     tests = [CodeTest, CodeConstsTest, CodeWeakRefTest]
-    if check_impl_detail(cpython=True) and ctypes is not None:
-        tests.append(CoExtra)
+    # if check_impl_detail(cpython=True) and ctypes is not None:
+    #     tests.append(CoExtra)
     run_unittest(*tests)
 
 if __name__ == "__main__":
-- 
2.25.1

