summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2024-10-29 11:47:46 -0700
committer Colin Cross <ccross@android.com> 2024-10-29 19:10:21 +0000
commit9759ed7b2641cfa19fca4a122cd82308e13c7ed9 (patch)
tree2162d4734bf27c9c950a3fb828b74c6466fc9a73
parent3659226dcb3c5a8ed23679530d5ede3263134f8c (diff)
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
-rw-r--r--rust/sanitize.go26
1 files changed, 9 insertions, 17 deletions
diff --git a/rust/sanitize.go b/rust/sanitize.go
index c086880ed..b8f922fe2 100644
--- a/rust/sanitize.go
+++ b/rust/sanitize.go
@@ -94,14 +94,6 @@ var hwasanFlags = []string{
"-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) props() []interface{} {
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 @@ func (sanitize *sanitize) begin(ctx BaseModuleContext) {
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 @@ func (sanitize *sanitize) SetSanitizer(t cc.SanitizerType, b bool) {
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))