Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ff245242 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge "Move disabling rust sanitizers for linux_musl_x86 earlier" into main

parents ca280bf7 9759ed7b
Loading
Loading
Loading
Loading
+9 −17
Original line number Diff line number Diff line
@@ -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))