Skip to content

Commit 4210409

Browse files
committed
Enable ASan on Fuchsia
This change adds the x86_64-fuchsia and aarch64-fuchsia LLVM targets to those allowed to invoke -Zsanitizer. Currently, the only overlap between compiler_rt sanitizers supported by both rustc and Fuchsia is ASan.
1 parent ae66171 commit 4210409

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

src/bootstrap/native.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,24 @@ fn supported_sanitizers(out_dir: &Path, target: Interned<String>) -> Vec<Sanitiz
659659
});
660660
}
661661
}
662+
"x86_64-fuchsia" => {
663+
for s in &["asan"] {
664+
result.push(SanitizerRuntime {
665+
cmake_target: format!("clang_rt.{}-x86_64", s),
666+
path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-x86_64.a", s)),
667+
name: format!("librustc_rt.{}.a", s),
668+
});
669+
}
670+
}
671+
"aarch64-fuchsia" => {
672+
for s in &["asan"] {
673+
result.push(SanitizerRuntime {
674+
cmake_target: format!("clang_rt.{}-aarch64", s),
675+
path: out_dir.join(&format!("build/lib/fuchsia/libclang_rt.{}-aarch64.a", s)),
676+
name: format!("librustc_rt.{}.a", s),
677+
});
678+
}
679+
}
662680
_ => {}
663681
}
664682
result

src/librustc_codegen_ssa/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -777,7 +777,7 @@ fn link_sanitizer_runtime(sess: &Session, crate_type: config::CrateType, linker:
777777
linker.args(&["-Wl,-rpath".into(), "-Xlinker".into(), rpath.into()]);
778778
linker.link_dylib(Symbol::intern(&libname));
779779
}
780-
"x86_64-unknown-linux-gnu" => {
780+
"x86_64-unknown-linux-gnu" | "x86_64-fuchsia" | "aarch64-fuchsia" => {
781781
let filename = format!("librustc_rt.{}.a", name);
782782
let path = default_tlib.join(&filename);
783783
linker.link_whole_rlib(&path);

src/librustc_session/session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
11281128
// Sanitizers can only be used on some tested platforms.
11291129
if let Some(ref sanitizer) = sess.opts.debugging_opts.sanitizer {
11301130
const ASAN_SUPPORTED_TARGETS: &[&str] =
1131-
&["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
1131+
&["x86_64-unknown-linux-gnu", "x86_64-apple-darwin", "x86_64-fuchsia", "aarch64-fuchsia" ];
11321132
const TSAN_SUPPORTED_TARGETS: &[&str] =
11331133
&["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
11341134
const LSAN_SUPPORTED_TARGETS: &[&str] =

0 commit comments

Comments
 (0)