Skip to content

Commit 9abacec

Browse files
committed
rewrite sanitizer-staticlib-link to rmake
1 parent d224256 commit 9abacec

File tree

3 files changed

+26
-21
lines changed

3 files changed

+26
-21
lines changed

src/tools/tidy/src/allowed_run_make_makefiles.txt

-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ run-make/reproducible-build-2/Makefile
7070
run-make/reproducible-build/Makefile
7171
run-make/rlib-format-packed-bundled-libs-2/Makefile
7272
run-make/rlib-format-packed-bundled-libs/Makefile
73-
run-make/sanitizer-staticlib-link/Makefile
7473
run-make/share-generics-dylib/Makefile
7574
run-make/simd-ffi/Makefile
7675
run-make/split-debuginfo/Makefile

tests/run-make/sanitizer-staticlib-link/Makefile

-20
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// This test first builds a staticlib with AddressSanitizer and checks that
2+
// linking it to an executable fails due to the missing sanitizer runtime.
3+
// It then builds an executable linking to the staticlib and checks that
4+
// the fault in the staticlib is detected correctly.
5+
6+
// Note that checking for the link failure actually checks two things at once:
7+
// 1) That the library has the sanitizer intrumentation
8+
// 2) and that library does not have the sanitizer runtime
9+
// See https://github.com/rust-lang/rust/pull/38699
10+
11+
//@ needs-sanitizer-support
12+
//@ needs-sanitizer-address
13+
14+
use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run_fail, rustc, static_lib_name};
15+
16+
fn main() {
17+
rustc().arg("-g").arg("-Zsanitizer=address").crate_type("staticlib").input("library.rs").run();
18+
cc().input("program.c")
19+
.arg(static_lib_name("library"))
20+
.out_exe("program")
21+
.args(extra_c_flags())
22+
.args(extra_cxx_flags())
23+
.run_fail();
24+
rustc().arg("-g").arg("-Zsanitizer=address").crate_type("bin").input("program.rs").run();
25+
run_fail("program").assert_stderr_contains("stack-buffer-overflow");
26+
}

0 commit comments

Comments
 (0)