Fix race CommonGlobalCflags when running tests in parallel.

Clone the commonGlobalCflags global variable when modifying it so that
it gets a unique object per context.

Test: go test -race ./...
Change-Id: Ia4b91c40939d4b4d338bd11e4d4f523521874548
This commit is contained in:
Colin Cross 2024-01-17 11:11:03 -08:00
parent 6c7e8ff86f
commit bcf53701b7

View file

@ -16,6 +16,7 @@ package config
import ( import (
"runtime" "runtime"
"slices"
"strings" "strings"
"android/soong/android" "android/soong/android"
@ -400,7 +401,7 @@ func init() {
exportedVars.ExportStringList("CommonGlobalCflags", commonGlobalCflags) exportedVars.ExportStringList("CommonGlobalCflags", commonGlobalCflags)
pctx.VariableFunc("CommonGlobalCflags", func(ctx android.PackageVarContext) string { pctx.VariableFunc("CommonGlobalCflags", func(ctx android.PackageVarContext) string {
flags := commonGlobalCflags flags := slices.Clone(commonGlobalCflags)
// http://b/131390872 // http://b/131390872
// Automatically initialize any uninitialized stack variables. // Automatically initialize any uninitialized stack variables.