{"record":{"id":"6f7c7175ce7df233","repo":"golang/go","slug":"s-v-output-q","errorCode":null,"errorMessage":"%s: %v; output: %q","messagePattern":"(.+?): (.+?); output: %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/buildid.go","lineNumber":246,"sourceCode":"\tb.id.Lock()\n\tid = b.gccToolIDCache[key]\n\texe = b.gccToolIDCache[key+\".exe\"]\n\tb.id.Unlock()\n\n\tif id != \"\" {\n\t\treturn id, exe, nil\n\t}\n\n\t// Invoke the driver with -### to see the subcommands and the\n\t// version strings. Use -x to set the language. Pretend to\n\t// compile an empty file on standard input.\n\tcmdline := str.StringList(prefix, name, \"-###\", \"-x\", language, \"-c\", \"-\")\n\tcmd := exec.Command(cmdline[0], cmdline[1:]...)\n\t// Force untranslated output so that we see the string \"version\".\n\tcmd.Env = append(os.Environ(), \"LC_ALL=C\")\n\tout, err := cmd.CombinedOutput()\n\tif err != nil {\n\t\treturn \"\", \"\", fmt.Errorf(\"%s: %v; output: %q\", name, err, out)\n\t}\n\n\tversion := \"\"\n\tlines := strings.Split(string(out), \"\\n\")\n\tfor _, line := range lines {\n\t\tfields := strings.Fields(line)\n\t\tfor i, field := range fields {\n\t\t\tif strings.HasSuffix(field, \":\") {\n\t\t\t\t// Avoid parsing fields of lines like \"Configured with: …\", which may\n\t\t\t\t// contain arbitrary substrings.\n\t\t\t\tbreak\n\t\t\t}\n\t\t\tif field == \"version\" && i < len(fields)-1 {\n\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","sourceCodeStart":228,"sourceCodeEnd":264,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/buildid.go#L228-L264","documentation":"gccToolIDPrefix runs '<name> -### -x <language> -c -' (e.g. 'gcc -### -x c -c -') to capture the driver's expanded subcommands and version string. If cmd.CombinedOutput returns an error (binary missing, non-zero exit, signal), the error is wrapped with the binary name and the raw output for diagnosis.","triggerScenarios":"Building with cgo or gccgo where the configured C/gccgo compiler (CC, GCCGO, or auto-detected) doesn't exist on PATH, isn't executable, or crashes when invoked with -###. Also triggered by a compiler that emits to stderr and exits non-zero.","commonSituations":"CC points at a missing binary after a toolchain uninstall; cross-compile environments where the cross-gcc isn't installed; a misconfigured GCCGO env var; clang invoked with flags gcc expects.","solutions":["Verify the compiler exists: 'which gcc' / 'which gccgo' (or the value of CC/GCCGO).","Install the missing compiler (e.g. 'apt install gcc' or 'apt install gccgo').","Set CC=/full/path/to/gcc or GCCGO=/full/path/to/gccgo explicitly.","Inspect the captured output in the error for the real failure (missing cc1, permission denied, etc.)."],"exampleFix":"// before\n$ CC=clang-99 go build ./...\n// error: clang-99: exec: \"clang-99\": executable file not found in $PATH; output: \"\"\n\n// after\n$ which clang\n/usr/bin/clang\n$ CC=/usr/bin/clang go build ./...","handlingStrategy":"validation","validationCode":"// Confirm the configured C/gccgo compiler is invocable.\nfunc checkCompiler(name string) error {\n    lp, err := exec.LookPath(name)\n    if err != nil { return fmt.Errorf(\"compiler %q not on PATH\", name) }\n    cmd := exec.Command(lp, \"-###\", \"-x\", \"c\", \"-c\", \"-\")\n    cmd.Env = append(os.Environ(), \"LC_ALL=C\")\n    if out, err := cmd.CombinedOutput(); err != nil {\n        return fmt.Errorf(\"%s invocation failed: %v; output: %q\", lp, err, out)\n    }\n    return nil\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pin CC and GCCGO to absolute paths in CI.","Pre-validate the toolchain with 'gcc -v' / 'gccgo -v' before building.","Don't assume a compiler exists because it did in a previous image."],"tags":["gccgo","cgo","toolchain","compiler-detection"],"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:17:08.281Z"}