From 742c69f9757745e7e2ba8343f10bc79c5e788a78 Mon Sep 17 00:00:00 2001 From: Martin Habovstiak Date: Thu, 4 Jul 2024 08:14:18 +0200 Subject: [PATCH] Compile `no_std` test using xargo The `no_std` test disables `std`, so unwinding is unsupported, so we use `panic = "abort"` but the `core` library is compiled with unwind by default which breaks the build. Xargo can handle this by recompiling `core` with `panic = "abort"` so we use it. --- .github/workflows/rust.yml | 2 ++ contrib/_test.sh | 6 ++++-- no_std_test/Xargo.toml | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 no_std_test/Xargo.toml diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index f435fdda7..bbe07b19d 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -46,6 +46,8 @@ jobs: uses: dtolnay/rust-toolchain@nightly - name: Install src run: rustup component add rust-src + - name: Install xargo + run: cargo install xargo - name: Running test script env: DO_FMT: true diff --git a/contrib/_test.sh b/contrib/_test.sh index e18b23146..d415b5689 100755 --- a/contrib/_test.sh +++ b/contrib/_test.sh @@ -101,8 +101,10 @@ if [ "$DO_ASAN" = true ]; then RUSTFLAGS='-Zsanitizer=memory -Zsanitizer-memory-track-origins -Cforce-frame-pointers=yes -Cllvm-args=-msan-eager-checks=0' \ cargo test --lib --all --features="$FEATURES" -Zbuild-std --target x86_64-unknown-linux-gnu - cargo run --release --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified Successfully" - cargo run --release --features=alloc --manifest-path=./no_std_test/Cargo.toml | grep -q "Verified alloc Successfully" + cd no_std_test + xargo run --release --target=x86_64-unknown-linux-gnu | grep -q "Verified Successfully" + xargo run --release --target=x86_64-unknown-linux-gnu --features=alloc | grep -q "Verified alloc Successfully" + cd - fi # Run formatter if told to. diff --git a/no_std_test/Xargo.toml b/no_std_test/Xargo.toml new file mode 100644 index 000000000..de8cec3df --- /dev/null +++ b/no_std_test/Xargo.toml @@ -0,0 +1,2 @@ +[dependencies] +alloc = {}