Skip to content

Commit

Permalink
Merge with upstream (#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhil authored Dec 30, 2024
2 parents bd991b2 + 190ec98 commit 010c5c5
Show file tree
Hide file tree
Showing 182 changed files with 1,854 additions and 894 deletions.
139 changes: 56 additions & 83 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ jobs:
audit: ${{ steps.calculate.outputs.audit }}
preview1-adapter: ${{ steps.calculate.outputs.preview1-adapter }}
run-dwarf: ${{ steps.calculate.outputs.run-dwarf }}
platform-checks: ${{ steps.calculate.outputs.platform-checks }}
steps:
- uses: actions/checkout@v4
- id: calculate
Expand All @@ -216,6 +217,8 @@ jobs:
run_full=true
elif grep -q 'prtest:debug' commits.log; then
echo run-dwarf=true >> $GITHUB_OUTPUT
elif grep -q 'prtest:platform-checks' commits.log; then
echo platform-checks=true >> $GITHUB_OUTPUT
fi
if grep -q crates.c-api names.log; then
echo test-capi=true >> $GITHUB_OUTPUT
Expand Down Expand Up @@ -257,6 +260,7 @@ jobs:
echo audit=true >> $GITHUB_OUTPUT
echo preview1-adapter=true >> $GITHUB_OUTPUT
echo run-dwarf=true >> $GITHUB_OUTPUT
echo platform-checks=true >> $GITHUB_OUTPUT
fi
# Build all documentation of Wasmtime, including the C API documentation,
Expand Down Expand Up @@ -442,30 +446,6 @@ jobs:
- uses: ./.github/actions/cancel-on-failure
if: failure()

# Checks for no_std support, ensure that crates can build on a no_std target
no_std_checks:
name: no_std checks
runs-on: ubuntu-latest
env:
CARGO_NDK_VERSION: 2.12.2
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-rust

# NOTE(dhil): Currently, we only support x86_64 Linux.
# - run: rustup target add x86_64-unknown-none
# - run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,component-model
# - run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model
# - run: cargo check --target x86_64-unknown-none -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps
# - run: cargo check --target x86_64-unknown-none -p cranelift-control --no-default-features
# - run: cargo check --target x86_64-unknown-none -p pulley-interpreter --features encode,decode,disas,interp

# common logic to cancel the entire run if this job fails
- uses: ./.github/actions/cancel-on-failure
if: failure()

# Check that Clippy lints are passing.
clippy:
name: Clippy
Expand Down Expand Up @@ -520,10 +500,6 @@ jobs:
- run: cargo check --features wasmfx_pooling_allocator
- run: cargo check --features wasmfx_baseline,wasmfx_pooling_allocator

# Check whether `wasmtime` cross-compiles to x86_64-unknown-freebsd
- run: rustup target add x86_64-unknown-freebsd
- run: cargo check --target x86_64-unknown-freebsd

# Re-vendor all WIT files and ensure that they're all up-to-date by ensuring
# that there's no git changes.
- name: Re-vendor WIT
Expand All @@ -539,45 +515,66 @@ jobs:
- uses: ./.github/actions/cancel-on-failure
if: failure()

checks_illumos:
name: Check illumos
runs-on: ubuntu-latest
# Various checks that Wasmtime builds for a variety of platforms. Each
# platform may not include the entire dependency tree and maybe just a few
# features here and there, see the `include` matrix for more details.
platform_checks:
needs: determine
# NOTE(dhil): Disabled as the platforms are currently unsupported.
if: false && needs.determine.outputs.platform-checks
name: "Platform: ${{ matrix.target }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
include:
- target: x86_64-unknown-freebsd
os: ubuntu-latest
test: cargo check
- target: aarch64-pc-windows-msvc
os: windows-latest
test: cargo check
# While we're here testing a windows target also test a feature'd build
# on Windows. Note that this isn't covered by `micro_checks` above since
# that's for unix platforms, not Windows, so include a small check here
# which isn't the full `micro_checks` matrix but hopefully enough bang
# for our buck.
- target: i686-pc-windows-msvc
os: windows-latest
test: cargo check && cargo build -p wasmtime --no-default-features --features runtime
# This is used for general compatibility with `#![no_std]` targets and a
# variety of crates are tested here.
- target: x86_64-unknown-none
os: ubuntu-latest
test: >
cargo check -p wasmtime --no-default-features --features runtime,component-model &&
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model &&
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps &&
cargo check -p wasmtime --no-default-features --features runtime,gc,component-model,signals-based-traps &&
cargo check -p cranelift-control --no-default-features &&
cargo check -p pulley-interpreter --features encode,decode,disas,interp
# Use `cross` for illumos to have a C compiler/linker available.
- target: x86_64-unknown-illumos
os: ubuntu-latest
cross: true
test: cross build
- target: wasm32-wasip1
os: ubuntu-latest
test: cargo build --no-default-features --features compile,cranelift,all-arch
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-rust

# Check whether `wasmtime` cross-compiles to illumos. We need to use `cross` for this (even for
# cargo check) because of non-Rust dependencies.
- run: rustup target add ${{ matrix.target }}
- name: Install cross
run: |
curl -L --proto '=https' --tlsv1.2 -sSf https://raw.githubusercontent.com/cargo-bins/cargo-binstall/main/install-from-binstall-release.sh | bash
cargo binstall --no-confirm cross
- name: Cross-compile to illumos
run:
cross build --target x86_64-unknown-illumos

# common logic to cancel the entire run if this job fails
- uses: ./.github/actions/cancel-on-failure
if: failure()

# Check whether `wasmtime` cross-compiles to aarch64-pc-windows-msvc
# We don't build nor test it because it lacks trap handling.
# Tracking issue: https://github.com/bytecodealliance/wasmtime/issues/4992
checks_winarm64:
needs: determine
# TODO(dhil): This check is disabled due to lack of platform support.
if: needs.determine.outputs.run-full && false
name: Check Windows ARM64
runs-on: windows-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-rust
- run: rustup target add aarch64-pc-windows-msvc
- run: cargo check -p wasmtime --target aarch64-pc-windows-msvc
if: ${{ matrix.cross }}
- run: ${{ matrix.test }}
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}

# common logic to cancel the entire run if this job fails
- uses: ./.github/actions/cancel-on-failure
Expand Down Expand Up @@ -991,27 +988,6 @@ jobs:
- uses: ./.github/actions/cancel-on-failure
if: failure()


build-wasmtime-target-wasm32:
name: Build wasmtime-target-wasm32
# TODO(dhil): This platform is unsupported.
if: false
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- uses: ./.github/actions/install-rust
- run: rustup target add wasm32-wasip1 wasm32-unknown-unknown
- run: cargo build --target wasm32-wasip1 --no-default-features --features compile,cranelift,all-arch
env:
VERSION: ${{ github.sha }}

# common logic to cancel the entire run if this job fails
- uses: ./.github/actions/cancel-on-failure
if: failure()


bench:
needs: determine
if: needs.determine.outputs.run-full
Expand Down Expand Up @@ -1206,19 +1182,16 @@ jobs:
- doc
- micro_checks
- fiber_tests
- no_std_checks
- clippy
- monolith_checks
- checks_illumos
- checks_winarm64
- platform_checks
- bench
- meta_deterministic_check
- verify-publish
- determine
- miri
- build-preview1-component-adapter
- build-preview1-component-adapter-provider
- build-wasmtime-target-wasm32
- test-min-platform-example
- check_js
if: always()
Expand Down
14 changes: 14 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ humantime = { workspace = true }
tempfile = { workspace = true, optional = true }

async-trait = { workspace = true }
trait-variant = { workspace = true }
bytes = { workspace = true }
cfg-if = { workspace = true }
tokio = { workspace = true, optional = true, features = [ "signal", "macros" ] }
Expand All @@ -98,6 +99,7 @@ criterion = { workspace = true }
num_cpus = "1.13.0"
memchr = "2.4"
async-trait = { workspace = true }
trait-variant = { workspace = true }
wat = { workspace = true }
rayon = "1.5.0"
wasmtime-wast = { workspace = true, features = ['component-model'] }
Expand Down Expand Up @@ -316,6 +318,7 @@ tracing = "0.1.26"
bitflags = "2.0"
thiserror = "1.0.43"
async-trait = "0.1.71"
trait-variant = "0.1.2"
heck = "0.5"
similar = "2.1.0"
toml = "0.8.10"
Expand Down
3 changes: 2 additions & 1 deletion ci/build-test-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,10 @@ const FULL_MATRIX = [
// TODO(dhil): Disabled as long as we don't support other platforms
// than x86_64 Linux.
// {
// "os": "macos-13",
// "os": macos,
// "name": "Test macOS x86_64",
// "filter": "macos-x64",
// "target": "x86_64-apple-darwin",
// },
// {
// "os": macos,
Expand Down
32 changes: 0 additions & 32 deletions cranelift/codegen/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,6 @@ fn run_compilation(compilation: &IsleCompilation) -> Result<(), Errors> {
isle::compile::from_files(file_paths, &options)?
};

let code = rustfmt(&code).unwrap_or_else(|e| {
println!("cargo:warning=Failed to run `rustfmt` on ISLE-generated code: {e:?}");
code
});

eprintln!(
"Writing ISLE-generated Rust code to {}",
compilation.output.display()
Expand All @@ -226,30 +221,3 @@ fn run_compilation(compilation: &IsleCompilation) -> Result<(), Errors> {

Ok(())
}

fn rustfmt(code: &str) -> std::io::Result<String> {
use std::io::Write;

let mut rustfmt = std::process::Command::new("rustfmt")
.stdin(std::process::Stdio::piped())
.stdout(std::process::Stdio::piped())
.spawn()?;

let mut stdin = rustfmt.stdin.take().unwrap();
stdin.write_all(code.as_bytes())?;
drop(stdin);

let mut stdout = rustfmt.stdout.take().unwrap();
let mut data = vec![];
stdout.read_to_end(&mut data)?;

let status = rustfmt.wait()?;
if !status.success() {
return Err(std::io::Error::new(
std::io::ErrorKind::Other,
format!("`rustfmt` exited with status {status}"),
));
}

Ok(String::from_utf8(data).expect("rustfmt always writes utf-8 to stdout"))
}
2 changes: 1 addition & 1 deletion cranelift/codegen/meta/src/cdsl/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ fn verify_polymorphic(
/// Verify that the use of TypeVars is consistent with `ctrl_typevar` as the controlling type
/// variable.
///
/// All polymorhic inputs must either be derived from `ctrl_typevar` or be independent free type
/// All polymorphic inputs must either be derived from `ctrl_typevar` or be independent free type
/// variables only used once.
///
/// All polymorphic results must be derived from `ctrl_typevar`.
Expand Down
3 changes: 2 additions & 1 deletion cranelift/codegen/meta/src/pulley.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ impl Inst<'_> {
match self.name {
// Skip instructions related to control-flow as those require
// special handling with `MachBuffer`.
"Jump" | "Call" | "CallIndirect" => true,
"Jump" => true,
n if n.starts_with("Call") => true,

// Skip special instructions not used in Cranelift.
"XPush32Many" | "XPush64Many" | "XPop32Many" | "XPop64Many" => true,
Expand Down
2 changes: 1 addition & 1 deletion cranelift/codegen/meta/src/shared/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1815,7 +1815,7 @@ pub(crate) fn define(
r#"
Fixed-point multiplication of numbers in the QN format, where N + 1
is the number bitwidth:
`a := signed_saturate((x * y + 1 << (Q - 1)) >> Q)`
`a := signed_saturate((x * y + (1 << (Q - 1))) >> Q)`
Polymorphic over all integer vector types with 16- or 32-bit numbers.
"#,
Expand Down
Loading

0 comments on commit 010c5c5

Please sign in to comment.