Skip to content

Commit 94aa655

Browse files
authored
Rollup merge of rust-lang#68473 - nopsledder:rust_sanitizer_fuchsia, r=alexcrichton
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.
2 parents e7752ae + 192650a commit 94aa655

File tree

3 files changed

+25
-3
lines changed

3 files changed

+25
-3
lines changed

src/bootstrap/native.rs

+18
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

+1-1
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

+6-2
Original file line numberDiff line numberDiff line change
@@ -1127,8 +1127,12 @@ fn validate_commandline_args_with_session_available(sess: &Session) {
11271127

11281128
// Sanitizers can only be used on some tested platforms.
11291129
if let Some(ref sanitizer) = sess.opts.debugging_opts.sanitizer {
1130-
const ASAN_SUPPORTED_TARGETS: &[&str] =
1131-
&["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
1130+
const ASAN_SUPPORTED_TARGETS: &[&str] = &[
1131+
"x86_64-unknown-linux-gnu",
1132+
"x86_64-apple-darwin",
1133+
"x86_64-fuchsia",
1134+
"aarch64-fuchsia",
1135+
];
11321136
const TSAN_SUPPORTED_TARGETS: &[&str] =
11331137
&["x86_64-unknown-linux-gnu", "x86_64-apple-darwin"];
11341138
const LSAN_SUPPORTED_TARGETS: &[&str] =

0 commit comments

Comments
 (0)