@@ -124,11 +124,6 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
124124 return err
125125 }
126126
127- // The slice of jobs that orchestrates most of the build.
128- // This is somewhat like an in-memory Makefile with each job being a
129- // Makefile target.
130- var jobs []* compileJob
131-
132127 // Create the *ssa.Program. This does not yet build the entire SSA of the
133128 // program so it's pretty fast and doesn't need to be parallelized.
134129 program := lprogram .LoadSSA ()
@@ -311,7 +306,6 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
311306 return os .Rename (f .Name (), bitcodePath )
312307 },
313308 }
314- jobs = append (jobs , job )
315309 packageJobs = append (packageJobs , job )
316310 }
317311
@@ -402,14 +396,13 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
402396 return nil
403397 },
404398 }
405- jobs = append (jobs , programJob )
406399
407400 // Check whether we only need to create an object file.
408401 // If so, we don't need to link anything and will be finished quickly.
409402 outext := filepath .Ext (outpath )
410403 if outext == ".o" || outext == ".bc" || outext == ".ll" {
411404 // Run jobs to produce the LLVM module.
412- err := runJobs (jobs )
405+ err := runJobs (programJob )
413406 if err != nil {
414407 return err
415408 }
@@ -450,7 +443,6 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
450443 return ioutil .WriteFile (objfile , llvmBuf .Bytes (), 0666 )
451444 },
452445 }
453- jobs = append (jobs , outputObjectFileJob )
454446
455447 // Prepare link command.
456448 linkerDependencies := []* compileJob {outputObjectFileJob }
@@ -465,8 +457,6 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
465457 if err != nil {
466458 return err
467459 }
468- jobs = append (jobs , job .dependencies ... )
469- jobs = append (jobs , job )
470460 linkerDependencies = append (linkerDependencies , job )
471461 }
472462
@@ -484,7 +474,6 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
484474 return err
485475 },
486476 }
487- jobs = append (jobs , job )
488477 linkerDependencies = append (linkerDependencies , job )
489478 }
490479
@@ -503,7 +492,6 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
503492 return err
504493 },
505494 }
506- jobs = append (jobs , job )
507495 linkerDependencies = append (linkerDependencies , job )
508496 }
509497 }
@@ -521,17 +509,13 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
521509 if err != nil {
522510 return err
523511 }
524- // The library needs to be compiled (cache miss).
525- jobs = append (jobs , job .dependencies ... )
526- jobs = append (jobs , job )
527512 linkerDependencies = append (linkerDependencies , job )
528513 case "wasi-libc" :
529514 path := filepath .Join (root , "lib/wasi-libc/sysroot/lib/wasm32-wasi/libc.a" )
530515 if _ , err := os .Stat (path ); os .IsNotExist (err ) {
531516 return errors .New ("could not find wasi-libc, perhaps you need to run `make wasi-libc`?" )
532517 }
533518 job := dummyCompileJob (path )
534- jobs = append (jobs , job )
535519 linkerDependencies = append (linkerDependencies , job )
536520 case "" :
537521 // no library specified, so nothing to do
@@ -574,7 +558,7 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
574558
575559 // Create a linker job, which links all object files together and does some
576560 // extra stuff that can only be done after linking.
577- jobs = append ( jobs , & compileJob {
561+ linkJob := & compileJob {
578562 description : "link" ,
579563 dependencies : linkerDependencies ,
580564 run : func (job * compileJob ) error {
@@ -647,12 +631,12 @@ func Build(pkgName, outpath string, config *compileopts.Config, action func(Buil
647631
648632 return nil
649633 },
650- })
634+ }
651635
652636 // Run all jobs to compile and link the program.
653637 // Do this now (instead of after elf-to-hex and similar conversions) as it
654638 // is simpler and cannot be parallelized.
655- err = runJobs (jobs )
639+ err = runJobs (linkJob )
656640 if err != nil {
657641 return err
658642 }
0 commit comments