Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions compiler/rustc_target/src/spec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1800,6 +1800,9 @@ supported_targets! {
("x86_64-lynx-lynxos178", x86_64_lynx_lynxos178),

("x86_64-pc-cygwin", x86_64_pc_cygwin),

("x86_64-asan-windows-msvc", x86_64_asan_windows_msvc),
("aarch64-asan-windows-msvc", aarch64_asan_windows_msvc),
}

/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::spec::{SanitizerSet, Target, TargetMetadata};

pub(crate) fn target() -> Target {
let mut base = super::aarch64_pc_windows_msvc::target();
base.metadata = TargetMetadata {
description: Some("64-bit Windows on ARM with ASAN enabled by default".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
};
base.options.default_sanitizers = SanitizerSet::ADDRESS;

assert!(base.options.default_sanitizers.contains(SanitizerSet::ADDRESS));

base
}
16 changes: 16 additions & 0 deletions compiler/rustc_target/src/spec/targets/x86_64_asan_windows_msvc.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
use crate::spec::{SanitizerSet, Target, TargetMetadata};

pub(crate) fn target() -> Target {
let mut base = super::x86_64_pc_windows_msvc::target();
base.metadata = TargetMetadata {
description: Some("64-bit Windows with ASAN enabled by default".into()),
tier: Some(3),
host_tools: Some(false),
std: Some(true),
};
base.options.default_sanitizers = SanitizerSet::ADDRESS;

assert!(base.options.default_sanitizers.contains(SanitizerSet::ADDRESS));

base
}
2 changes: 2 additions & 0 deletions src/bootstrap/src/core/sanity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const STAGE0_MISSING_TARGETS: &[&str] = &[
// just a dummy comment so the list doesn't get onelined
"riscv64gc-unknown-redox",
"hexagon-unknown-qurt",
"aarch64-asan-windows-msvc",
"x86_64-asan-windows-msvc",
];

/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
- [windows-gnullvm](platform-support/windows-gnullvm.md)
- [\*-win7-windows-gnu](platform-support/win7-windows-gnu.md)
- [\*-win7-windows-msvc](platform-support/win7-windows-msvc.md)
- [\*-asan-windows-msvc](platform-support/asan-windows-msvc.md)
- [x86_64-fortanix-unknown-sgx](platform-support/x86_64-fortanix-unknown-sgx.md)
- [x86_64-pc-cygwin](platform-support/x86_64-pc-cygwin.md)
- [x86_64-unknown-linux-none](platform-support/x86_64-unknown-linux-none.md)
Expand Down
1 change: 1 addition & 0 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ target | std | host | notes
[`wasm32-wasip3`](platform-support/wasm32-wasip3.md) | ✓ | WebAssembly with WASIp3
[`x86_64-apple-tvos`](platform-support/apple-tvos.md) | ✓ | | x86 64-bit tvOS
[`x86_64-apple-watchos-sim`](platform-support/apple-watchos.md) | ✓ | | x86 64-bit Apple WatchOS simulator
[`*-asan-windows-msvc`](platform-support/asan-windows-msvc.md) | ✓ | | 64-bit Windows with AddressSanitizer
[`x86_64-lynx-lynxos178`](platform-support/lynxos178.md) | | | x86_64 LynxOS-178
[`x86_64-pc-cygwin`](platform-support/x86_64-pc-cygwin.md) | ✓ | | 64-bit x86 Cygwin |
[`x86_64-pc-nto-qnx710`](platform-support/nto-qnx.md) | ✓ | | x86 64-bit QNX Neutrino 7.1 RTOS with default network stack (io-pkt) |
Expand Down
72 changes: 72 additions & 0 deletions src/doc/rustc/src/platform-support/asan-windows-msvc.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# `*-asan-windows-msvc`

**Tier: 3**

- `aarch64-asan-windows-msvc`
- `x86_64-asan-windows-msvc`

These targets mirror `*-pc-windows-msvc` with AddressSanitizer enabled by default.

## Target maintainers

[@ChrisDenton](https://github.com/ChrisDenton)
[@dpaoliello](https://github.com/dpaoliello)
[@eholk](https://github.com/eholk)
[@Fulgen301](https://github.com/Fulgen301)
[@lambdageek](https://github.com/lambdageek)
[@sivadeilra](https://github.com/sivadeilra)
[@wesleywiser](https://github.com/wesleywiser)

## Requirements

This target is for cross-compilation only. Host tools are not supported because
this target's primary use cases do not require the host tools to be instrumented
with AddressSanitizer. The standard library is fully supported.

In all other aspects, this target is identical to `*-pc-windows-msvc`.

## Building the target

This target can be built by adding it to the `target` list in `bootstrap.toml`.

```toml
[build]
target = [
"aarch64-asan-windows-msvc",
"x86_64-asan-windows-msvc"
]
```

## Building Rust programs

Rust does not yet ship pre-compiled artifacts for this target. To compile for
this target, you will either need to build Rust with the target enabled (see
"Building the target" above), or build your own copy of `core` by using
`build-std` or similar.

Compilation can be done with:

aarch64:
```sh
rustc --target aarch64-asan-windows-msvc my_program.rs
```


x86_64:
```sh
rustc --target x86_64-asan-windows-msvc my_program.rs
```

## Testing

Programs compiled for this target require the `clang_rt.asan_dynamic-*.dll`
corresponding to the target CPU architecture. This can be installed by using the
Visual Studio Installer to install the C++ AddressSanitizer component. Once
installed, add the directory containing the DLL to your `PATH` or run your
program from a Visual Studio Developer Command Prompt.

## Cross-compilation toolchains and C code

Architectural cross-compilation from one Windows host to a different Windows
platform is natively supported by the MSVC toolchain provided the appropriate
components are selected when using the VS Installer.
6 changes: 6 additions & 0 deletions tests/assembly-llvm/targets/targets-pe.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
//@ add-minicore
//@ assembly-output: emit-asm
// ignore-tidy-linelength
//@ revisions: aarch64_asan_windows_msvc
//@ [aarch64_asan_windows_msvc] compile-flags: --target aarch64-asan-windows-msvc
//@ [aarch64_asan_windows_msvc] needs-llvm-components: arm
//@ revisions: aarch64_pc_windows_msvc
//@ [aarch64_pc_windows_msvc] compile-flags: --target aarch64-pc-windows-msvc
//@ [aarch64_pc_windows_msvc] needs-llvm-components: aarch64
Expand Down Expand Up @@ -67,6 +70,9 @@
//@ revisions: x86_64_pc_windows_msvc
//@ [x86_64_pc_windows_msvc] compile-flags: --target x86_64-pc-windows-msvc
//@ [x86_64_pc_windows_msvc] needs-llvm-components: x86
//@ revisions: x86_64_asan_windows_msvc
//@ [x86_64_asan_windows_msvc] compile-flags: --target x86_64-asan-windows-msvc
//@ [x86_64_asan_windows_msvc] needs-llvm-components: x86
//@ revisions: x86_64_unknown_uefi
//@ [x86_64_unknown_uefi] compile-flags: --target x86_64-unknown-uefi
//@ [x86_64_unknown_uefi] needs-llvm-components: x86
Expand Down
Loading