From 6c5b8f4e026c7beb14636adfe07b144b6eed7e21 Mon Sep 17 00:00:00 2001 From: Ivan Lozano Date: Mon, 15 Nov 2021 09:35:12 -0500 Subject: [PATCH] rust: Skip global 'fuzzer' sanitizer static bins The 'fuzzer' sanitizer enables 'hwasan', which is not supported for Rust static binaries. Make sure we skip applying this sanitizer to those binaries. Bug: 204776996 Test: SANITIZE_TARGET=fuzzer m Change-Id: I619cfab32b46c0811590973344eb5cdbe3f1a119 --- rust/sanitize.go | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/rust/sanitize.go b/rust/sanitize.go index fdb342d40..d9446e528 100644 --- a/rust/sanitize.go +++ b/rust/sanitize.go @@ -144,7 +144,7 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { // Global Sanitizers if found, globalSanitizers = android.RemoveFromList("hwaddress", globalSanitizers); found && s.Hwaddress == nil { - // TODO(b/180495975): HWASan for static Rust binaries isn't supported yet. + // TODO(b/204776996): HWASan for static Rust binaries isn't supported yet. if !ctx.RustModule().StaticExecutable() { s.Hwaddress = proptools.BoolPtr(true) } @@ -161,7 +161,10 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) { } if found, globalSanitizers = android.RemoveFromList("fuzzer", globalSanitizers); found && s.Fuzzer == nil { - s.Fuzzer = proptools.BoolPtr(true) + // TODO(b/204776996): HWASan for static Rust binaries isn't supported yet, and fuzzer enables HWAsan + if !ctx.RustModule().StaticExecutable() { + s.Fuzzer = proptools.BoolPtr(true) + } } // Global Diag Sanitizers @@ -289,7 +292,7 @@ func rustSanitizerRuntimeMutator(mctx android.BottomUpMutatorContext) { deps = []string{config.LibclangRuntimeLibrary(mod.toolchain(mctx), "asan")} } else if mod.IsSanitizerEnabled(cc.Hwasan) || (mod.IsSanitizerEnabled(cc.Fuzzer) && mctx.Arch().ArchType == android.Arm64) { - // TODO(b/180495975): HWASan for static Rust binaries isn't supported yet. + // TODO(b/204776996): HWASan for static Rust binaries isn't supported yet. if binary, ok := mod.compiler.(binaryInterface); ok { if binary.staticallyLinked() { mctx.ModuleErrorf("HWASan is not supported for static Rust executables yet.")