mirror of
https://github.com/golang/go
synced 2024-11-26 01:17:57 -07:00
cmd/go: use overlaid path contents in build cache
When caching actions, use the overlaid file contents, because those are the ones actually used to produce the outputs. For #39958 Change-Id: Ia1f85b2fcf1f26e3b5be82f4d35c2726b134a36b Reviewed-on: https://go-review.googlesource.com/c/go/+/266720 Trust: Michael Matloob <matloob@golang.org> Run-TryBot: Michael Matloob <matloob@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
f016172dbe
commit
30ba798093
@ -15,6 +15,7 @@ import (
|
||||
"cmd/go/internal/base"
|
||||
"cmd/go/internal/cache"
|
||||
"cmd/go/internal/cfg"
|
||||
"cmd/go/internal/fsys"
|
||||
"cmd/go/internal/str"
|
||||
"cmd/internal/buildid"
|
||||
)
|
||||
@ -375,6 +376,7 @@ func (b *Builder) buildID(file string) string {
|
||||
|
||||
// fileHash returns the content hash of the named file.
|
||||
func (b *Builder) fileHash(file string) string {
|
||||
file, _ = fsys.OverlayPath(file)
|
||||
sum, err := cache.FileHash(file)
|
||||
if err != nil {
|
||||
return ""
|
||||
|
32
src/cmd/go/testdata/script/build_overlay.txt
vendored
32
src/cmd/go/testdata/script/build_overlay.txt
vendored
@ -47,6 +47,14 @@ go build -overlay overlay.json -o main_call_asm$GOEXE ./call_asm
|
||||
exec ./main_call_asm$GOEXE
|
||||
! stdout .
|
||||
|
||||
# Change the contents of a file in the overlay and ensure that makes the target stale
|
||||
go install -overlay overlay.json ./test_cache
|
||||
go list -overlay overlay.json -f '{{.Stale}}' ./test_cache
|
||||
stdout '^false$'
|
||||
cp overlay/test_cache_different.go overlay/test_cache.go
|
||||
go list -overlay overlay.json -f '{{.Stale}}' ./test_cache
|
||||
stdout '^true$'
|
||||
|
||||
go list -compiled -overlay overlay.json -f '{{range .CompiledGoFiles}}{{. | printf "%s\n"}}{{end}}' ./cgo_hello_replace
|
||||
cp stdout compiled_cgo_sources.txt
|
||||
go run ../print_line_comments.go compiled_cgo_sources.txt
|
||||
@ -87,6 +95,13 @@ go build -compiler=gccgo -overlay overlay.json -o main_call_asm_gccgo$GOEXE ./ca
|
||||
exec ./main_call_asm_gccgo$GOEXE
|
||||
! stdout .
|
||||
|
||||
go install -gccgo -overlay overlay.json ./test_cache
|
||||
go list -gccgo -overlay overlay.json -f '{{.Stale}}' ./test_cache
|
||||
stdout '^false$'
|
||||
cp overlay/test_cache_different.go overlay/test_cache.go
|
||||
go list -gccgo -overlay overlay.json -f '{{.Stale}}' ./test_cache
|
||||
stdout '^true$'
|
||||
|
||||
-- m/go.mod --
|
||||
// TODO(matloob): how do overlays work with go.mod (especially if mod=readonly)
|
||||
module m
|
||||
@ -114,6 +129,7 @@ the actual code is in the overlay
|
||||
"printpath/main.go": "overlay/printpath.go",
|
||||
"printpath/other.go": "overlay2/printpath2.go",
|
||||
"call_asm/asm.s": "overlay/asm_file.s",
|
||||
"test_cache/main.go": "overlay/test_cache.go",
|
||||
"cgo_hello_replace/cgo_header.h": "overlay/cgo_head.h",
|
||||
"cgo_hello_replace/hello.c": "overlay/hello.c",
|
||||
"cgo_hello_quote/cgo_hello.go": "overlay/cgo_hello_quote.go",
|
||||
@ -230,6 +246,22 @@ void say_hello() { puts("hello cgo\n"); fflush(stdout); }
|
||||
TEXT ·foo(SB),0,$0
|
||||
RET
|
||||
|
||||
-- m/overlay/test_cache.go --
|
||||
package foo
|
||||
|
||||
import "fmt"
|
||||
|
||||
func bar() {
|
||||
fmt.Println("something")
|
||||
}
|
||||
-- m/overlay/test_cache_different.go --
|
||||
package foo
|
||||
|
||||
import "fmt"
|
||||
|
||||
func bar() {
|
||||
fmt.Println("different")
|
||||
}
|
||||
-- m/cgo_hello_quote/hello.c --
|
||||
#include <stdio.h>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user