aboutsummaryrefslogtreecommitdiff
path: root/misc/cgo
diff options
context:
space:
mode:
authorArchana R <aravind5@in.ibm.com>2022-08-10 09:57:51 -0500
committerThan McIntosh <thanm@google.com>2022-08-11 17:23:33 +0000
commitdfbecc06e73b79aaeee4220b3e760cbd76050ae5 (patch)
tree18edf27107bf008a216b4383b80f0383afcc0066 /misc/cgo
parent133c0e9011b8c0e13442cdb754d7f6a8ac54ce00 (diff)
downloadgo-dfbecc06e73b79aaeee4220b3e760cbd76050ae5.tar.gz
go-dfbecc06e73b79aaeee4220b3e760cbd76050ae5.zip
misc/cgo/testsanitizers: fix code to detect gcc version correctly
The current implementation of compilerVersion incorrectly gives an error message that the compiler version is too old even though the system has a recent compiler. This happens for specifically for the gcc compiler and causes ASAN tests to be skipped. Replacing -v with gcc dump version options seems to fix it. Running ./testsanitizers.test -test.v now shows the ASAN tests being run. --- PASS: TestASAN (16.81s) --- PASS: TestASAN/asan_useAfterReturn (0.60s) --- PASS: TestASAN/asan_global5 (0.61s) --- PASS: TestASAN/asan_unsafe_fail1 (0.73s) --- PASS: TestASAN/asan_unsafe_fail3 (0.73s) --- PASS: TestASAN/asan_unsafe_fail2 (0.74s) --- PASS: TestASAN/asan_global4_fail (0.74s) --- PASS: TestASAN/asan5_fail (0.74s) --- PASS: TestASAN/asan3_fail (0.88s) --- PASS: TestASAN/asan4_fail (0.89s) --- PASS: TestASAN/asan2_fail (0.99s) --- PASS: TestASAN/asan_global3_fail (1.00s) --- PASS: TestASAN/asan_global1_fail (1.01s) --- PASS: TestASAN/asan1_fail (1.01s) --- PASS: TestASAN/asan_global2_fail (1.02s) PASS Fixes #54370 Change-Id: Iac13a1cf37de54432a6e49555f61e9ec1d781ab8 Reviewed-on: https://go-review.googlesource.com/c/go/+/422574 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Damien Neil <dneil@google.com> Run-TryBot: Archana Ravindar <aravind5@in.ibm.com> Reviewed-by: Than McIntosh <thanm@google.com>
Diffstat (limited to 'misc/cgo')
-rw-r--r--misc/cgo/testsanitizers/cc_test.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/misc/cgo/testsanitizers/cc_test.go b/misc/cgo/testsanitizers/cc_test.go
index 4f0252a27c..f447b5c89f 100644
--- a/misc/cgo/testsanitizers/cc_test.go
+++ b/misc/cgo/testsanitizers/cc_test.go
@@ -202,16 +202,16 @@ func compilerVersion() (version, error) {
var match [][]byte
if bytes.HasPrefix(out, []byte("gcc")) {
compiler.name = "gcc"
- cmd, err := cc("-v")
+ cmd, err := cc("-dumpfullversion", "-dumpversion")
if err != nil {
return err
}
- out, err := cmd.CombinedOutput()
+ out, err := cmd.Output()
if err != nil {
// gcc, but does not support gcc's "-v" flag?!
return err
}
- gccRE := regexp.MustCompile(`gcc version (\d+)\.(\d+)`)
+ gccRE := regexp.MustCompile(`(\d+)\.(\d+)`)
match = gccRE.FindSubmatch(out)
} else {
clangRE := regexp.MustCompile(`clang version (\d+)\.(\d+)`)