Skip to content

Commit f9f8ec2

Browse files
committed
pythongh-96426: Include EMSDK version in SOABI, disable abi3
Emscripten does not provide a stable ABI, yet. Shared libraries include the Emscripten SDK version, for example ``.cpython-312-wasm32-emscripten-3_1_19.so``. Unqualified extensions with ``.abi3.so`` or ``.so`` suffix are no longer supported.
1 parent 13c309f commit f9f8ec2

File tree

6 files changed

+38
-4
lines changed

6 files changed

+38
-4
lines changed

Diff for: Doc/library/intro.rst

+10
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,16 @@ DOM APIs as well as limited networking capabilities with JavaScript's
112112
links are limited and don't support some operations. For example, WASI does
113113
not permit symlinks with absolute file names.
114114

115+
* ``wasm32-emscripten`` has optional support for shared extensions. Since
116+
Emscripten does not provide a stable ABI, yet. Shared libraries include
117+
the Emscripten SDK version, for example
118+
``.cpython-312-wasm32-emscripten-3_1_19.so``. Unqualified extensions with
119+
``.abi3.so`` or ``.so`` suffix are not supported.
120+
121+
* ``wasm32-wasi`` does not support shared extensions, yet. All extensions
122+
must be compiled into the main WASM binary.
123+
124+
115125
.. _WebAssembly: https://webassembly.org/
116126
.. _Emscripten: https://emscripten.org/
117127
.. _Emscripten Networking: https://emscripten.org/docs/porting/networking.html>

Diff for: Lib/test/test_imp.py

+15
Original file line numberDiff line numberDiff line change
@@ -456,5 +456,20 @@ def test_unencodeable(self):
456456
os.rmdir(name)
457457

458458

459+
@unittest.skipUnless(support.is_emscripten, "Emscripten specific test")
460+
@requires_load_dynamic
461+
class EmscriptenSuffixes(unittest.TestCase):
462+
def test_extension_suffixes(self):
463+
# see gh-96426
464+
suffixes = _imp.extension_suffixes()
465+
uname = os.uname()
466+
release = uname.release.replace(".", "_")
467+
shortver = f"{sys.version_info.major}{sys.version_info.minor}"
468+
self.assertEqual(
469+
suffixes,
470+
[f".cpython-{shortver}-{uname.machine}-emscripten-{release}.so"]
471+
)
472+
473+
459474
if __name__ == "__main__":
460475
unittest.main()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
``wasm32-emscripten`` platform now include the Emscripten SDK version in
2+
platform triplet and suffix for shared extension modules (``SOABI``).
3+
Extensions with `.abi3.so` and `.so` are no longer importable. This avoids
4+
problems with ABI incompatible builds or accidental mixing of ELF shared
5+
extensions and WASM shared extensions.

Diff for: Python/dynload_shlib.c

+4
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,12 @@ const char *_PyImport_DynLoadFiletab[] = {
4242
#ifdef ALT_SOABI
4343
"." ALT_SOABI ".so",
4444
#endif
45+
#if !defined(__EMSCRIPTEN__)
46+
// gh-96426: Emscripten has no stable ABI, only support extensions
47+
// with full SOABI, e.g. ".cpython-312-wasm32-emscripten-3_1_19.so".
4548
".abi" PYTHON_ABI_STRING ".so",
4649
".so",
50+
#endif // Emscripten
4751
#endif /* __CYGWIN__ */
4852
NULL,
4953
};

Diff for: configure

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: configure.ac

+2-2
Original file line numberDiff line numberDiff line change
@@ -1051,15 +1051,15 @@ cat > conftest.c <<EOF
10511051
vxworks
10521052
#elif defined(__wasm32__)
10531053
# if defined(__EMSCRIPTEN__)
1054-
wasm32-emscripten
1054+
wasm32-emscripten - __EMSCRIPTEN_major__ _ __EMSCRIPTEN_minor__ _ __EMSCRIPTEN_tiny__
10551055
# elif defined(__wasi__)
10561056
wasm32-wasi
10571057
# else
10581058
# error unknown wasm32 platform
10591059
# endif
10601060
#elif defined(__wasm64__)
10611061
# if defined(__EMSCRIPTEN__)
1062-
wasm64-emscripten
1062+
wasm64-emscripten - __EMSCRIPTEN_major__ _ __EMSCRIPTEN_minor__ _ __EMSCRIPTEN_tiny__
10631063
# elif defined(__wasi__)
10641064
wasm64-wasi
10651065
# else

0 commit comments

Comments
 (0)