Skip to content

Commit ddfedec

Browse files
committed
cmd/racebuild: add -copyonfail debugging flag
When debugging new versions of the race detector runtime, it can be useful to copy the newly built syso back to the local machine's Go repo (from the gomote) even if race.bat/race.bash fails, so as to analyze the syso or run other tests with it. Add a command line option "-copyonfail" that attempts to perform the copy even if the script run fails. Updates golang/go#35006. Updates golang/go#53539. Change-Id: I688b8673b444d1b6d948f10ca2fa4ab109eade44 Reviewed-on: https://go-review.googlesource.com/c/build/+/415675 Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Than McIntosh <[email protected]> TryBot-Result: Gopher Robot <[email protected]>
1 parent c0c4fab commit ddfedec

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

cmd/racebuild/racebuild.go

+10-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var (
3535
flagRev = flag.String("rev", "", "llvm-project git revision from https://github.com/llvm/llvm-project (required)")
3636
flagCherryPick = flag.String("cherrypick", "", "go.googlesource.com CL reference to cherry-pick on top of Go repo (takes form 'refs/changes/NNN/<CL number>/<patchset number>') (optional)")
3737
flagCheckout = flag.String("checkout", "", "go.googlesource.com CL reference to check out on top of Go repo (takes form 'refs/changes/NNN/<CL number>/<patchset number>') (optional)")
38+
flagCopyOnFail = flag.Bool("copyonfail", false, "Attempt to copy newly built race syso into Go repo even if script fails.")
3839
flagGoRev = flag.String("gorev", "HEAD", "Go repository revision to use; HEAD is relative to --goroot")
3940
flagPlatforms = flag.String("platforms", "all", `comma-separated platforms (such as "linux/amd64") to rebuild, or "all"`)
4041
)
@@ -509,11 +510,16 @@ func (p *Platform) Build(ctx context.Context) error {
509510
if _, err := p.Gomote(ctx, "put", "-mode=0700", p.Inst, script.Name(), targetName); err != nil {
510511
return err
511512
}
513+
var scriptRunErr error
512514
gogitop, gosrcref := setupForGoRepoGitOp()
513515
if _, err := p.Gomote(ctx, "run", "-e=REV="+*flagRev, "-e=GOREV="+goRev,
514516
"-e=GOGITOP="+gogitop, "-e=GOSRCREF="+gosrcref,
515517
p.Inst, targetName); err != nil {
516-
return err
518+
if !*flagCopyOnFail {
519+
return err
520+
}
521+
log.Printf("%v: gomote script run failed, continuing...\n", p.Name())
522+
scriptRunErr = err
517523
}
518524

519525
// The script is supposed to leave updated runtime at that path. Copy it out.
@@ -527,6 +533,9 @@ func (p *Platform) Build(ctx context.Context) error {
527533
if err := p.WriteSyso(filepath.Join(*flagGoroot, "src", "runtime", "race", syso), targz); err != nil {
528534
return fmt.Errorf("%v", err)
529535
}
536+
if scriptRunErr != nil {
537+
return err
538+
}
530539

531540
log.Printf("%v: build completed", p.Name())
532541
return nil

0 commit comments

Comments
 (0)