mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
Diagnose use sanitizers with crt-static
This commit is contained in:
parent
fc81ad22c4
commit
4376484439
@ -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.
|
||||
|
5
src/test/ui/sanitize/crt-static.rs
Normal file
5
src/test/ui/sanitize/crt-static.rs
Normal 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]
|
4
src/test/ui/sanitize/crt-static.stderr
Normal file
4
src/test/ui/sanitize/crt-static.stderr
Normal 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
|
||||
|
Loading…
Reference in New Issue
Block a user