Skip to content

BLD: allow targeting webassembly without emscripten #29053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

zebreus
Copy link
Contributor

@zebreus zebreus commented May 26, 2025

This pull request updates NumPy's platform detection logic to support WebAssembly (WASM) targets compiled with Clang, independent of Emscripten.

Currently, the CPU architecture is only set to wasm when emscripten is detected (by checking for __EMSCRIPTEN__). However, Clang can compile to WebAssembly without Emscripten. By also including a check for __wasm__, this patch allows NumPy to detect WebAssembly targets compiled without Emscripten.

This broadens NumPy's compatibility with WebAssembly toolchains and environments other than emscripten, such as WASIX.

@melissawm melissawm added the 36 - Build Build related PR label May 26, 2025
@melissawm melissawm moved this to Awaiting a code review in NumPy first-time contributor PRs May 26, 2025
@rgommers
Copy link
Member

rgommers commented Jun 1, 2025

Thanks @zebreus. This change seems reasonable to me, and can be merged as is I think.

I see a CPython interpreter can be built on WASIX, so note that the NumPy test suite has a lot of test skips for WASM, controlled by this boolean:

IS_WASM = platform.machine() in ["wasm32", "wasm64"]

Those skips are for things that don't work in Emscripten-based interpreters like Pyodide (file system access, subprocess invocations, etc.). If WASIX/wasmer or other such things are going to offer more comprehensive Python support, we may need to distinguish between these different WASM flavors better.

@rgommers
Copy link
Member

rgommers commented Jun 1, 2025

Any reason why this PR is Draft?

@zebreus
Copy link
Contributor Author

zebreus commented Jun 2, 2025

Thanks for the quick feedback @rgommers .

This PR is still a draft because I didn't come around to verify that everything is working as expected with WASIX last week. I have now done so, and I am marking this as ready.

For now, the test skips are still needed. While Python on WASIX supports subprocess, a few other things are still missing. Additionally, running programs with dlopen support currently requires wasmer and wasix-libc builds from a specific branch, so they are not yet suitable for integration into an automated test suite.

@zebreus zebreus marked this pull request as ready for review June 2, 2025 13:55
Copy link
Member

@rgommers rgommers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good, thanks @zebreus

@rgommers rgommers merged commit 4c8fd85 into numpy:main Jun 3, 2025
75 checks passed
@github-project-automation github-project-automation bot moved this from Awaiting a code review to Completed in NumPy first-time contributor PRs Jun 3, 2025
@rgommers rgommers added this to the 2.4.0 release milestone Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
36 - Build Build related PR
Projects
Development

Successfully merging this pull request may close these issues.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy