golang/go · error
%s: compilation command confusion %q
Error message
%s: compilation command confusion %q
What it means
gccToolIDPrefix found the indented compiler-command line in experimental -### output, but quoted.Split on that line yielded zero fields. This means the line consists only of whitespace/quotes that the splitter couldn't tokenize — an invariant violation in the compiler's output format.
Source
Thrown at src/cmd/go/internal/work/buildid.go:300
// 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.
if id == "" {
id = b.fileHash(exe)
}
}
View on GitHub (pinned to b6b368adc5)
Solutions
- Capture the raw -### output and inspect the indented line that should hold the command.
- Use a release gcc/gccgo rather than a patched/experimental one.
- Report the malformed output to the Go issue tracker.
- Temporarily set -compiler=gc if gccgo isn't required.
Example fix
// before $ GCCGO=/opt/gccgo-patched/bin/gccgo go build -compiler=gccgo ./... // error: /opt/gccgo-patched/bin/gccgo: compilation command confusion "..." // after $ GCCGO=gccgo go build -compiler=gccgo ./... # or diagnose: /opt/gccgo-patched/bin/gccgo -### -x go -c -
Defensive patterns
Strategy: fallback
Prevention
- Treat 'compilation command confusion' as a signal the compiler driver is non-standard.
- Switch to a release gcc/gccgo.
- Report malformed -### output upstream rather than working around it long-term.
When it happens
Trigger: An experimental gcc/gccgo whose expanded command line is empty or malformed (e.g. just a stray quote or whitespace). Extremely rare; indicates a broken or non-standard compiler driver.
Common situations: A patched gcc that emits an empty expanded command; a wrapper that strips all tokens but leaves the line prefix; concurrent truncation of the captured output.
Related errors
- %s: %v; output: %q
- %s: can not find version number in %q
- %s: can not find compilation command in %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/6c8dbb9ce93ad13d.
Report an issue: GitHub.