golang/go · error
%s: %v; output: %q
Error message
%s: %v; output: %q
What it means
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.
Source
Thrown at src/cmd/go/internal/work/buildid.go:246
b.id.Lock()
id = b.gccToolIDCache[key]
exe = b.gccToolIDCache[key+".exe"]
b.id.Unlock()
if id != "" {
return id, exe, nil
}
// Invoke the driver with -### to see the subcommands and the
// version strings. Use -x to set the language. Pretend to
// compile an empty file on standard input.
cmdline := str.StringList(prefix, name, "-###", "-x", language, "-c", "-")
cmd := exec.Command(cmdline[0], cmdline[1:]...)
// Force untranslated output so that we see the string "version".
cmd.Env = append(os.Environ(), "LC_ALL=C")
out, err := cmd.CombinedOutput()
if err != nil {
return "", "", fmt.Errorf("%s: %v; output: %q", name, err, out)
}
version := ""
lines := strings.Split(string(out), "\n")
for _, line := range lines {
fields := strings.Fields(line)
for i, field := range fields {
if strings.HasSuffix(field, ":") {
// Avoid parsing fields of lines like "Configured with: …", which may
// contain arbitrary substrings.
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 knowsView on GitHub (pinned to b6b368adc5)
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.).
Example fix
// before $ CC=clang-99 go build ./... // error: clang-99: exec: "clang-99": executable file not found in $PATH; output: "" // after $ which clang /usr/bin/clang $ CC=/usr/bin/clang go build ./...
Defensive patterns
Strategy: validation
Validate before calling
// Confirm the configured C/gccgo compiler is invocable.
func checkCompiler(name string) error {
lp, err := exec.LookPath(name)
if err != nil { return fmt.Errorf("compiler %q not on PATH", name) }
cmd := exec.Command(lp, "-###", "-x", "c", "-c", "-")
cmd.Env = append(os.Environ(), "LC_ALL=C")
if out, err := cmd.CombinedOutput(); err != nil {
return fmt.Errorf("%s invocation failed: %v; output: %q", lp, err, out)
}
return nil
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- %s: can not find version number in %q
- %s: can not find compilation command in %q
- %s: compilation command confusion %q
- C compiler %q not found: %v
- Fortran source files not allowed when not using cgo or SWIG:
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/6f7c7175ce7df233.
Report an issue: GitHub.