From e14bd485347ca7852ff737ee9b3ec5c35b58115a Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 28 May 2025 11:49:22 -0700 Subject: [PATCH 1/3] Support multi-arch builds in the devcontainer Make WASI SDK and Wasmtime work under x86-64 and arm64. --- .github/workflows/ci.yml | 6 +++++- devcontainer/Dockerfile | 30 ++++++++++++++++++++++-------- 2 files changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 052f2b8..d6fd0cd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -9,7 +9,7 @@ on: jobs: build_devcontainer: - name: Build (Devcontainer) + name: Build and test (Devcontainer) runs-on: ubuntu-latest env: TAG: cpython-devcontainer:1.0.0-${{ github.run_id }} @@ -24,6 +24,10 @@ jobs: context: ./devcontainer load: true tags: ${{ env.TAG }} + - name: Test WASI SDK + run: docker run --rm ${{ env.TAG }} /opt/wasi-sdk/bin/clang --version + - name: Test Wasmtime + run: docker run --rm ${{ env.TAG }} /usr/local/bin/wasmtime --version build_autoconf: name: Build and test (Autoconf) diff --git a/devcontainer/Dockerfile b/devcontainer/Dockerfile index 7c9e168..e792eb6 100644 --- a/devcontainer/Dockerfile +++ b/devcontainer/Dockerfile @@ -1,13 +1,9 @@ FROM docker.io/library/fedora:41 -ENV CC=clang +ARG TARGETARCH -ENV WASI_SDK_VERSION=24 -ENV WASI_SDK_PATH=/opt/wasi-sdk -ENV WASMTIME_HOME=/opt/wasmtime -ENV WASMTIME_VERSION=22.0.0 -ENV WASMTIME_CPU_ARCH=x86_64 +ENV CC=clang RUN dnf -y --nodocs --setopt=install_weak_deps=False --disablerepo=fedora-cisco-openh264 install \ /usr/bin/{blurb,clang,curl,git,ln,tar,xz} \ @@ -19,12 +15,30 @@ RUN dnf -y --nodocs --setopt=install_weak_deps=False --disablerepo=fedora-cisco- builddep python3 && \ dnf -y clean all + +ENV WASI_SDK_VERSION=24 +ENV WASI_SDK_PATH=/opt/wasi-sdk + RUN mkdir ${WASI_SDK_PATH} && \ - curl --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-x86_64-linux.tar.gz | \ + case "${TARGETARCH}" in \ + amd64) WASI_ARCH="x86_64" ;; \ + arm64) WASI_ARCH="arm64" ;; \ + *) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \ + esac && \ + curl --location https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-${WASI_SDK_VERSION}/wasi-sdk-${WASI_SDK_VERSION}.0-${WASI_ARCH}-linux.tar.gz | \ tar --strip-components 1 --directory ${WASI_SDK_PATH} --extract --gunzip + +ENV WASMTIME_HOME=/opt/wasmtime +ENV WASMTIME_VERSION=33.0.0 + RUN mkdir --parents ${WASMTIME_HOME} && \ - curl --location "https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_CPU_ARCH}-linux.tar.xz" | \ + case "${TARGETARCH}" in \ + amd64) WASMTIME_ARCH="x86_64" ;; \ + arm64) WASMTIME_ARCH="aarch64" ;; \ + *) echo "Unsupported TARGETARCH: ${TARGETARCH}" && exit 1 ;; \ + esac && \ + curl --location "https://github.com/bytecodealliance/wasmtime/releases/download/v${WASMTIME_VERSION}/wasmtime-v${WASMTIME_VERSION}-${WASMTIME_ARCH}-linux.tar.xz" | \ xz --decompress | \ tar --strip-components 1 --directory ${WASMTIME_HOME} -x && \ ln -s ${WASMTIME_HOME}/wasmtime /usr/local/bin From f45b8dd1bc98e51501573b9e9dbdfd9382a02e54 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 28 May 2025 11:52:43 -0700 Subject: [PATCH 2/3] Add arm64 to the OS matrix for testing the devcontainer --- .github/workflows/ci.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d6fd0cd..d01e988 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -10,7 +10,11 @@ on: jobs: build_devcontainer: name: Build and test (Devcontainer) - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, ubuntu-24.04-arm] + runs-on: ${{ matrix.os }} env: TAG: cpython-devcontainer:1.0.0-${{ github.run_id }} steps: From cc78e7ed05a2c96fbb47e98981921a0361bf0382 Mon Sep 17 00:00:00 2001 From: Brett Cannon Date: Wed, 28 May 2025 13:12:48 -0700 Subject: [PATCH 3/3] Add comments about when to update the versions of WASI SDK and Wasmtime --- devcontainer/Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/devcontainer/Dockerfile b/devcontainer/Dockerfile index e792eb6..c2d16ae 100644 --- a/devcontainer/Dockerfile +++ b/devcontainer/Dockerfile @@ -16,6 +16,7 @@ RUN dnf -y --nodocs --setopt=install_weak_deps=False --disablerepo=fedora-cisco- dnf -y clean all +# Update only after consulting with WASI support maintainers (see PEP 11). ENV WASI_SDK_VERSION=24 ENV WASI_SDK_PATH=/opt/wasi-sdk @@ -29,8 +30,9 @@ RUN mkdir ${WASI_SDK_PATH} && \ tar --strip-components 1 --directory ${WASI_SDK_PATH} --extract --gunzip -ENV WASMTIME_HOME=/opt/wasmtime +# Update as desired. ENV WASMTIME_VERSION=33.0.0 +ENV WASMTIME_HOME=/opt/wasmtime RUN mkdir --parents ${WASMTIME_HOME} && \ case "${TARGETARCH}" in \