Skip to content

"Found multiple definitions for subrepo <arch>" error when cross-compiling #3222

@chrisnovakovic

Description

@chrisnovakovic

Spotted today in the context of the go-rules release workflow, but has been seen before too:

$ ./pleasew build --profile release -o plugin.go.pleasegotool:$(pwd)/plz-out/bin/tools/please_go/please_go -p -v notice //package:please_go_release_files //package:driver_release_files
20:00:09.384 NOTICE: Build running for 0s, 0 / 1 tasks done, 0 workers busy
20:00:09.407 CRITICAL: Found multiple definitions for subrepo 'darwin_arm64' (&{Name:darwin_arm64 Root: PackageRoot: Target:<nil> State:0xc00021a3c0 Arch:{OS:darwin Arch:arm64} IsCrossCompile:true AdditionalConfigFiles:[] fs:{} fsSync:{done:{_:{} v:1} m:{state:0 sema:0}}} s &{Name:darwin_arm64 Root: PackageRoot: Target:<nil> State:0xc00021a3c0 Arch:{OS:darwin Arch:arm64} IsCrossCompile:true AdditionalConfigFiles:[] fs:<nil> fsSync:{done:{_:{} v:0} m:{state:0 sema:0}}})
Error: Process completed with exit code 1.

The architecture subrepo causing the problem isn't consistent - I've seen it fail with darwin_arm64 and linux_amd64 on different runs of the workflow. From the function that produces the error message, it seems that two subrepos can be equal if the structs representing them are deeply equal:

please/src/core/graph.go

Lines 105 to 114 in 382cfd6

func (graph *BuildGraph) MaybeAddSubrepo(subrepo *Subrepo) *Subrepo {
if !graph.subrepos.Add(subrepo.Name, subrepo) {
old := graph.subrepos.Get(subrepo.Name)
if !reflect.DeepEqual(old, subrepo) {
log.Fatalf("Found multiple definitions for subrepo '%s' (%+v s %+v)", old.Name, old, subrepo)
}
return old
}
return subrepo
}

Perhaps this condition is slightly too strict - the unexported fs and fsSync fields were added relatively recently, in #3038, and from the error message above it appears that the subrepos are identical in other respects, so perhaps they should be excluded from the equality comparison.

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions