diff options
| author | bors <bors@rust-lang.org> | 2021-05-30 23:38:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2021-05-30 23:38:10 +0000 |
| commit | aab93ca37f38f70869c5de47c1877e54579e9de2 (patch) | |
| tree | 20a277cf7f439e6827b4b50e3e043253382a6739 | |
| parent | c1e8f3a5857c3c8d095fd212acc6ed442f4cc58b (diff) | |
| parent | 43764844399af82f407fe963fa708e8f90981ea4 (diff) | |
| download | rust-aab93ca37f38f70869c5de47c1877e54579e9de2.tar.gz rust-aab93ca37f38f70869c5de47c1877e54579e9de2.zip | |
Auto merge of #85559 - 12101111:sanitizer-crt-static, r=nagisa
Diagnose use sanitizers with crt-static Fix: https://github.com/rust-lang/rust/issues/85459
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 8 | ||||
| -rw-r--r-- | src/test/ui/sanitize/crt-static.rs | 5 | ||||
| -rw-r--r-- | src/test/ui/sanitize/crt-static.stderr | 4 |
3 files changed, 17 insertions, 0 deletions
diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 70c45b0d7d3..4ba47985ce1 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1512,6 +1512,14 @@ fn validate_commandline_args_with_session_available(sess: &Session) { if let (Some(first), Some(second)) = (sanitizer_iter.next(), sanitizer_iter.next()) { sess.err(&format!("`-Zsanitizer={}` is incompatible with `-Zsanitizer={}`", first, second)); } + + // Cannot enable crt-static with sanitizers on Linux + if sess.crt_static(None) && !sess.opts.debugging_opts.sanitizer.is_empty() { + sess.err( + "Sanitizer is incompatible with statically linked libc, \ + disable it using `-C target-feature=-crt-static`", + ); + } } /// Holds data on the current incremental compilation session, if there is one. diff --git a/src/test/ui/sanitize/crt-static.rs b/src/test/ui/sanitize/crt-static.rs new file mode 100644 index 00000000000..f5dd2a40cc4 --- /dev/null +++ b/src/test/ui/sanitize/crt-static.rs @@ -0,0 +1,5 @@ +// compile-flags: -Z sanitizer=address -C target-feature=+crt-static --target x86_64-unknown-linux-gnu + +#![feature(no_core)] +#![no_core] +#![no_main] diff --git a/src/test/ui/sanitize/crt-static.stderr b/src/test/ui/sanitize/crt-static.stderr new file mode 100644 index 00000000000..3a9c636d760 --- /dev/null +++ b/src/test/ui/sanitize/crt-static.stderr @@ -0,0 +1,4 @@ +error: Sanitizer is incompatible with statically linked libc, disable it using `-C target-feature=-crt-static` + +error: aborting due to previous error + |
