Skip to content

C# macos support

C# macos support #3790

Workflow file for this run

name: CI
on:
pull_request:
merge_group:
defaults:
run:
shell: bash
# Cancel any in-flight jobs for the same PR/branch so there's only one active
# at a time
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build:
name: Build wit-bindgen
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- build: x86_64-linux
os: ubuntu-latest
env:
CARGO_BUILD_TARGET: x86_64-unknown-linux-gnu
DOCKER_IMAGE: ./ci/docker/x86_64-linux/Dockerfile
- build: aarch64-linux
os: ubuntu-latest
env:
CARGO_BUILD_TARGET: aarch64-unknown-linux-gnu
DOCKER_IMAGE: ./ci/docker/aarch64-linux/Dockerfile
- build: riscv64gc-linux
os: ubuntu-latest
env:
CARGO_BUILD_TARGET: riscv64gc-unknown-linux-gnu
DOCKER_IMAGE: ./ci/docker/riscv64gc-linux/Dockerfile
- build: x86_64-macos
os: macos-latest
env:
CARGO_BUILD_TARGET: x86_64-apple-darwin
MACOSX_DEPLOYMENT_TARGET: 10.12
- build: aarch64-macos
os: macos-latest
env:
CARGO_BUILD_TARGET: aarch64-apple-darwin
MACOSX_DEPLOYMENT_TARGET: 10.12
- build: x86_64-windows
os: windows-latest
env:
CARGO_BUILD_TARGET: x86_64-pc-windows-msvc
RUSTFLAGS: -Ctarget-feature=+crt-static
- build: aarch64-windows
os: windows-11-arm
env:
CARGO_BUILD_TARGET: aarch64-pc-windows-msvc
RUSTFLAGS: -Ctarget-feature=+crt-static
env: ${{ matrix.env }}
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update stable --no-self-update && rustup default stable
- run: rustup target add $CARGO_BUILD_TARGET
- run: ./ci/build-release-artifacts.sh
- run: ./ci/build-tarballs.sh "${{ matrix.build }}"
- uses: actions/upload-artifact@v4
with:
name: bins-${{ matrix.build }}
path: dist
test:
name: Test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# moonbit removed from language matrix for now - causing CI failures
lang: [c, rust, csharp, cpp, go]
runs-on: ${{ matrix.os }}
env:
RUNTIMELAB_COMMIT: '4cac3ab5c8e97fda69c23dfca41ace964babc05e'
steps:
- uses: actions/checkout@v4
with:
submodules: true
# FIXME(rust-lang/rust#148347) current rust (1.91) is broken
- name: Install Rust
run: rustup update 1.90.0 --no-self-update && rustup default 1.90.0
- run: rustup target add wasm32-wasip1 wasm32-wasip2
- run: rustup target add wasm32-unknown-unknown
if: matrix.lang == 'rust'
- uses: ./.github/actions/install-wasi-sdk
- name: Setup .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: '9.x'
if: matrix.lang == 'csharp' && runner.os != 'macOS'
- name: Setup .NET 10 (macOS)
uses: actions/setup-dotnet@v4
with:
dotnet-version: '10.x'
dotnet-quality: 'preview'
if: matrix.lang == 'csharp' && runner.os == 'macOS'
- name: Setup Go
uses: actions/setup-go@v5
with:
go-version: 1.25.4
if: matrix.lang == 'go'
# Hacky work-around for https://github.com/dotnet/runtime/issues/80619
- run: dotnet new console -o /tmp/foo
if: matrix.os != 'windows-latest' && matrix.lang == 'csharp'
- run: |
curl -fsSL https://cli.moonbitlang.com/install/unix.sh | bash
echo "$HOME/.moon/bin" >> $GITHUB_PATH
if: matrix.os != 'windows-latest' && matrix.lang == 'moonbit'
- run: |
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser; irm https://cli.moonbitlang.com/install/powershell.ps1 | iex
"C:\Users\runneradmin\.moon\bin" | Out-File -FilePath $env:GITHUB_PATH -Append
shell: powershell
if: matrix.os == 'windows-latest' && matrix.lang == 'moonbit'
# macOS C# requires locally-built ILC packages since no osx-arm64
# packages are published on NuGet.
- name: Cache runtimelab ILC packages
id: cache-runtimelab
uses: actions/cache@v4
with:
path: runtimelab-packages
key: runtimelab-macos-arm64-${{ env.RUNTIMELAB_COMMIT }}
if: runner.os == 'macOS' && matrix.lang == 'csharp'
- name: Install LLVM 18 for runtimelab build
if: runner.os == 'macOS' && matrix.lang == 'csharp' && steps.cache-runtimelab.outputs.cache-hit != 'true'
run: brew install llvm@18
- name: Checkout runtimelab
uses: actions/checkout@v4
with:
repository: dotnet/runtimelab
ref: ${{ env.RUNTIMELAB_COMMIT }}
path: runtimelab
if: runner.os == 'macOS' && matrix.lang == 'csharp' && steps.cache-runtimelab.outputs.cache-hit != 'true'
- name: Build runtimelab ILC packages
if: runner.os == 'macOS' && matrix.lang == 'csharp' && steps.cache-runtimelab.outputs.cache-hit != 'true'
run: |
cd runtimelab
ln -sf $WASI_SDK_PATH src/mono/wasi/wasi-sdk
mkdir -p src/mono/wasi/include
# Build wasi libs and packages
./build.sh clr.aot+libs -c Release -a wasm -os wasi /p:NuGetAudit=false
./build.sh nativeaot.packages -c Release -a wasm -os wasi /p:NuGetAudit=false
# Build host compiler, libs, WASM JIT, and packages
./build.sh clr.aot -c Release /p:NuGetAudit=false
./build.sh libs -c Release /p:NuGetAudit=false
LLVM_CMAKE_CONFIG_RELEASE=$(brew --prefix llvm@18)/lib/cmake/llvm \
src/coreclr/build-runtime.sh -arm64 -release -os osx -outputrid osx-arm64 -component llvmjit
cp artifacts/bin/coreclr/osx.arm64.Release/libclrjit_universal_llvm32_arm64.dylib artifacts/bin/coreclr/osx.arm64.Release/ilc-published/
cp artifacts/bin/coreclr/osx.arm64.Release/libjitinterface_arm64.dylib artifacts/bin/coreclr/osx.arm64.Release/ilc-published/
./build.sh nativeaot.packages -c Release /p:NuGetAudit=false
mkdir -p ../runtimelab-packages
cp artifacts/packages/Release/Shipping/*.nupkg ../runtimelab-packages/
- name: Set ILC env vars for macOS C#
if: runner.os == 'macOS' && matrix.lang == 'csharp'
run: |
echo "ILC_VERSION=10.0.0-dev" >> $GITHUB_ENV
echo "ILC_PACKAGES_PATH=${{ github.workspace }}/runtimelab-packages" >> $GITHUB_ENV
# Run all codegen tests for this language
- run: |
cargo run test --languages ${{ matrix.lang }} tests/codegen \
--artifacts target/artifacts \
--rust-wit-bindgen-path ./crates/guest-rust
# Run all runtime tests for this language, and also enable Rust in case this
# language only implements either the runner or test component
- run: |
cargo run test --languages rust,${{ matrix.lang }} tests/runtime \
--artifacts target/artifacts \
--rust-wit-bindgen-path ./crates/guest-rust
# While async is off-by-default and toolchains are percolating this is a
# separate job to get configured slightly differently.
async:
name: Test Async (allowed to fail)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- run: rustup target add wasm32-wasip2
# As of this writing, we need [a patched build of
# Go](https://github.com/dicej/go/releases/tag/go1.25.5-wasi-on-idle) to
# support async.
- name: Install Patched Go
run: |
curl -OL https://github.com/dicej/go/releases/download/go1.25.5-wasi-on-idle/go-linux-amd64-bootstrap.tbz
tar xf go-linux-amd64-bootstrap.tbz
echo "$(pwd)/go-linux-amd64-bootstrap/bin" >> $GITHUB_PATH
- uses: ./.github/actions/install-wasi-sdk
- run: |
cargo run test --languages rust,c,go tests/runtime-async \
--artifacts target/artifacts \
--rust-wit-bindgen-path ./crates/guest-rust
test_unit:
name: Crate Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- run: rustup target add wasm32-wasip1
- run: cargo test
- run: cargo test -p wit-bindgen-core
- run: cargo test -p wit-bindgen
- run: cargo test -p wit-bindgen --all-features
- run: cargo test -p wit-bindgen-rust
- run: cargo test --workspace --exclude 'wit-bindgen*'
- run: rustup update nightly-2025-11-10 --no-self-update
- run: rustup default nightly-2025-11-10
- run: rustup component add miri
- run: rustup component add rust-src
- run: cargo miri test -p wit-bindgen --all-features
check:
name: Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable --no-self-update && rustup default stable
- name: Install wasm32-unknown-unknown target
run: rustup target add wasm32-unknown-unknown
- name: Install wasm32-wasip1 target
run: rustup target add wasm32-wasip1
# Verify the output of the `./ci/rebuild-libwit-bindgen-cabi.sh` script is
# up-to-date.
- uses: ./.github/actions/install-wasi-sdk
- run: ./ci/rebuild-libwit-bindgen-cabi.sh
- run: git diff --exit-code
# Test various feature combinations, make sure they all build
- run: cargo build
- run: cargo build --no-default-features
- run: cargo build --no-default-features --features rust
- run: cargo build --no-default-features --features c
- run: cargo build --no-default-features --features go
- run: cargo build --no-default-features --features csharp
- run: cargo build --no-default-features --features markdown
- run: cargo build --no-default-features --features moonbit
# Feature combos of the `wit-bindgen` crate
- run: cargo build --target wasm32-wasip1 -p wit-bindgen --no-default-features
- run: cargo build --target wasm32-wasip1 -p wit-bindgen --no-default-features --features realloc
- run: cargo build --target wasm32-wasip1 -p wit-bindgen --no-default-features --features macros
- run: cargo build --target wasm32-wasip1 -p wit-bindgen --no-default-features --features macros,realloc
- run: cargo build --target wasm32-wasip1 -p wit-bindgen --no-default-features --features async
- run: cargo build --target wasm32-wasip1 -p wit-bindgen --no-default-features --features async-spawn
- run: cargo build --target wasm32-wasip1 -p wit-bindgen --no-default-features --features async,macros
- run: cargo build --target wasm32-wasip1 -p wit-bindgen --no-default-features --features inter-task-wakeup
# Verity that documentation can be generated for the rust bindings crate.
- run: rustup update nightly --no-self-update
- run: cargo +nightly doc -p wit-bindgen --no-deps
env:
RUSTDOCFLAGS: --cfg=docsrs
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Install Rust
run: rustup update stable && rustup default stable && rustup component add rustfmt
- name: Format source code
run: cargo fmt -- --check
verify-publish:
if: github.repository_owner == 'bytecodealliance'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- run: rustup update stable && rustup default stable
- run: rustc ci/publish.rs
# Make sure the tree is publish-able as-is
- run: ./publish verify
# Make sure we can bump version numbers for the next release
- run: ./publish bump
# "Join node" which the merge queue waits on.
ci-status:
name: Record the result of testing and building steps
runs-on: ubuntu-latest
needs:
- test
- test_unit
- rustfmt
- build
- verify-publish
- check
# - async
if: always()
steps:
- name: Successful test and build
if: ${{ !(contains(needs.*.result, 'failure')) }}
run: exit 0
- name: Failing test and build
if: ${{ contains(needs.*.result, 'failure') }}
run: exit 1
- name: Report failure on cancellation
if: ${{ contains(needs.*.result, 'cancelled') || cancelled() }}
run: exit 1
clippy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: rustup update stable --no-self-update && rustup default stable
- run: rustup component add clippy
- run: cargo clippy --workspace --all-targets -- -D warnings