-
Notifications
You must be signed in to change notification settings - Fork 17.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[release-branch.go1.13] cmd/go: don't include package dir in cache ke…
…y when -trimpath is set The '-trimpath' flag tells 'go build' to trim any paths from the output files that are tied to the current workspace or toolchain. When this flag is set, we do not need to include the package directory in the text hashed to construct the action ID for each package. Updates #33772 Fixes #34326 Change-Id: I20b902d2f58019709b15864ca79aa0d9255ae707 Reviewed-on: https://go-review.googlesource.com/c/go/+/195318 Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> (cherry picked from commit aa680c0) Reviewed-on: https://go-review.googlesource.com/c/go/+/198259 Run-TryBot: Bryan C. Mills <[email protected]> Reviewed-by: Jay Conrod <[email protected]>
- Loading branch information
Jay Conrod
authored and
Bryan C. Mills
committed
Oct 1, 2019
1 parent
0c07603
commit 8c8a881
Showing
3 changed files
with
46 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,44 @@ | ||
[short] skip | ||
|
||
env -r GOROOT_REGEXP=$GOROOT | ||
env -r WORK_REGEXP=$WORK | ||
env -r WORK_REGEXP='$WORK' # don't expand $WORK; grep replaces $WORK in text before matching. | ||
env GOROOT GOROOT_REGEXP WORK WORK_REGEXP | ||
|
||
# A binary built without -trimpath should contain the current workspace | ||
# and GOROOT for debugging and stack traces. | ||
cd a | ||
go build -o hello.exe hello.go | ||
grep -q $WORK_REGEXP hello.exe | ||
grep -q $GOROOT_REGEXP hello.exe | ||
|
||
# A binary built with -trimpath should not contain the current workspace | ||
# or GOROOT. | ||
go build -trimpath -o hello.exe hello.go | ||
! grep -q $GOROOT_REGEXP hello.exe | ||
! grep -q $WORK_REGEXP hello.exe | ||
cd .. | ||
|
||
# A binary from an external module built with -trimpath should not contain | ||
# the current workspace or GOROOT. | ||
env GO111MODULE=on | ||
go build -trimpath -o fortune.exe rsc.io/fortune | ||
! grep -q $GOROOT_REGEXP fortune.exe | ||
! grep -q $WORK_REGEXP fortune.exe | ||
|
||
-- hello.go -- | ||
# Two binaries built from identical packages in different directories | ||
# should be identical. | ||
mkdir b | ||
cp a/go.mod a/hello.go b | ||
cd a | ||
go build -trimpath -o ../a.exe . | ||
cd ../b | ||
go build -trimpath -o ../b.exe . | ||
cd .. | ||
cmp -q a.exe b.exe | ||
|
||
-- a/hello.go -- | ||
package main | ||
func main() { println("hello") } | ||
|
||
-- go.mod -- | ||
-- a/go.mod -- | ||
module m |