Move disabling rust sanitizers for linux_musl_x86 earlier
Setting Never at the end of begin() is too late, and SanitizerEnabled
is still being set. This causes the extra sanitizer versions to still
be created, but HideFromMake doesn't get called, causing conflicts
in the generated Android-${TARGET_PRODUCT}.mk.
Set Never earlier so that the rest of setting up sanitizers is skipped.
Fixes: 376075440
Flag: EXEMPT bugfix
Test: m USE_HOST_MUSL=true BUILD_HOST_static=true SANITIZE_HOST=address ASAN_OPTIONS="detect_leaks=0" ${OUT_DIR}/host/linux-x86/bin/dex2oat64
Change-Id: I48fc1f6fd9051b51c34374c56edacc30fb585642
diff --git a/rust/sanitize.go b/rust/sanitize.go
index c086880..b8f922f 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -94,14 +94,6 @@
"-C llvm-args=--hwasan-with-ifunc",
}
-func boolPtr(v bool) *bool {
- if v {
- return &v
- } else {
- return nil
- }
-}
-
func init() {
}
func (sanitize *sanitize) props() []interface{} {
@@ -111,6 +103,11 @@
func (sanitize *sanitize) begin(ctx BaseModuleContext) {
s := &sanitize.Properties.Sanitize
+ // Disable sanitizers for musl x86 modules, rustc does not support any sanitizers.
+ if ctx.Os() == android.LinuxMusl && ctx.Arch().ArchType == android.X86 {
+ s.Never = proptools.BoolPtr(true)
+ }
+
// Never always wins.
if Bool(s.Never) {
return
@@ -212,11 +209,6 @@
s.Memtag_heap = nil
}
- // Disable sanitizers for musl x86 modules, rustc does not support any sanitizers.
- if ctx.Os() == android.LinuxMusl && ctx.Arch().ArchType == android.X86 {
- s.Never = boolPtr(true)
- }
-
// TODO:(b/178369775)
// For now sanitizing is only supported on non-windows targets
if ctx.Os() != android.Windows && (Bool(s.Hwaddress) || Bool(s.Address) || Bool(s.Memtag_heap) || Bool(s.Fuzzer)) {
@@ -318,16 +310,16 @@
sanitizerSet := false
switch t {
case cc.Fuzzer:
- sanitize.Properties.Sanitize.Fuzzer = boolPtr(b)
+ sanitize.Properties.Sanitize.Fuzzer = proptools.BoolPtr(b)
sanitizerSet = true
case cc.Asan:
- sanitize.Properties.Sanitize.Address = boolPtr(b)
+ sanitize.Properties.Sanitize.Address = proptools.BoolPtr(b)
sanitizerSet = true
case cc.Hwasan:
- sanitize.Properties.Sanitize.Hwaddress = boolPtr(b)
+ sanitize.Properties.Sanitize.Hwaddress = proptools.BoolPtr(b)
sanitizerSet = true
case cc.Memtag_heap:
- sanitize.Properties.Sanitize.Memtag_heap = boolPtr(b)
+ sanitize.Properties.Sanitize.Memtag_heap = proptools.BoolPtr(b)
sanitizerSet = true
default:
panic(fmt.Errorf("setting unsupported sanitizerType %d", t))