Skip to content

Commit

Permalink
upgrades from wasm32-wasi to wasm32-wasip1
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Cummins committed Nov 13, 2024
1 parent c54e926 commit 546024c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ jobs:
- name: Install latest Rust nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-wasi wasm32-unknown-unknown
targets: wasm32-wasip1 wasm32-unknown-unknown

- name: Install latest Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasi wasm32-unknown-unknown
targets: wasm32-wasip1 wasm32-unknown-unknown
components: clippy, rustfmt

- name: Install Rust std source
Expand Down Expand Up @@ -213,7 +213,7 @@ jobs:
before-script-linux: |
rustup install nightly
rustup component add rust-src --toolchain nightly
rustup target add wasm32-wasi wasm32-unknown-unknown
rustup target add wasm32-wasip1 wasm32-unknown-unknown
- name: Set up cross-compiled linux aarch64 build
if: matrix.config.target == 'aarch64-unknown-linux-gnu'
Expand Down
16 changes: 14 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ jobs:
- name: Install latest Rust nightly toolchain
uses: dtolnay/rust-toolchain@nightly
with:
targets: wasm32-wasi wasm32-unknown-unknown
targets: wasm32-wasip1 wasm32-unknown-unknown

- name: Install latest Rust stable toolchain
uses: dtolnay/rust-toolchain@stable
with:
targets: wasm32-wasi wasm32-unknown-unknown
targets: wasm32-wasip1 wasm32-unknown-unknown
components: clippy, rustfmt

- name: Install Rust std source
Expand Down Expand Up @@ -75,6 +75,18 @@ jobs:
key: cpython-wasi
enableCrossOsArchive: true

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.config.maturin_target }}
args: --release --out dist --features pyo3
manylinux: 2_28
docker-options: -v /opt/wasi-sdk:/opt/wasi-sdk
before-script-linux: |
rustup install nightly
rustup component add rust-src --toolchain nightly
rustup target add wasm32-wasip1 wasm32-unknown-unknown
- name: Lint
shell: bash
run: bash .github/workflows/lint.sh
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ switch.
### Prerequisites

- Tools needed to build [CPython](https://github.com/python/cpython) (Make, Clang, etc.)
- [Rust](https://rustup.rs/) stable 1.71 or later *and* nightly 2023-07-27 or later, including the `wasm32-wasi` and `wasm32-unknown-unknown` targets
- Note that we currently use the `-Z build-std` Cargo option to build the `componentize-py` runtime with position-independent code (which is not the default for `wasm32-wasi`) and this requires using a recent nightly build of Rust.
- [Rust](https://rustup.rs/) stable 1.71 or later *and* nightly 2023-07-27 or later, including the `wasm32-wasip1` and `wasm32-unknown-unknown` targets
- Note that we currently use the `-Z build-std` Cargo option to build the `componentize-py` runtime with position-independent code (which is not the default for `wasm32-wasip1`) and this requires using a recent nightly build of Rust.

For Rust, something like this should work once you have `rustup`:

```shell
rustup update
rustup install nightly
rustup component add rust-src --toolchain nightly
rustup target add wasm32-wasi wasm32-unknown-unknown
rustup target add wasm32-wasip1 wasm32-unknown-unknown
```

### Building and Running
Expand Down
8 changes: 4 additions & 4 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn package_all_the_things(out_dir: &Path) -> Result<()> {
.arg("-Z")
.arg("build-std=panic_abort,std")
.arg("--release")
.arg("--target=wasm32-wasi");
.arg("--target=wasm32-wasip1");

for (key, _) in env::vars_os() {
if key
Expand All @@ -132,7 +132,7 @@ fn package_all_the_things(out_dir: &Path) -> Result<()> {
assert!(status.success());
println!("cargo:rerun-if-changed=runtime");

let path = out_dir.join("wasm32-wasi/release/libcomponentize_py_runtime.a");
let path = out_dir.join("wasm32-wasip1/release/libcomponentize_py_runtime.a");

if path.exists() {
let clang = wasi_sdk.join(format!("bin/{CLANG_EXECUTABLE}"));
Expand Down Expand Up @@ -169,7 +169,7 @@ fn package_all_the_things(out_dir: &Path) -> Result<()> {

for library in libraries {
compress(
&wasi_sdk.join("share/wasi-sysroot/lib/wasm32-wasi"),
&wasi_sdk.join("share/wasi-sysroot/lib/wasm32-wasip1"),
library,
out_dir,
true,
Expand Down Expand Up @@ -285,7 +285,7 @@ fn maybe_make_cpython(repo_dir: &Path, wasi_sdk: &Path) -> Result<()> {
run(Command::new("../../config.guess").current_dir(&cpython_wasi_dir))?;

run(Command::new("../../Tools/wasm/wasi-env")
.env("CONFIG_SITE", "../../Tools/wasm/config.site-wasm32-wasi")
.env("CONFIG_SITE", "../../Tools/wasm/config.site-wasm32-wasip1")
.env("CFLAGS", "-fPIC")
.current_dir(&cpython_wasi_dir)
.args([
Expand Down
2 changes: 1 addition & 1 deletion src/prelink.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use zstd::Decoder;

use crate::{ComponentizePyConfig, ConfigContext, Library, RawComponentizePyConfig};

static NATIVE_EXTENSION_SUFFIX: &str = ".cpython-312-wasm32-wasi.so";
static NATIVE_EXTENSION_SUFFIX: &str = ".cpython-312-wasm32-wasip1.so";

type ConfigsMatchedWorlds<'a> =
IndexMap<String, (ConfigContext<ComponentizePyConfig>, Option<&'a str>)>;
Expand Down

0 comments on commit 546024c

Please sign in to comment.