mirror of
https://github.com/golang/go
synced 2024-11-17 07:04:44 -07:00
cmd/go: relax version regexp from CL 547998
In CL 547998 I relaxed cmd/go's parsing of version lines to allow it to recognize clang versions with vendor prefixes. To prevent false-positives, I added a check for a version 3-tuple following the word "version". However, it appears that some releases of GCC use only a 2-tuple instead. Updates #64423. Fixes #64619. Change-Id: I5f1d0881b6295544a46ab958c6ad4c2155cf51fe Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/548120 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
This commit is contained in:
parent
78b42a5338
commit
6cdf2ccae8
@ -9,7 +9,6 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"os/exec"
|
||||
"regexp"
|
||||
"strings"
|
||||
|
||||
"cmd/go/internal/base"
|
||||
@ -237,7 +236,6 @@ func (b *Builder) gccToolID(name, language string) (id, exe string, err error) {
|
||||
}
|
||||
|
||||
version := ""
|
||||
gccVersionRE := regexp.MustCompile(`^[0-9]+\.[0-9]+\.[0-9]+`)
|
||||
lines := strings.Split(string(out), "\n")
|
||||
for _, line := range lines {
|
||||
fields := strings.Fields(line)
|
||||
@ -247,9 +245,18 @@ func (b *Builder) gccToolID(name, language string) (id, exe string, err error) {
|
||||
// contain arbitrary substrings.
|
||||
break
|
||||
}
|
||||
if field == "version" && i < len(fields)-1 && gccVersionRE.MatchString(fields[i+1]) {
|
||||
version = line
|
||||
break
|
||||
if field == "version" && i < len(fields)-1 {
|
||||
// Check that the next field is plausibly a version number.
|
||||
// We require only that it begins with an ASCII digit,
|
||||
// since we don't know what version numbering schemes a given
|
||||
// C compiler may use. (Clang and GCC mostly seem to follow the scheme X.Y.Z,
|
||||
// but in https://go.dev/issue/64619 we saw "8.3 [DragonFly]", and who knows
|
||||
// what other C compilers like "zig cc" might report?)
|
||||
next := fields[i+1]
|
||||
if len(next) > 0 && next[0] >= '0' && next[0] <= '9' {
|
||||
version = line
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
if version != "" {
|
||||
|
Loading…
Reference in New Issue
Block a user