Skip to content

[mypyc] librt base64: support pyodide via the NEON intrinsics - #20316

Merged
ilevkivskyi merged 2 commits into
python:masterfrom
mr-c:librt_base64_pyodide
Nov 29, 2025
Merged

[mypyc] librt base64: support pyodide via the NEON intrinsics#20316
ilevkivskyi merged 2 commits into
python:masterfrom
mr-c:librt_base64_pyodide

Conversation

@mr-c

@mr-c mr-c commented Nov 28, 2025

Copy link
Copy Markdown
Contributor

Fixes the following error when building lib-rt with pyodide

/home/runner/work/librt/librt/.pyodide_build/pywasmcross_symlinks/cc -fno-strict-overflow -Wsign-compare -Wunreachable-code -DNDEBUG -g -O3 -Wall -O2 -g0 -fPIC -DPY_CALL_TRAMPOLINE -I. -Ibase64 -I/tmp/build-env-ftmn_jvi/include -I/home/runner/.cache/cibuildwheel/pyodide-build-0.30.7/0.27.7/xbuildenv/pyodide-root/cpython/installs/python-3.12.7/include/python3.12 -c base64/arch/avx/codec.c -o build/temp.emscripten_3_1_58_wasm32-cpython-312/base64/arch/avx/codec.o -O3 -mavx
emcc: error: passing any of -msse, -msse2, -msse3, -mssse3, -msse4.1, -msse4.2, -msse4, -mavx, -mfpu=neon flags also requires passing -msimd128 (or -mrelaxed-simd)!

Instead of using emscripten's compatibility headers for X86 intrinsics, this PR has pyodide/emscripten use the NEON intrinsics as they better match the underlying SIMD capabilities in WASM. And it skips the "CPU detection" which would not work (nor make sense) in a WASM setting.

Ideally a pure WASM implementation would be added to base64 and backported here as well.

@ilevkivskyi

Copy link
Copy Markdown
Member

cc @JukkaL FYI

@ilevkivskyi

Copy link
Copy Markdown
Member

Also cc @emmatyping who added the original WASM build

@ilevkivskyi ilevkivskyi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Apart from ever increasing amount of code duplication this looks good to me. If there are no objections I am going to merge this today/tomorrow.

@emmatyping emmatyping left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This looks good! Thanks for the fix :)

@ilevkivskyi
ilevkivskyi merged commit dec6528 into python:master Nov 29, 2025
13 checks passed
@mr-c
mr-c deleted the librt_base64_pyodide branch December 1, 2025 13:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants