{"record":{"id":"a7a8a3ffa2154f76","repo":"golang/go","slug":"s-can-not-find-compilation-command-in-q","errorCode":null,"errorMessage":"%s: can not find compilation command in %q","messagePattern":"(.+?): can not find compilation command in %q","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cmd/go/internal/work/buildid.go","lineNumber":295,"sourceCode":"\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}\n\n\t\tfields, _ := quoted.Split(compiler)\n\t\tif len(fields) == 0 {\n\t\t\treturn \"\", \"\", fmt.Errorf(\"%s: compilation command confusion %q\", name, out)\n\t\t}\n\t\texe = fields[0]\n\t\tif !strings.ContainsAny(exe, `/\\`) {\n\t\t\tif lp, err := pathcache.LookPath(exe); err == nil {\n\t\t\t\texe = lp\n\t\t\t}\n\t\t}\n\t\tid, err = buildid.ReadFile(exe)\n\t\tif err != nil {\n\t\t\treturn \"\", \"\", err\n\t\t}\n\n\t\t// If we can't find a build ID, use a hash.","sourceCodeStart":277,"sourceCodeEnd":313,"githubUrl":"https://github.com/golang/go/blob/b6b368adc57c96c3151d224d172029f233ead2c3/src/cmd/go/internal/work/buildid.go#L277-L313","documentation":"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.","triggerScenarios":"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.","commonSituations":"Building Go against a self-built gcc trunk; a distro's gcc snapshot package; a compiler wrapper that reformats -### output.","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."],"exampleFix":"// before — self-built gcc trunk\n$ CC=/opt/gcc-trunk/bin/gcc go build ./...\n// error: /opt/gcc-trunk/bin/gcc: can not find compilation command in \"...\"\n\n// after — use release gcc\n$ CC=gcc go build ./...\n# or inspect: /opt/gcc-trunk/bin/gcc -### -x c -c -","handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["gccgo","cgo","toolchain","compiler-detection"],"backgroundTag":null,"analyzedSha":"b6b368adc57c96c3151d224d172029f233ead2c3","analyzedAt":"2026-08-12T00:22:02.250Z","schemaVersion":2},"datasetVersion":"2026-08-12T12:31:55.035Z"}