@@ -487,6 +487,82 @@ jobs:
487487 .nox/emscripten
488488 key : emscripten-${{ hashFiles('emscripten/*') }}-${{ hashFiles('noxfile.py') }}-${{ steps.setup-python.outputs.python-path }}
489489
490+ wasm32-wasip1 :
491+ name : wasm32-wasip1
492+ if : ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }}
493+ needs : [fmt]
494+ runs-on : ubuntu-latest
495+ env :
496+ WASI_SDK_PATH : " /opt/wasi-sdk"
497+ CPYTHON_PATH : " ${{ github.workspace }}/wasi/cpython"
498+ steps :
499+ 500+ - uses : actions/setup-python@v6
501+ with :
502+ python-version : 3.14
503+ id : setup-python
504+ - name : Install Rust toolchain
505+ uses : dtolnay/rust-toolchain@stable
506+ with :
507+ targets : wasm32-wasip1
508+ components : rust-src
509+ - name : " Install wasmtime"
510+ uses : bytecodealliance/actions/wasmtime/setup@v1
511+ - name : " Install WASI SDK"
512+ run : |
513+ mkdir ${{ env.WASI_SDK_PATH }} && \
514+ curl -s -S --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-24/wasi-sdk-24.0-x86_64-linux.tar.gz | \
515+ tar --strip-components 1 --directory ${{ env.WASI_SDK_PATH }} --extract --gunzip
516+ $WASI_SDK_PATH/bin/clang --version
517+ - uses : actions/cache/restore@v5
518+ id : cache-wasip1-python
519+ with :
520+ path : ${{ env.CPYTHON_PATH }}/cross-build/
521+ key : wasm32-wasip1-python
522+ 523+ with :
524+ repository : python/cpython
525+ ref : 3.14
526+ path : ${{ env.CPYTHON_PATH }}
527+ fetch-depth : 1
528+ - name : Build
529+ run : |
530+ cd ${{ env.CPYTHON_PATH }}
531+ cat >> Tools/wasm/wasi/config.site-wasm32-wasi <<'EOF'
532+
533+ # Force-disable POSIX dynamic loading for WASI
534+ ac_cv_func_dlopen=no
535+ ac_cv_lib_dl_dlopen=no
536+ EOF
537+ python Tools/wasm/wasi build --quiet -- --config-cache
538+ cp cross-build/wasm32-wasip1/libpython3.14.a \
539+ cross-build/wasm32-wasip1/Modules/_hacl/libHacl_HMAC.a \
540+ cross-build/wasm32-wasip1/Modules/_decimal/libmpdec/libmpdec.a \
541+ cross-build/wasm32-wasip1/Modules/expat/libexpat.a \
542+ cross-build/wasm32-wasip1/build/lib.wasi-wasm32-3.14/
543+ - uses : Swatinem/rust-cache@v2
544+ with :
545+ save-if : ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
546+ - name : Test
547+ env :
548+ PYO3_CROSS_LIB_DIR : ${{ env.CPYTHON_PATH }}/cross-build/wasm32-wasip1/build/lib.wasi-wasm32-3.14/
549+ CARGO_BUILD_TARGET : wasm32-wasip1
550+ CARGO_TARGET_WASM32_WASIP1_RUNNER : wasmtime run --dir ${{ env.CPYTHON_PATH }}::/ --env PYTHONPATH=/lib
551+ RUSTFLAGS : >
552+ -C link-arg=-L${{ env.WASI_SDK_PATH }}/share/wasi-sysroot/lib/wasm32-wasi
553+ -C link-arg=-lwasi-emulated-signal
554+ -C link-arg=-lwasi-emulated-process-clocks
555+ -C link-arg=-lwasi-emulated-getpid
556+ -C link-arg=-lmpdec
557+ -C link-arg=-lHacl_HMAC
558+ -C link-arg=-lexpat
559+ run : RUSTDOCFLAGS=$RUSTFLAGS cargo test
560+ - uses : actions/cache/save@v5
561+ if : ${{ github.ref == 'refs/heads/main' || contains(github.event.pull_request.labels.*.name, 'CI-save-pr-cache') }}
562+ with :
563+ path : ${{ env.CPYTHON_PATH }}/cross-build/
564+ key : ${{ steps.cache-wasip1-python.outputs.cache-primary-key }}
565+
490566 test-debug :
491567 if : ${{ contains(github.event.pull_request.labels.*.name, 'CI-build-full') || github.event_name != 'pull_request' }}
492568 needs : [fmt]
0 commit comments