@@ -78,17 +78,18 @@ type BuildResult struct {
7878// key, avoiding the need for recompiling all dependencies when only the
7979// implementation of an imported package changes.
8080type packageAction struct {
81- ImportPath string
82- CompilerBuildID string
83- TinyGoVersion string
84- LLVMVersion string
85- Config * compiler.Config
86- CFlags []string
87- FileHashes map [string ]string // hash of every file that's part of the package
88- EmbeddedFiles map [string ]string // hash of all the //go:embed files in the package
89- Imports map [string ]string // map from imported package to action ID hash
90- OptLevel string // LLVM optimization level (O0, O1, O2, Os, Oz)
91- UndefinedGlobals []string // globals that are left as external globals (no initializer)
81+ ImportPath string
82+ CompilerBuildID string
83+ TinyGoVersion string
84+ LLVMVersion string
85+ CCompilerIdentity string
86+ Config * compiler.Config
87+ CFlags []string
88+ FileHashes map [string ]string // hash of every file that's part of the package
89+ EmbeddedFiles map [string ]string // hash of all the //go:embed files in the package
90+ Imports map [string ]string // map from imported package to action ID hash
91+ OptLevel string // LLVM optimization level (O0, O1, O2, Os, Oz)
92+ UndefinedGlobals []string // globals that are left as external globals (no initializer)
9293}
9394
9495// Build performs a single package to executable Go build. It takes in a package
@@ -344,6 +345,13 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
344345 OptLevel : optLevel ,
345346 UndefinedGlobals : undefinedGlobals ,
346347 }
348+ if len (pkg .CGoHeaders ) != 0 {
349+ compilerID , err := clangCompilerIdentity ()
350+ if err != nil {
351+ return err
352+ }
353+ actionID .CCompilerIdentity = compilerID
354+ }
347355 for filePath , hash := range pkg .FileHashes {
348356 actionID .FileHashes [filePath ] = hex .EncodeToString (hash )
349357 }
@@ -393,9 +401,6 @@ func Build(pkgName, outpath, tmpdir string, config *compileopts.Config) (BuildRe
393401 }
394402
395403 // Load bitcode of CGo headers and join the modules together.
396- // This may seem vulnerable to cache problems, but this is not
397- // the case: the Go code that was just compiled already tracks
398- // all C files that are read and hashes them.
399404 // These headers could be compiled in parallel but the benefit
400405 // is so small that it's probably not worth parallelizing.
401406 // Packages are compiled independently anyway.
0 commit comments