Skip to content

Commit

Permalink
Use output dir for empty packages to be hermetic
Browse files Browse the repository at this point in the history
  • Loading branch information
joeljeske committed Mar 30, 2022
1 parent 1691291 commit 50fb24b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion go/tools/builders/compilepkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,12 @@ func compileArchive(
defer cleanup()

if len(srcs.goSrcs) == 0 {
emptyPath := filepath.Join(workDir, "_empty.go")
// We need to run the compiler to create a valid archive, even if there's
// nothing in it. GoPack will complain if we try to add assembly or cgo
// objects.
// _empty.go needs to be in a deterministic location (not tmpdir) in order
// to ensure deterministic output
emptyPath := filepath.Join(filepath.Dir(outPath), "_empty.go")
if err := ioutil.WriteFile(emptyPath, []byte("package empty\n"), 0666); err != nil {
return err
}
Expand Down

0 comments on commit 50fb24b

Please sign in to comment.