golang/go · error
action contains multiple PGO profile dependencies
Error message
action contains multiple PGO profile dependencies
What it means
When executing a build action, the go tool walks a.Deps for entries whose Mode is "preprocess PGO profile". At most one such dependency is expected per action; this fires when a second is found, indicating the action graph was constructed with duplicate PGO-profile dependencies. It is an internal invariant violation in the build-action planner, not caused by ordinary source or flag input.
Source
Thrown at src/cmd/go/internal/work/exec.go:844
embed.Files = make(map[string]string)
for _, file := range p.EmbedFiles {
embed.Files[file] = fsys.Actual(filepath.Join(p.Dir, file))
}
js, err := json.MarshalIndent(&embed, "", "\t")
if err != nil {
return fmt.Errorf("marshal embedcfg: %v", err)
}
embedcfg = js
}
// Find PGO profile if needed.
var pgoProfile string
for _, a1 := range a.Deps {
if a1.Mode != "preprocess PGO profile" {
continue
}
if pgoProfile != "" {
return fmt.Errorf("action contains multiple PGO profile dependencies")
}
pgoProfile = a1.built
}
var coverageConfig string
if coverPr != nil {
coverageConfig = coverPr.coverageConfig
}
if p.Internal.BuildInfo != nil && cfg.ModulesEnabled {
prog := modload.ModInfoProg(p.Internal.BuildInfo.String(), cfg.BuildToolchainName == "gccgo")
if len(prog) > 0 {
if err := sh.writeFile(objdir+"_gomod_.go", prog); err != nil {
return err
}
gofiles = append(gofiles, objdir+"_gomod_.go")
}
}View on GitHub (pinned to b6b368adc5)
Solutions
- Build with -pgo=off to confirm the issue is PGO-specific
- Ensure the module has at most one default.pgo file (check the package directory and replace directives)
- Report as a Go toolchain bug with the module layout and exact build flags
Example fix
// before go build -pgo=auto ./... // after (isolate the cause) go build -pgo=off ./...
Defensive patterns
Strategy: validation
Validate before calling
// Confirm at most one PGO profile before a -pgo build
matches, _ := filepath.Glob("*.pgo")
if len(matches) > 1 {
return fmt.Errorf("multiple pgo files present: %v", matches)
} Prevention
- Keep at most one default.pgo in the module root
- Use -pgo=off when profile-guided optimization is not needed
- Pin the Go version so action-graph behavior is stable
When it happens
Trigger: Fires in (b *Builder).build inside the `for _, a1 := range a.Deps` loop when pgoProfile is already non-empty and another a1.Mode == "preprocess PGO profile" is encountered.
Common situations: Unusual combinations of -pgo flags, a module with multiple default.pgo files resolved by the loader, or a toolchain bug in action-graph construction. Very rare in normal PGO workflows.
Related errors
- vet config not found
- marshal embedcfg: %v
- internal error marshaling vet config: %v
- error reading profile header: %w
- internal error in windynrelocsym: redirect GOT token applied
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/cf491ac5a2f7e7b0.
Report an issue: GitHub.