1
Fork 0

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
This commit is contained in:
bors 2021-05-30 23:38:10 +00:00
commit aab93ca37f
3 changed files with 17 additions and 0 deletions

View file

@ -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()) { if let (Some(first), Some(second)) = (sanitizer_iter.next(), sanitizer_iter.next()) {
sess.err(&format!("`-Zsanitizer={}` is incompatible with `-Zsanitizer={}`", first, second)); 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. /// Holds data on the current incremental compilation session, if there is one.

View file

@ -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]

View file

@ -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