From: Ian Lance Taylor Date: Thu, 6 Mar 2025 20:54:27 +0000 (-0800) Subject: cmd/cgo/internal/testsanitizers: for "leak", use -fsanitize=address X-Git-Tag: go1.25rc1~806 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=f55bb135d28bc95131a8c987d50350e5c6d7f633;p=gostls13.git cmd/cgo/internal/testsanitizers: for "leak", use -fsanitize=address We currently test the leak detector by running "go build -asan", which will pass -fsanitize=address to the C compiler. So use that when testing whether the option works. Fixes #72128 Change-Id: I4efc0b689bfda04c80dbac30a5c757215f297d2f Reviewed-on: https://go-review.googlesource.com/c/go/+/655535 Reviewed-by: Ian Lance Taylor Reviewed-by: Cherry Mui Auto-Submit: Ian Lance Taylor LUCI-TryBot-Result: Go LUCI --- diff --git a/src/cmd/cgo/internal/testsanitizers/cc_test.go b/src/cmd/cgo/internal/testsanitizers/cc_test.go index 193d24d52c..fa0105b11a 100644 --- a/src/cmd/cgo/internal/testsanitizers/cc_test.go +++ b/src/cmd/cgo/internal/testsanitizers/cc_test.go @@ -361,10 +361,18 @@ func configure(sanitizer string) *config { return c } + sanitizerOpt := sanitizer + // For the leak detector, we use "go build -asan", + // which implies the address sanitizer. + // We may want to adjust this someday. + if sanitizer == "leak" { + sanitizerOpt = "address" + } + c := &config{ sanitizer: sanitizer, - cFlags: []string{"-fsanitize=" + sanitizer}, - ldFlags: []string{"-fsanitize=" + sanitizer}, + cFlags: []string{"-fsanitize=" + sanitizerOpt}, + ldFlags: []string{"-fsanitize=" + sanitizerOpt}, } if testing.Verbose() {