From 440554e4dd7080a781a09018f4f956965658d199 Mon Sep 17 00:00:00 2001 From: Gabriel de Perthuis Date: Tue, 24 Nov 2020 15:56:05 +0100 Subject: [PATCH] Test that core can be built with msan enabled See https://github.com/rust-fuzz/cargo-fuzz/issues/243 The test currently fails, since it highlights a regression. Reverting library/stdarch to (the problem commit being ) makes it pass again. --- .../sanitizer-memory-build-core/.gitignore | 2 ++ .../sanitizer-memory-build-core/Cargo.toml | 6 ++++++ .../sanitizer-memory-build-core/Makefile | 19 +++++++++++++++++++ .../sanitizer-memory-build-core/src/main.rs | 3 +++ 4 files changed, 30 insertions(+) create mode 100644 src/test/run-make-fulldeps/sanitizer-memory-build-core/.gitignore create mode 100644 src/test/run-make-fulldeps/sanitizer-memory-build-core/Cargo.toml create mode 100644 src/test/run-make-fulldeps/sanitizer-memory-build-core/Makefile create mode 100644 src/test/run-make-fulldeps/sanitizer-memory-build-core/src/main.rs diff --git a/src/test/run-make-fulldeps/sanitizer-memory-build-core/.gitignore b/src/test/run-make-fulldeps/sanitizer-memory-build-core/.gitignore new file mode 100644 index 0000000000000..042776aad7295 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-memory-build-core/.gitignore @@ -0,0 +1,2 @@ +/Cargo.lock +/target/ diff --git a/src/test/run-make-fulldeps/sanitizer-memory-build-core/Cargo.toml b/src/test/run-make-fulldeps/sanitizer-memory-build-core/Cargo.toml new file mode 100644 index 0000000000000..0c725516a0b58 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-memory-build-core/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "foo" +version = "0.1.0" +edition = "2018" + +[workspace] diff --git a/src/test/run-make-fulldeps/sanitizer-memory-build-core/Makefile b/src/test/run-make-fulldeps/sanitizer-memory-build-core/Makefile new file mode 100644 index 0000000000000..c8ecada3e7a7c --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-memory-build-core/Makefile @@ -0,0 +1,19 @@ +# needs-sanitizer-support +# needs-sanitizer-memory + +# This test builds a trivial program with memory sanitizer +# and rebuilds part of the standard library + +# -Clink-dead-code is a setting that sanitizer front-ends generally enable, +# due to issues with certain linkers mangling sections used to track +# coverage when trying to remove dead code +# Linking dead code allows tracking more regressions generating code for the +# standard library, eg for target features that are not currently enabled. + +# -Ccodegen-units=1 is also enabled by the front-ends, to work around +# misoptimisations with ThinLTO. + +all: + RUSTFLAGS="-Cpasses=sancov -Clink-dead-code -Zsanitizer=memory -Ccodegen-units=1" \ + cargo build --verbose --release -Zbuild-std=core --target $(TARGET) + diff --git a/src/test/run-make-fulldeps/sanitizer-memory-build-core/src/main.rs b/src/test/run-make-fulldeps/sanitizer-memory-build-core/src/main.rs new file mode 100644 index 0000000000000..e7a11a969c037 --- /dev/null +++ b/src/test/run-make-fulldeps/sanitizer-memory-build-core/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}