Skip to content

Commit 35e8393

Browse files
authored
Reusing workDir to store nogo facts and export data (bazel-contrib#2648)
1 parent 144a8e3 commit 35e8393

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

go/tools/builders/compilepkg.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,9 @@ func compileArchive(
318318
}
319319
defer os.Remove(importcfgPath)
320320

321-
// tempdir to store nogo facts and pkgdef for packaging later
322-
xTempDir, err := ioutil.TempDir(filepath.Dir(outXPath), "x_files")
323-
if err != nil {
324-
return err
325-
}
326-
defer os.RemoveAll(xTempDir)
327321
// Run nogo concurrently.
328322
var nogoChan chan error
329-
outFactsPath := filepath.Join(xTempDir, nogoFact)
323+
outFactsPath := filepath.Join(workDir, nogoFact)
330324
if nogoPath != "" {
331325
ctx, cancel := context.WithCancel(context.Background())
332326
nogoChan = make(chan error)
@@ -415,10 +409,10 @@ func compileArchive(
415409
// copy the nogo facts into the .x file. Unfortunately, when building a plugin,
416410
// the linker needs export data in the .a file. To work around this, we copy
417411
// the export data into the .x file ourselves.
418-
if err = extractFileFromArchive(outPath, xTempDir, pkgDef); err != nil {
412+
if err = extractFileFromArchive(outPath, workDir, pkgDef); err != nil {
419413
return err
420414
}
421-
pkgDefPath := filepath.Join(xTempDir, pkgDef)
415+
pkgDefPath := filepath.Join(workDir, pkgDef)
422416
if nogoStatus == nogoSucceeded {
423417
return appendFiles(goenv, outXPath, []string{pkgDefPath, outFactsPath})
424418
}

0 commit comments

Comments
 (0)