Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
248 changes: 47 additions & 201 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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')
Expand All @@ -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')
Expand All @@ -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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Session.vim

## Configuration
/bootstrap.toml
#/config.toml
/config.toml
/Makefile
config.mk
config.stamp
Expand Down
30 changes: 30 additions & 0 deletions build-wasix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions config.toml → config.toml.wasix-template
Original file line number Diff line number Diff line change
@@ -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",
]
Expand All @@ -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%"
4 changes: 0 additions & 4 deletions library/std/src/sys/net/connection/socket/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Socket> {
super::unsupported::unsupported()
}

pub fn duplicate(&self) -> io::Result<Socket> {
Ok(Self(self.0.try_clone()?))
}
Expand Down
4 changes: 2 additions & 2 deletions library/std/src/sys/pal/unix/os.rs
Original file line number Diff line number Diff line change
Expand Up @@ -435,13 +435,13 @@ pub fn current_exe() -> io::Result<PathBuf> {
pub fn current_exe() -> io::Result<PathBuf> {
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<u8> = 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());
Expand Down
Loading