From f4b23267faeaf401fd1c8bb78375c8dfdbd0e3c8 Mon Sep 17 00:00:00 2001 From: Gary Guo Date: Mon, 21 Oct 2024 14:58:11 +0800 Subject: [PATCH] Add check for compiling in panic=abort without debuginfo --- Cargo.lock | 9 ++++++++- Cargo.toml | 1 + test_crates/panic_abort_no_debuginfo/Cargo.toml | 7 +++++++ test_crates/panic_abort_no_debuginfo/check.sh | 11 +++++++++++ test_crates/panic_abort_no_debuginfo/src/main.rs | 3 +++ tests/compile_tests.rs | 1 + 6 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 test_crates/panic_abort_no_debuginfo/Cargo.toml create mode 100755 test_crates/panic_abort_no_debuginfo/check.sh create mode 100644 test_crates/panic_abort_no_debuginfo/src/main.rs diff --git a/Cargo.lock b/Cargo.lock index deb6ad6..2dadcce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "catch_std_exception" @@ -33,6 +33,13 @@ version = "0.2.158" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439" +[[package]] +name = "panic_abort_no_debuginfo" +version = "0.1.0" +dependencies = [ + "unwinding", +] + [[package]] name = "rustc-std-workspace-alloc" version = "1.0.0" diff --git a/Cargo.toml b/Cargo.toml index d3e3161..1246a44 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,6 +13,7 @@ members = [ "test_crates/throw_and_catch", "test_crates/catch_std_exception", "test_crates/std_catch_exception", + "test_crates/panic_abort_no_debuginfo", ] [dependencies] diff --git a/test_crates/panic_abort_no_debuginfo/Cargo.toml b/test_crates/panic_abort_no_debuginfo/Cargo.toml new file mode 100644 index 0000000..1e8b5c6 --- /dev/null +++ b/test_crates/panic_abort_no_debuginfo/Cargo.toml @@ -0,0 +1,7 @@ +[package] +name = "panic_abort_no_debuginfo" +version = "0.1.0" +edition = "2021" + +[dependencies] +unwinding = { path = "../../", features = ["panic"] } diff --git a/test_crates/panic_abort_no_debuginfo/check.sh b/test_crates/panic_abort_no_debuginfo/check.sh new file mode 100755 index 0000000..a3acc3a --- /dev/null +++ b/test_crates/panic_abort_no_debuginfo/check.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash +set -o pipefail + +# Skip the test if need -Zbuild-std, it somehow doesn't work. +if [ -n "$BUILD_STD" ]; then + exit 0 +fi + +export CARGO_TARGET_DIR=$(mktemp -d) +trap "rm -rf $CARGO_TARGET_DIR" EXIT +RUSTFLAGS="-Cpanic=abort -Cdebuginfo=0" ${CARGO:-cargo} build --release $BUILD_STD 2>&1 diff --git a/test_crates/panic_abort_no_debuginfo/src/main.rs b/test_crates/panic_abort_no_debuginfo/src/main.rs new file mode 100644 index 0000000..6a29a05 --- /dev/null +++ b/test_crates/panic_abort_no_debuginfo/src/main.rs @@ -0,0 +1,3 @@ +extern crate unwinding; + +fn main() {} diff --git a/tests/compile_tests.rs b/tests/compile_tests.rs index 26a5697..d672a05 100644 --- a/tests/compile_tests.rs +++ b/tests/compile_tests.rs @@ -8,6 +8,7 @@ fn main() { "throw_and_catch", "catch_std_exception", "std_catch_exception", + "panic_abort_no_debuginfo", ]; for test in tests {