golang/go · error

unrecognized compiler %q

Error message

unrecognized compiler %q

What it means

Thrown by the compiler prefix condition in DefaultConds. The condition accepts only the two Go compiler toolchains — 'gc' (the standard compiler) and 'gccgo'. Any other suffix errors at conds.go:52-57 because there is no third compiler to compare against.

Source

Thrown at src/cmd/internal/script/conds.go:56

				return true, nil
			}
			if _, ok := syslist.KnownArch[suffix]; !ok {
				return false, fmt.Errorf("unrecognized GOARCH %q", suffix)
			}
			return false, nil
		})

	conds["compiler"] = PrefixCondition(
		"runtime.Compiler == <suffix>",
		func(_ *State, suffix string) (bool, error) {
			if suffix == runtime.Compiler {
				return true, nil
			}
			switch suffix {
			case "gc", "gccgo":
				return false, nil
			default:
				return false, fmt.Errorf("unrecognized compiler %q", suffix)
			}
		})

	conds["root"] = BoolCondition("os.Geteuid() == 0", os.Geteuid() == 0)

	return conds
}

// Condition returns a Cond with the given summary and evaluation function.
func Condition(summary string, eval func(*State) (bool, error)) Cond {
	return &funcCond{eval: eval, usage: CondUsage{Summary: summary}}
}

type funcCond struct {
	eval  func(*State) (bool, error)
	usage CondUsage
}

View on GitHub (pinned to b6b368adc5)

Solutions

  1. Use exactly 'gc' or 'gccgo' as the suffix.
  2. If you need to detect a third-party compiler, register a custom condition rather than overloading 'compiler'.
  3. Verify the current value with runtime.Compiler to understand which branch will be taken.

Example fix

// before
[compiler:gcc] exec go build
// after
[compiler:gccgo] exec go build
Defensive patterns

Strategy: validation

Validate before calling

func validCompiler(v string) bool {
    return v == "gc" || v == "gccgo"
}

Prevention

When it happens

Trigger: Writing [compiler:<x>] with a value other than the current runtime.Compiler and not in {gc, gccgo}, e.g. [compiler:gcc], [compiler:llvm], or [compiler:tinygo].

Common situations: Confusing the Go compiler name with a C compiler (gcc); referencing an experimental or third-party Go compiler that the script engine does not know; typo such as [compiler:gccgoo].

Related errors


AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12). Data as JSON: /api/errors/0cd08c9c75fc9837. Report an issue: GitHub.