Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 07282e8

Browse files
committedJul 22, 2024
rewrite sanitizer-staticlib-link to rmake
1 parent aecf0b8 commit 07282e8

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
@@ -75,7 +75,6 @@ run-make/reproducible-build/Makefile
7575
run-make/rlib-format-packed-bundled-libs-2/Makefile
7676
run-make/rlib-format-packed-bundled-libs-3/Makefile
7777
run-make/rlib-format-packed-bundled-libs/Makefile
78-
run-make/sanitizer-staticlib-link/Makefile
7978
run-make/share-generics-dylib/Makefile
8079
run-make/simd-ffi/Makefile
8180
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)
Failed to load comments.