Only add sanitizer runtimes when linking an executable (#64629).

This commit is contained in:
Christian Holler (:decoder) 2019-09-25 20:23:26 +02:00
parent 66bf391c3a
commit 640c261a1f

View File

@ -1372,7 +1372,9 @@ fn add_upstream_rust_crates<'a, B: ArchiveBuilder<'a>>(cmd: &mut dyn Linker,
_ if codegen_results.crate_info.profiler_runtime == Some(cnum) => {
add_static_crate::<B>(cmd, sess, codegen_results, tmpdir, crate_type, cnum);
}
_ if codegen_results.crate_info.sanitizer_runtime == Some(cnum) => {
_ if codegen_results.crate_info.sanitizer_runtime == Some(cnum) &&
crate_type == config::CrateType::Executable => {
// Link the sanitizer runtimes only if we are actually producing an executable
link_sanitizer_runtime::<B>(cmd, sess, codegen_results, tmpdir, cnum);
}
// compiler-builtins are always placed last to ensure that they're