{"record":{"id":"3a7b2e68a5d8af70","repo":"golang/go","slug":"s-can-not-find-version-number-in-q","errorCode":null,"errorMessage":"%s: can not find version number in %q","messagePattern":"(.+?): can not find version number in %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/buildid.go","lineNumber":278,"sourceCode":"\t\t\t\t// Check that the next field is plausibly a version number.\n\t\t\t\t// We require only that it begins with an ASCII digit,\n\t\t\t\t// since we don't know what version numbering schemes a given\n\t\t\t\t// C compiler may use. (Clang and GCC mostly seem to follow the scheme X.Y.Z,\n\t\t\t\t// but in https://go.dev/issue/64619 we saw \"8.3 [DragonFly]\", and who knows\n\t\t\t\t// what other C compilers like \"zig cc\" might report?)\n\t\t\t\tnext := fields[i+1]\n\t\t\t\tif len(next) > 0 && next[0] >= '0' && next[0] <= '9' {\n\t\t\t\t\tversion = line\n\t\t\t\t\tbreak\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tif version != \"\" {\n\t\t\tbreak\n\t\t}\n\t}\n\tif version == \"\" {\n\t\treturn \"\", \"\", fmt.Errorf(\"%s: can not find version number in %q\", name, out)\n\t}\n\n\tif !strings.Contains(version, \"experimental\") {\n\t\t// This is a release. Use this line as the tool ID.\n\t\tid = version\n\t} else {\n\t\t// This is a development version. The first line with\n\t\t// a leading space is the compiler proper.\n\t\tcompiler := \"\"\n\t\tfor _, line := range lines {\n\t\t\tif strings.HasPrefix(line, \" \") && !strings.HasPrefix(line, \" (in-process)\") {\n\t\t\t\tcompiler = line\n\t\t\t\tbreak\n\t\t\t}\n\t\t}\n\t\tif compiler == \"\" {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"%s: can not find compilation command in %q\", name, out)\n\t\t}","sourceCodeStart":260,"sourceCodeEnd":296,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/buildid.go#L260-L296","documentation":"gccToolIDPrefix parsed the -### output line-by-line looking for a token 'version' immediately followed by a digit. If no line matches, the compiler's output format is unrecognized and the tool ID cannot be derived. The raw output is included in the error.","triggerScenarios":"A C/gccgo compiler whose -### output doesn't include a 'version <digit...>' field — e.g. some clang builds, zig cc, tinycc, or a wrapper script that strips version info. Localized output is forced to C via LC_ALL=C, so localization isn't the cause.","commonSituations":"Using 'zig cc' or a musl-cross wrapper; a stripped/embedded clang; a custom gcc wrapper that filters -v output; an exotic vendor gcc.","solutions":["Use a mainstream gcc or gccgo release whose -### output is well-formed.","If using clang, ensure it's a complete install (not a stub).","File a bug / use a Go version with broader compiler-output parsing, or set -gcflags to bypass tool ID detection where supported.","Inspect the raw output quoted in the error to see what the compiler actually emits."],"exampleFix":"// before\n$ CC='zig cc' go build ./...\n// error: zig: can not find version number in \"...\"\n\n// after — use a standard gcc\n$ CC=gcc go build ./...","handlingStrategy":"validation","validationCode":"// Check that a compiler emits a parseable 'version <digit>' line.\nfunc checkCompilerVersionLine(name string) error {\n    cmd := exec.Command(name, \"-###\", \"-x\", \"c\", \"-c\", \"-\")\n    cmd.Env = append(os.Environ(), \"LC_ALL=C\")\n    out, _ := cmd.CombinedOutput()\n    re := regexp.MustCompile(`(?m)version\\s+[0-9]`)\n    if !re.Match(out) {\n        return fmt.Errorf(\"%s emits no parseable version line; use a standard gcc/gccgo\", name)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use mainstream gcc/gccgo releases for cgo/gccgo builds.","Avoid 'zig cc' or stripped wrapper compilers for Go's tool-ID detection.","Test the compiler's -### output in CI before relying on it."],"tags":["gccgo","cgo","toolchain","compiler-detection"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}