]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/dist: wait for run jobs to finish in case of a compiler error
authorAgniva De Sarker <agnivade@yahoo.co.in>
Fri, 3 Aug 2018 15:21:25 +0000 (20:51 +0530)
committerIan Lance Taylor <iant@golang.org>
Thu, 30 Aug 2018 21:11:54 +0000 (21:11 +0000)
Instead of calling run synchronously, we pass it through bgrun
and immediately wait for it to finish. This pushes all jobs
to execute through the bgwork channel and therefore causes
them to exit cleanly in case of a compiler error.

Fixes #25981

Change-Id: I789a85d23fabf32d144ab85a3c9f53546cb7765a
Reviewed-on: https://go-review.googlesource.com/127776
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/cmd/dist/build.go

index 06adccd9a4a7b564453001d1e54ba50e8568bfa7..d4f9dc4fbb5f41256f00fea2a5cca3c6bf8a3912 100644 (file)
@@ -805,10 +805,14 @@ func runInstall(dir string, ch chan struct{}) {
                compile = append(compile, "-asmhdr", pathf("%s/go_asm.h", workdir))
        }
        compile = append(compile, gofiles...)
-       run(path, CheckExit|ShowOutput, compile...)
+       var wg sync.WaitGroup
+       // We use bgrun and immediately wait for it instead of calling run() synchronously.
+       // This executes all jobs through the bgwork channel and allows the process
+       // to exit cleanly in case an error occurs.
+       bgrun(&wg, path, compile...)
+       bgwait(&wg)
 
        // Compile the files.
-       var wg sync.WaitGroup
        for _, p := range files {
                if !strings.HasSuffix(p, ".s") {
                        continue
@@ -858,7 +862,8 @@ func runInstall(dir string, ch chan struct{}) {
 
        // Remove target before writing it.
        xremove(link[targ])
-       run("", CheckExit|ShowOutput, link...)
+       bgrun(&wg, "", link...)
+       bgwait(&wg)
 }
 
 // matchfield reports whether the field (x,y,z) matches this build.