Create x86_64-unknown-linux-gnuasan target which enables ASAN by default
As suggested, in order to distribute sanitizer instrumented standard libraries without introducing new rustc flags, this adds a new dedicated target. With the target, we can distribute the instrumented standard libraries through a separate rustup component.
This commit is contained in:
parent
53b6f89be2
commit
c222a00e79
8 changed files with 81 additions and 0 deletions
|
|
@ -1801,6 +1801,8 @@ supported_targets! {
|
|||
("x86_64-lynx-lynxos178", x86_64_lynx_lynxos178),
|
||||
|
||||
("x86_64-pc-cygwin", x86_64_pc_cygwin),
|
||||
|
||||
("x86_64-unknown-linux-gnuasan", x86_64_unknown_linux_gnuasan),
|
||||
}
|
||||
|
||||
/// Cow-Vec-Str: Cow<'static, [Cow<'static, str>]>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,16 @@
|
|||
use crate::spec::{SanitizerSet, Target, TargetMetadata};
|
||||
|
||||
pub(crate) fn target() -> Target {
|
||||
let mut base = super::x86_64_unknown_linux_gnu::target();
|
||||
base.metadata = TargetMetadata {
|
||||
description: Some(
|
||||
"64-bit Linux (kernel 3.2+, glibc 2.17+) with ASAN enabled by default".into(),
|
||||
),
|
||||
tier: Some(2),
|
||||
host_tools: Some(false),
|
||||
std: Some(true),
|
||||
};
|
||||
base.supported_sanitizers = SanitizerSet::ADDRESS;
|
||||
base.default_sanitizers = SanitizerSet::ADDRESS;
|
||||
base
|
||||
}
|
||||
|
|
@ -1484,6 +1484,7 @@ fn supported_sanitizers(
|
|||
"x86_64",
|
||||
&["asan", "dfsan", "lsan", "msan", "safestack", "tsan", "rtsan"],
|
||||
),
|
||||
"x86_64-unknown-linux-gnuasan" => common_libs("linux", "x86_64", &["asan"]),
|
||||
"x86_64-unknown-linux-musl" => {
|
||||
common_libs("linux", "x86_64", &["asan", "lsan", "msan", "tsan"])
|
||||
}
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ pub struct Finder {
|
|||
const STAGE0_MISSING_TARGETS: &[&str] = &[
|
||||
// just a dummy comment so the list doesn't get onelined
|
||||
"riscv64im-unknown-none-elf",
|
||||
"x86_64-unknown-linux-gnuasan",
|
||||
];
|
||||
|
||||
/// Minimum version threshold for libstdc++ required when using prebuilt LLVM
|
||||
|
|
|
|||
|
|
@ -151,5 +151,6 @@
|
|||
- [x86_64-pc-cygwin](platform-support/x86_64-pc-cygwin.md)
|
||||
- [x86_64-unknown-linux-none](platform-support/x86_64-unknown-linux-none.md)
|
||||
- [x86_64-unknown-none](platform-support/x86_64-unknown-none.md)
|
||||
- [x86_64-unknown-linux-gnuasan](platform-support/x86_64-unknown-linux-gnuasan.md)
|
||||
- [xtensa-\*-none-elf](platform-support/xtensa.md)
|
||||
- [\*-nuttx-\*](platform-support/nuttx.md)
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ target | std | notes
|
|||
[`x86_64-apple-ios-macabi`](platform-support/apple-ios-macabi.md) | ✓ | Mac Catalyst on x86_64
|
||||
[`x86_64-fortanix-unknown-sgx`](platform-support/x86_64-fortanix-unknown-sgx.md) | ✓ | [Fortanix ABI] for 64-bit Intel SGX
|
||||
[`x86_64-linux-android`](platform-support/android.md) | ✓ | 64-bit x86 Android
|
||||
[`x86_64-unknown-linux-gnuasan`](platform-support/x86_64-unknown-linux-gnuasan.md) | ✓ | 64-bit Linux (kernel 3.2+, glibc 2.17+) with ASAN enabled by default
|
||||
[`x86_64-unknown-fuchsia`](platform-support/fuchsia.md) | ✓ | 64-bit x86 Fuchsia
|
||||
`x86_64-unknown-linux-gnux32` | ✓ | 64-bit Linux (x32 ABI) (kernel 4.15+, glibc 2.27)
|
||||
[`x86_64-unknown-none`](platform-support/x86_64-unknown-none.md) | * | Freestanding/bare-metal x86_64, softfloat
|
||||
|
|
|
|||
|
|
@ -0,0 +1,56 @@
|
|||
# `x86_64-unknown-linux-gnuasan`
|
||||
|
||||
**Tier: 2**
|
||||
|
||||
Target mirroring `x86_64-unknown-linux-gnu` with AddressSanitizer enabled by
|
||||
default.
|
||||
The goal of this target is to allow shipping ASAN-instrumented standard
|
||||
libraries through rustup, enabling a fully instrumented binary without requiring
|
||||
nightly features (build-std).
|
||||
Once build-std stabilizes, this target is no longer needed and will be removed.
|
||||
|
||||
## Target maintainers
|
||||
|
||||
- [@jakos-sec](https://github.com/jakos-sec)
|
||||
- [@1c3t3a](https://github.com/1c3t3a)
|
||||
- [@rust-lang/project-exploit-mitigations][project-exploit-mitigations]
|
||||
|
||||
## Requirements
|
||||
|
||||
The target is for cross-compilation only. Host tools are not supported, since
|
||||
there is no need to have the host tools instrumented with ASAN. std is fully
|
||||
supported.
|
||||
|
||||
In all other aspects the target is equivalent to `x86_64-unknown-linux-gnu`.
|
||||
|
||||
## Building the target
|
||||
|
||||
The target can be built by enabling it for a rustc build:
|
||||
|
||||
```toml
|
||||
[build]
|
||||
target = ["x86_64-unknown-linux-gnuasan"]
|
||||
```
|
||||
|
||||
## Building Rust programs
|
||||
|
||||
Rust programs can be compiled by adding this target via rustup:
|
||||
|
||||
```sh
|
||||
$ rustup target add x86_64-unknown-linux-gnuasan
|
||||
```
|
||||
|
||||
and then compiling with the target:
|
||||
|
||||
```sh
|
||||
$ rustc foo.rs --target x86_64-unknown-linux-gnuasan
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
Created binaries will run on Linux without any external requirements.
|
||||
|
||||
## Cross-compilation toolchains and C code
|
||||
|
||||
The target supports C code and should use the same toolchain target as
|
||||
`x86_64-unknown-linux-gnu`.
|
||||
|
|
@ -673,6 +673,9 @@
|
|||
//@ revisions: x86_64_unknown_linux_gnux32
|
||||
//@ [x86_64_unknown_linux_gnux32] compile-flags: --target x86_64-unknown-linux-gnux32
|
||||
//@ [x86_64_unknown_linux_gnux32] needs-llvm-components: x86
|
||||
//@ revisions: x86_64_unknown_linux_gnuasan
|
||||
//@ [x86_64_unknown_linux_gnuasan] compile-flags: --target x86_64-unknown-linux-gnuasan
|
||||
//@ [x86_64_unknown_linux_gnuasan] needs-llvm-components: x86
|
||||
//@ revisions: x86_64_unknown_linux_musl
|
||||
//@ [x86_64_unknown_linux_musl] compile-flags: --target x86_64-unknown-linux-musl
|
||||
//@ [x86_64_unknown_linux_musl] needs-llvm-components: x86
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue