diff --git a/ci-sanitizers-test.sh b/ci-sanitizers-test.sh index 6850fcc..a099794 100755 --- a/ci-sanitizers-test.sh +++ b/ci-sanitizers-test.sh @@ -2,7 +2,8 @@ set -eauxo pipefail # llvm-symbolizer supports v0 mangling -RUSTFLAGS="-Zrandomize-layout -Cdebuginfo=full -Csymbol-mangling-version=v0 --cfg=skip-slow-tests" +RUSTFLAGS="-Zrandomize-layout -Cdebuginfo=full -Csymbol-mangling-version=v0 \ + --cfg skip_slow_tests" if [ -z "${TARGET+x}" ]; then echo "Env TARGET must be set" @@ -29,7 +30,7 @@ address) # FIXME: if on aarch64-{unknown}-linux-{android, gnu}, we can use `hwaddress` # instead of `address` which should be faster. Unfortunately we probably # don't have that in CI - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=address" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=address --cfg sanitizer=\"address\"" ;; hwaddress) # see above @@ -41,36 +42,38 @@ kasan) exit 1 ;; memory) - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=memory" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=memory --cfg sanitizer=\"memory\"" ;; memtag) # FIXME: alternative to MSAN with the same target restrictions as hwaddress - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=memtag" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=memtag --cfg sanitizer=\"memory\"" ecbo "we don't have a CI target for this yet" exit 1 ;; cfi) # CFI needs LTO and 1CGU, seems like randomize-layout enables `embed-bitcode=no` # which conflicts - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=cfi -Cembed-bitcode=yes -Clinker-plugin-lto -Ccodegen-units=1" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=cfi --cfg sanitizer=\"cfi\" \ + -Cembed-bitcode=yes -Clinker-plugin-lto -Ccodegen-units=1" ;; kcfi) - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=kcfi" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=kcfi --cfg sanitizer=\"cfi\"" ;; safestack) - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=safestack" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=safestack --cfg sanitizer=\"safestack\"" ;; shadow-call-stack) # FIXME: aarch64-linux-android only - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=shadow-call-stack" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=shadow-call-stack \ + --cfg sanitizer=\"shadow-call-stack\"" echo "we don't have a CI target for this yet" exit 1 ;; leak) - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=leak" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=leak --cfg sanitizer=\"leak\"" ;; thread) - RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=thread" + RUSTFLAGS="${RUSTFLAGS} -Zsanitizer=thread --cfg sanitizer=\"thread\"" ;; *) echo "unknown sanitizer $2" diff --git a/rust-src-san.diff b/rust-src-san.diff index c281d73..a34e06e 100644 --- a/rust-src-san.diff +++ b/rust-src-san.diff @@ -1,28 +1,29 @@ diff --git a/library/alloc/tests/vec.rs b/library/alloc/tests/vec.rs -index d44dcfbf673..d3bacbc1586 100644 +index d44dcfbf673..28809512f07 100644 --- a/library/alloc/tests/vec.rs +++ b/library/alloc/tests/vec.rs -@@ -1636,6 +1636,7 @@ fn test_reserve_exact() { +@@ -1636,6 +1636,8 @@ fn test_reserve_exact() { } #[test] -+#[no_sanitize] // ASAN throws an error for requesting max allocation size ++// ASAN throws an error for requesting max allocation size ++#[cfg_attr(sanitzer = "memory", no_sanitize)] #[cfg_attr(miri, ignore)] // Miri does not support signalling OOM #[cfg_attr(target_os = "android", ignore)] // Android used in CI has a broken dlmalloc fn test_try_reserve() { diff --git a/library/core/tests/slice.rs b/library/core/tests/slice.rs -index 865e702b5c2..5efad11a463 100644 +index 865e702b5c2..c28fb2660aa 100644 --- a/library/core/tests/slice.rs +++ b/library/core/tests/slice.rs -@@ -1876,7 +1876,7 @@ fn sort_unstable() { - } +@@ -1877,7 +1877,7 @@ fn sort_unstable() { #[test] --#[cfg(not(target_arch = "wasm32"))] -+#[cfg(not(any(skip_slow_tests, target_arch = "wasm32")))] - #[cfg_attr(miri, ignore)] // Miri is too slow + #[cfg(not(target_arch = "wasm32"))] +-#[cfg_attr(miri, ignore)] // Miri is too slow ++#[cfg_attr(any(miri. skip_slow_tests), ignore)] // Miri is too slow fn select_nth_unstable() { use core::cmp::Ordering::{Equal, Greater, Less}; + use rand::seq::SliceRandom; @@ -2573,7 +2573,8 @@ macro_rules! empty_max_mut { }; }