Diagnose use sanitizers with crt-static

This commit is contained in:
12101111 2021-05-22 01:24:50 +08:00
parent fc81ad22c4
commit 4376484439
No known key found for this signature in database
GPG Key ID: 97785FADF38A97DC
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()) {
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.

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