-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
Create x86_64-unknown-linux-gnuasan target which enables ASAN by default #149644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+81
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnuasan.rs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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_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 | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
src/doc/rustc/src/platform-support/x86_64-unknown-linux-gnuasan.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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`. | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.