From bcf53701b7d4a78988a202375b48606457fd1b2f Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Wed, 17 Jan 2024 11:11:03 -0800 Subject: [PATCH] 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 --- cc/config/global.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cc/config/global.go b/cc/config/global.go index 85ebd6076..ec6dbcee7 100644 --- a/cc/config/global.go +++ b/cc/config/global.go @@ -16,6 +16,7 @@ package config import ( "runtime" + "slices" "strings" "android/soong/android" @@ -400,7 +401,7 @@ func init() { exportedVars.ExportStringList("CommonGlobalCflags", commonGlobalCflags) pctx.VariableFunc("CommonGlobalCflags", func(ctx android.PackageVarContext) string { - flags := commonGlobalCflags + flags := slices.Clone(commonGlobalCflags) // http://b/131390872 // Automatically initialize any uninitialized stack variables.