1
Fork 0

Rollup merge of #118521 - dpaoliello:asan, r=wesleywiser

Enable address sanitizer for MSVC targets using INFERASANLIBS linker flag

This enables address sanitizer for x86_64-pc-windows-msvc and i686-pc-windows-msvc targets when linked with the MSVC linker (link.exe) by leveraging the `/INFERASANLIBS` option to automatically find and link in Microsoft's address sanitizer runtime: <https://learn.microsoft.com/en-us/cpp/sanitizers/asan-runtime?view=msvc-170>

Implements https://github.com/rust-lang/compiler-team/issues/702
Fixes #89339 (for MSVC targets using the MSVC linker only)
Supercedes #89369

Successful x86_64-msvc build showing the sanitizer tests working: https://github.com/rust-lang/rust/actions/runs/7228346880/job/19697628258?pr=118521
This commit is contained in:
Matthias Krüger 2024-01-04 08:33:21 +01:00 committed by GitHub
commit 1f32203fd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 80 additions and 25 deletions

View file

@ -1,9 +1,10 @@
use crate::spec::{base, LinkerFlavor, Lld, Target};
use crate::spec::{base, LinkerFlavor, Lld, SanitizerSet, Target};
pub fn target() -> Target {
let mut base = base::windows_msvc::opts();
base.cpu = "pentium4".into();
base.max_atomic_width = Some(64);
base.supported_sanitizers = SanitizerSet::ADDRESS;
base.add_pre_link_args(
LinkerFlavor::Msvc(Lld::No),

View file

@ -1,10 +1,11 @@
use crate::spec::{base, Target};
use crate::spec::{base, SanitizerSet, Target};
pub fn target() -> Target {
let mut base = base::windows_msvc::opts();
base.cpu = "x86-64".into();
base.plt_by_default = false;
base.max_atomic_width = Some(64);
base.supported_sanitizers = SanitizerSet::ADDRESS;
Target {
llvm_target: "x86_64-pc-windows-msvc".into(),