From dbe22b061aa0f19dbe3d3c5c4a2d89cc62922c2c Mon Sep 17 00:00:00 2001 From: Arshia Ghafoori Date: Thu, 6 Nov 2025 13:04:25 +0400 Subject: [PATCH] Update CI to be self-contained and support the -dl target --- .github/workflows/ci.yml | 248 ++++-------------- .gitignore | 2 +- build-wasix.sh | 30 +++ config.toml => config.toml.wasix-template | 8 +- .../src/sys/net/connection/socket/windows.rs | 4 - library/std/src/sys/pal/unix/os.rs | 4 +- 6 files changed, 84 insertions(+), 212 deletions(-) rename config.toml => config.toml.wasix-template (67%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f9fb3b733973e..4f9beb3c9d07c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -6,93 +6,32 @@ on: pull_request: workflow_call: jobs: - build-libc: - runs-on: ubuntu-22.04 - steps: - - name: show git config - run: | - env - cat ~/.config/git/config || true - cat ~/.gitconfig || true - ls -lha ./wasix-libc || true - - - name: Check out wasix-libc - uses: actions/checkout@v4 - with: - repository: wasix-org/wasix-libc - ref: wasm64-rust-toolchain - path: wasix-libc - submodules: "recursive" - - - name: OS Setup (Ubuntu) - run: | - sudo apt-get update - sudo apt-get install -y build-essential curl wget xz-utils git python3 - - - name: Install Rust - uses: dtolnay/rust-toolchain@stable - - - name: Check out cargo-wasix - uses: actions/checkout@v4 - with: - repository: wasix-org/cargo-wasix - ref: target-fix - path: cargo-wasix - fetch-depth: 2 - - - name: Print cargo-wasix info - run: | - cd ./cargo-wasix - echo "cargo-wasix commit:" - git rev-parse HEAD - - - name: Build - shell: bash - run: | - cd $GITHUB_WORKSPACE/cargo-wasix - WASIX_NO_UPDATE_REPOS=1 WASIX_BUILD_DIR=$GITHUB_WORKSPACE WASIX_COMPONENTS=libc cargo run -- wasix build-toolchain - - # Workaround for preserving artifact directory structure - # See https://github.com/actions/upload-artifact/issues/174 - touch $GITHUB_WORKSPACE/.stub - - - name: Archive build output - uses: actions/upload-artifact@v4 - with: - name: wasix-libc - path: | - .stub - wasix-libc/sysroot32 - wasix-libc/sysroot64 - build-rust: - needs: build-libc strategy: matrix: include: - name: Windows (x86) - os: windows-latest + os: depot-windows-2022-16 arch: x86 + host_triple: x86_64-pc-windows-msvc - name: Ubuntu (x86) - os: ubuntu-22.04 + os: depot-ubuntu-22.04-16 arch: x86 + host_triple: x86_64-unknown-linux-gnu - name: Mac (x86) os: macos-13 arch: x86 + host_triple: x86_64-apple-darwin - name: Mac (aarch64) - os: macos-15 + os: depot-macos-15 arch: aarch64 + host_triple: aarch64-apple-darwin runs-on: ${{ matrix.os }} steps: - - name: Download wasix-libc artifact - uses: actions/download-artifact@v4 - with: - name: wasix-libc - - name: Check out repository code uses: actions/checkout@v4 with: @@ -102,28 +41,6 @@ jobs: clean: false fetch-depth: 50 - # We need the full history for the main repo so the build tooling can - # determine the cached LLVM download. - # - name: Fetch full branch history - # shell: bash - # run: | - # cd wasix-rust - # git fetch --unshallow origin $(git branch --show-current) - - # echo "Branch history fetched!" - - # - name: Install Rust - # uses: dtolnay/rust-toolchain@stable - - - name: Check out cargo-wasix - uses: actions/checkout@v4 - with: - repository: wasix-org/cargo-wasix - ref: target-fix - path: cargo-wasix - - # Mac - x86 - - name: Setup (Mac OS) shell: bash if: contains(matrix.os, 'macos') @@ -143,59 +60,13 @@ jobs: with: toolchain: stable - # Mac - continued - - - name: Build (Mac Os, x86) - shell: bash - if: contains(matrix.os, 'macos-13') && matrix.arch == 'x86' - env: - WASIX_NO_UPDATE_REPOS: "1" - GITHUB_ACTIONS: "false" - WASIX_COMPONENTS: rust - WASIX_RUST_HOST: x86_64-apple-darwin - run: | - cd cargo-wasix - # NOTE: must unset GITHUB_ACTIONS env var, because Rust bootstrap checks for it. - # (see bootstrap config.rs) - GITHUB_ACTIONS=false WASIX_BUILD_DIR=$GITHUB_WORKSPACE cargo run -- wasix build-toolchain - - - name: Archive build output (Mac OS - x86) - uses: actions/upload-artifact@v4 - if: contains(matrix.os, 'macos') && matrix.arch == 'x86' - with: - name: rust-toolchain-x86_64-apple-darwin - path: | - wasix-rust/build/x86_64-apple-darwin/stage2 - !wasix-rust/build/x86_64-apple-darwin/stage2/lib/rustlib/src - !wasix-rust/build/x86_64-apple-darwin/stage2/lib/rustlib/rustc-src - - # Mac - aarch64 - - - name: Build (Mac Os, aarch64) - shell: bash - if: contains(matrix.os, 'macos') && matrix.arch == 'aarch64' - env: - WASIX_NO_UPDATE_REPOS: "1" - GITHUB_ACTIONS: "false" - WASIX_COMPONENTS: rust - WASIX_RUST_HOST: aarch64-apple-darwin - run: | - cd cargo-wasix - # NOTE: must unset GITHUB_ACTIONS env var, because Rst bootstrap checks for it. - # (see bootstrap config.rs) - GITHUB_ACTIONS=false WASIX_BUILD_DIR=$GITHUB_WORKSPACE cargo run -- wasix build-toolchain - - - name: Archive build output (Mac OS - aarch64) - uses: actions/upload-artifact@v4 - if: contains(matrix.os, 'macos') && matrix.arch == 'aarch64' - with: - name: rust-toolchain-aarch64-apple-darwin - path: | - wasix-rust/build/aarch64-apple-darwin/stage2 - !wasix-rust/build/aarch64-apple-darwin/stage2/lib/rustlib/src - !wasix-rust/build/aarch64-apple-darwin/stage2/lib/rustlib/rustc-src + - name: Set up MinGW (Windows) + if: contains(matrix.os, 'windows') && matrix.arch == 'x86' + uses: e-t-l/setup-mingw@patch-1 - # Linux! + - name: Install ninja (Windows) + if: contains(matrix.os, 'windows') && matrix.arch == 'x86' + uses: seanmiddleditch/gha-setup-ninja@master - name: Setup (Ubuntu) if: matrix.arch == 'x86' && contains(matrix.os, 'ubuntu') @@ -204,74 +75,49 @@ jobs: sudo apt-get update sudo apt-get install -y build-essential curl wget xz-utils git python3 ninja-build cmake - - name: Build (Linux) - if: matrix.arch == 'x86' && contains(matrix.os, 'ubuntu') - shell: bash + - name: Download wasix-libc + run: | + mkdir wasix-libc + cd wasix-libc + gh release download -R wasix-org/wasix-libc -p 'sysroot-eh.tar.gz' + tar xvf sysroot-eh.tar.gz + gh release download -R wasix-org/wasix-libc -p 'sysroot-ehpic.tar.gz' + tar xvf sysroot-ehpic.tar.gz env: - WASIX_NO_UPDATE_REPOS: "1" - WASIX_COMPONENTS: rust - WASIX_RUST_HOST: x86_64-unknown-linux-gnu + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Build (${{ matrix.name }}) + shell: bash run: | - cd cargo-wasix - # NOTE: must unset GITHUB_ACTIONS env var, because Rst bootstrap checks for it. + # NOTE: must unset GITHUB_ACTIONS env var, because Rust bootstrap checks for it. # (see bootstrap config.rs) - GITHUB_ACTIONS=false WASIX_BUILD_DIR=$GITHUB_WORKSPACE cargo run -- wasix build-toolchain - - name: Archive build output (Linux) - uses: actions/upload-artifact@v4 - if: contains(matrix.os, 'ubuntu') - with: - name: rust-toolchain-x86_64-unknown-linux-gnu - path: | - wasix-rust/build/x86_64-unknown-linux-gnu/stage2 - !wasix-rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/src - !wasix-rust/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/rustc-src + cd wasix-rust - # Windows + export \ + HOST=${{ matrix.host_triple }} \ + GITHUB_ACTIONS="false" - # - name: Install chocolatey deps (Windows) - # if: contains(matrix.os, 'windows') && matrix.arch == 'x86' - # shell: bash - # continue-on-error: true - # run: choco install -y visualstudio2019community cmake + if command -v cygpath &> /dev/null; then + export \ + SYSROOT_EH=$(cygpath -w $(realpath ../wasix-libc/wasix-sysroot-eh/sysroot)) \ + SYSROOT_EHPIC=$(cygpath -w $(realpath ../wasix-libc/wasix-sysroot-ehpic/sysroot)) + else + export \ + SYSROOT_EH=$(realpath ../wasix-libc/wasix-sysroot-eh/sysroot) \ + SYSROOT_EHPIC=$(realpath ../wasix-libc/wasix-sysroot-ehpic/sysroot) + fi - - name: Set up MinGW (Windows) - if: contains(matrix.os, 'windows') && matrix.arch == 'x86' - uses: e-t-l/setup-mingw@patch-1 + echo SYSROOT_EH = $SYSROOT_EH + echo SYSROOT_EHPIC = $SYSROOT_EHPIC - # - name: Install llvm (Windows) - # if: matrix.os == 'self-hosted-windows' - # uses: KyleMayes/install-llvm-action@v1 - # with: - # version: "10.0" + bash build-wasix.sh - - name: Install ninja (Windows) - if: contains(matrix.os, 'windows') && matrix.arch == 'x86' - uses: seanmiddleditch/gha-setup-ninja@master - - - name: Build (Windows) - if: contains(matrix.os, 'windows') && matrix.arch == 'x86' - continue-on-error: true - shell: bash - env: - WASIX_NO_UPDATE_REPOS: "1" - WASIX_COMPONENTS: rust - WASIX_RUST_HOST: x86_64-pc-windows-msvc - # WASIX_RUST_HOST: x86_64-pc-windows-gnu - run: | - cd cargo-wasix - # NOTE: must unset GITHUB_ACTIONS env var, because Rst bootstrap checks for it. - # (see bootstrap config.rs) - GITHUB_ACTIONS=false WASIX_BUILD_DIR=$GITHUB_WORKSPACE cargo run -- wasix build-toolchain - - - name: Archive build output (Windows) - if: contains(matrix.os, 'windows') && matrix.arch == 'x86' + - name: Archive build output (${{ matrix.name }}) uses: actions/upload-artifact@v4 with: - name: rust-toolchain-x86_64-pc-windows-msvc - # name: rust-toolchain-x86_64-pc-windows-gnu + name: rust-toolchain-${{ matrix.host_triple }} path: | - wasix-rust/build/x86_64-pc-windows-msvc/stage2 - !wasix-rust/build/x86_64-pc-windows-msvc/stage2/lib/rustlib/src - !wasix-rust/build/x86_64-pc-windows-msvc/stage2/lib/rustlib/rustc-src - + wasix-rust/build/${{ matrix.host_triple }}/stage2 + !wasix-rust/build/${{ matrix.host_triple }}/stage2/lib/rustlib/src + !wasix-rust/build/${{ matrix.host_triple }}/stage2/lib/rustlib/rustc-src diff --git a/.gitignore b/.gitignore index f2d140a62de0b..5988a64916ad8 100644 --- a/.gitignore +++ b/.gitignore @@ -35,7 +35,7 @@ Session.vim ## Configuration /bootstrap.toml -#/config.toml +/config.toml /Makefile config.mk config.stamp diff --git a/build-wasix.sh b/build-wasix.sh index d2074916770b0..caa7932d311ba 100755 --- a/build-wasix.sh +++ b/build-wasix.sh @@ -10,6 +10,36 @@ if [ ${IS_PATCHED} -eq 0 ]; then fi cd ../.. +# Development-friendly defaults! In a dev environment, we can justifiably expect +# a local installation of rustc to exist already. +if [ -z "${HOST:-}" ]; then + HOST=$( + rustc -vV | + grep "host: " | + sed -e "s|host: ||" + ) +fi + +# Too many backslashes? Yes there are! Out of the 8 below, +# 4 get eaten by the sed command here, and 2 more get eaten +# by the sed command that updates config.toml.wasix-template, +# leaving 2 backslashes in the final config.toml file for the +# TOML parser to then interpret correctly. +SYSROOT_EH=${SYSROOT_EH:-../wasix-libc/sysroot32-eh} +SYSROOT_EH=$(sed -e 's|\\|\\\\\\\\|g' <<< "$SYSROOT_EH") +SYSROOT_EHPIC=${SYSROOT_EHPIC:-../wasix-libc/sysroot32-ehpic} +SYSROOT_EHPIC=$(sed -e 's|\\|\\\\\\\\|g' <<< "$SYSROOT_EHPIC") + +cat config.toml.wasix-template | \ + sed \ + -e "s|%HOST%|$HOST|g" \ + -e "s|%SYSROOT_EH%|$SYSROOT_EH|g" \ + -e "s|%SYSROOT_EHPIC%|$SYSROOT_EHPIC|g" \ + > config.toml + +echo Final config.toml: +cat config.toml + ./x.py build --stage 2 rustup toolchain uninstall wasix-dev diff --git a/config.toml b/config.toml.wasix-template similarity index 67% rename from config.toml rename to config.toml.wasix-template index 3ae55baf7e4a0..ee2f525820a27 100644 --- a/config.toml +++ b/config.toml.wasix-template @@ -1,8 +1,8 @@ -change-id = 125535 +change-id = 144675 [build] target = [ - "x86_64-unknown-linux-gnu", + "%HOST%", "wasm32-wasmer-wasi", "wasm32-wasmer-wasi-dl", ] @@ -18,7 +18,7 @@ llvm-tools = true download-ci-llvm = false [target.wasm32-wasmer-wasi] -wasi-root = "../wasix-libc/sysroot32-eh" +wasi-root = "%SYSROOT_EH%" [target.wasm32-wasmer-wasi-dl] -wasi-root = "../wasix-libc/sysroot32-ehpic" +wasi-root = "%SYSROOT_EHPIC%" diff --git a/library/std/src/sys/net/connection/socket/windows.rs b/library/std/src/sys/net/connection/socket/windows.rs index 7f43139a3cbeb..b71d8b1357b5a 100644 --- a/library/std/src/sys/net/connection/socket/windows.rs +++ b/library/std/src/sys/net/connection/socket/windows.rs @@ -300,10 +300,6 @@ impl Socket { } } - pub fn accept_timeout(&self, _storage: *mut c::SOCKADDR, _len: *mut c_int, _timeout: crate::time::Duration) -> io::Result { - super::unsupported::unsupported() - } - pub fn duplicate(&self) -> io::Result { Ok(Self(self.0.try_clone()?)) } diff --git a/library/std/src/sys/pal/unix/os.rs b/library/std/src/sys/pal/unix/os.rs index 0e68313cc3ed0..6c6ec80db1c82 100644 --- a/library/std/src/sys/pal/unix/os.rs +++ b/library/std/src/sys/pal/unix/os.rs @@ -435,13 +435,13 @@ pub fn current_exe() -> io::Result { pub fn current_exe() -> io::Result { unsafe { let mut sz: u32 = 0; - #[expect(deprecated)] + #[allow(deprecated)] libc::_NSGetExecutablePath(ptr::null_mut(), &mut sz); if sz == 0 { return Err(io::Error::last_os_error()); } let mut v: Vec = Vec::with_capacity(sz as usize); - #[expect(deprecated)] + #[allow(deprecated)] let err = libc::_NSGetExecutablePath(v.as_mut_ptr() as *mut i8, &mut sz); if err != 0 { return Err(io::Error::last_os_error());