golang/go · error
%s: can not find compilation command in %q
Error message
%s: can not find compilation command in %q
What it means
For development ('experimental') builds of gcc/gccgo, gccToolIDPrefix expects the first line starting with a space (and not ' (in-process)') to be the expanded compiler invocation. If no such line exists, the version was marked experimental but the compiler subcommand couldn't be located.
Source
Thrown at src/cmd/go/internal/work/buildid.go:295
if version == "" {
return "", "", fmt.Errorf("%s: can not find version number in %q", name, out)
}
if !strings.Contains(version, "experimental") {
// This is a release. Use this line as the tool ID.
id = version
} else {
// This is a development version. The first line with
// a leading space is the compiler proper.
compiler := ""
for _, line := range lines {
if strings.HasPrefix(line, " ") && !strings.HasPrefix(line, " (in-process)") {
compiler = line
break
}
}
if compiler == "" {
return "", "", fmt.Errorf("%s: can not find compilation command in %q", name, out)
}
fields, _ := quoted.Split(compiler)
if len(fields) == 0 {
return "", "", fmt.Errorf("%s: compilation command confusion %q", name, out)
}
exe = fields[0]
if !strings.ContainsAny(exe, `/\`) {
if lp, err := pathcache.LookPath(exe); err == nil {
exe = lp
}
}
id, err = buildid.ReadFile(exe)
if err != nil {
return "", "", err
}
// If we can't find a build ID, use a hash.View on GitHub (pinned to b6b368adc5)
Solutions
- Run '<compiler> -### -x c -c -' manually and inspect the output format.
- Switch to a stable release gcc/gccgo whose -### output is canonical.
- Report the compiler version upstream or to the Go issue tracker with the captured output.
- As a workaround, pin tool ID via GOFLAGS or use a release compiler for the build.
Example fix
// before — self-built gcc trunk $ CC=/opt/gcc-trunk/bin/gcc go build ./... // error: /opt/gcc-trunk/bin/gcc: can not find compilation command in "..." // after — use release gcc $ CC=gcc go build ./... # or inspect: /opt/gcc-trunk/bin/gcc -### -x c -c -
Defensive patterns
Strategy: fallback
Prevention
- Prefer release gcc/gccgo over development snapshots for Go builds.
- If you must use a snapshot, capture its -### output and verify it has an indented command line.
- Keep a release compiler available as a fallback in the build matrix.
When it happens
Trigger: A development snapshot of gcc/gccgo whose -### output omits the expanded cc1/cc1go subcommand line, or wraps it differently. The parser found 'experimental' in the version line but couldn't find the indented command line that follows.
Common situations: Building Go against a self-built gcc trunk; a distro's gcc snapshot package; a compiler wrapper that reformats -### output.
Related errors
- %s: %v; output: %q
- %s: can not find version number 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/a7a8a3ffa2154f76.
Report an issue: GitHub.