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

Commit 75db9318 authored by Liz Kammer's avatar Liz Kammer
Browse files

Iterate over sanitizers

Test: go test soong tests
Change-Id: If89b7d0b04cad79b42a08504d4fcff36e914b7a4
parent 7b920b40
Loading
Loading
Loading
Loading
+3 −19
Original line number Original line Diff line number Diff line
@@ -53,25 +53,9 @@ func RegisterCCBuildComponents(ctx android.RegistrationContext) {
	})
	})


	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
	ctx.PostDepsMutators(func(ctx android.RegisterMutatorsContext) {
		ctx.TopDown("asan_deps", sanitizerDepsMutator(Asan))
		for _, san := range Sanitizers {
		ctx.BottomUp("asan", sanitizerMutator(Asan)).Parallel()
			san.registerMutators(ctx)

		}
		ctx.TopDown("hwasan_deps", sanitizerDepsMutator(Hwasan))
		ctx.BottomUp("hwasan", sanitizerMutator(Hwasan)).Parallel()

		ctx.TopDown("fuzzer_deps", sanitizerDepsMutator(Fuzzer))
		ctx.BottomUp("fuzzer", sanitizerMutator(Fuzzer)).Parallel()

		// cfi mutator shouldn't run before sanitizers that return true for
		// incompatibleWithCfi()
		ctx.TopDown("cfi_deps", sanitizerDepsMutator(cfi))
		ctx.BottomUp("cfi", sanitizerMutator(cfi)).Parallel()

		ctx.TopDown("scs_deps", sanitizerDepsMutator(scs))
		ctx.BottomUp("scs", sanitizerMutator(scs)).Parallel()

		ctx.TopDown("tsan_deps", sanitizerDepsMutator(tsan))
		ctx.BottomUp("tsan", sanitizerMutator(tsan)).Parallel()


		ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
		ctx.TopDown("sanitize_runtime_deps", sanitizerRuntimeDepsMutator).Parallel()
		ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
		ctx.BottomUp("sanitize_runtime", sanitizerRuntimeMutator).Parallel()
+24 −1
Original line number Original line Diff line number Diff line
@@ -79,12 +79,23 @@ const (
	Hwasan
	Hwasan
	tsan
	tsan
	intOverflow
	intOverflow
	cfi
	scs
	scs
	Fuzzer
	Fuzzer
	memtag_heap
	memtag_heap
	cfi // cfi is last to prevent it running before incompatible mutators
)
)


var Sanitizers = []SanitizerType{
	Asan,
	Hwasan,
	tsan,
	intOverflow,
	scs,
	Fuzzer,
	memtag_heap,
	cfi, // cfi is last to prevent it running before incompatible mutators
}

// Name of the sanitizer variation for this sanitizer type
// Name of the sanitizer variation for this sanitizer type
func (t SanitizerType) variationName() string {
func (t SanitizerType) variationName() string {
	switch t {
	switch t {
@@ -133,6 +144,18 @@ func (t SanitizerType) name() string {
	}
	}
}
}


func (t SanitizerType) registerMutators(ctx android.RegisterMutatorsContext) {
	switch t {
	case Asan, Hwasan, Fuzzer, scs, tsan, cfi:
		ctx.TopDown(t.variationName()+"_deps", sanitizerDepsMutator(t))
		ctx.BottomUp(t.variationName(), sanitizerMutator(t))
	case memtag_heap, intOverflow:
		// do nothing
	default:
		panic(fmt.Errorf("unknown SanitizerType %d", t))
	}
}

func (*Module) SanitizerSupported(t SanitizerType) bool {
func (*Module) SanitizerSupported(t SanitizerType) bool {
	switch t {
	switch t {
	case Asan:
	case Asan: