tool/gocross: remove trimpath from test builds

trimpath can be inconvenient for IDEs and LSPs that do not always
correctly handle module relative paths, and can also contribute to
caching bugs taking effect. We rarely have a real need for trimpath of
test produced binaries, so avoiding it should be a net win.

Updates 
Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
James Tucker
2024-09-11 11:28:33 -07:00
committed by James Tucker
parent c0a1ed86cb
commit 0d76d7d21c
2 changed files with 5 additions and 2 deletions

@@ -35,7 +35,7 @@ func autoflagsForTest(argv []string, env *Environment, goroot, nativeGOOS, nativ
cc = "cc" cc = "cc"
targetOS = cmp.Or(env.Get("GOOS", ""), nativeGOOS) targetOS = cmp.Or(env.Get("GOOS", ""), nativeGOOS)
targetArch = cmp.Or(env.Get("GOARCH", ""), nativeGOARCH) targetArch = cmp.Or(env.Get("GOARCH", ""), nativeGOARCH)
buildFlags = []string{"-trimpath"} buildFlags = []string{}
cgoCflags = []string{"-O3", "-std=gnu11", "-g"} cgoCflags = []string{"-O3", "-std=gnu11", "-g"}
cgoLdflags []string cgoLdflags []string
ldflags []string ldflags []string
@@ -47,6 +47,10 @@ func autoflagsForTest(argv []string, env *Environment, goroot, nativeGOOS, nativ
subcommand = argv[1] subcommand = argv[1]
} }
if subcommand != "test" {
buildFlags = append(buildFlags, "-trimpath")
}
switch subcommand { switch subcommand {
case "build", "env", "install", "run", "test", "list": case "build", "env", "install", "run", "test", "list":
default: default:

@@ -163,7 +163,6 @@ GOTOOLCHAIN=local (was <nil>)
TS_LINK_FAIL_REFLECT=0 (was <nil>)`, TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
wantArgv: []string{ wantArgv: []string{
"gocross", "test", "gocross", "test",
"-trimpath",
"-tags=tailscale_go,osusergo,netgo", "-tags=tailscale_go,osusergo,netgo",
"-ldflags", "-X tailscale.com/version.longStamp=1.2.3-long -X tailscale.com/version.shortStamp=1.2.3 -X tailscale.com/version.gitCommitStamp=abcd -X tailscale.com/version.extraGitCommitStamp=defg '-extldflags=-static'", "-ldflags", "-X tailscale.com/version.longStamp=1.2.3-long -X tailscale.com/version.shortStamp=1.2.3 -X tailscale.com/version.gitCommitStamp=abcd -X tailscale.com/version.extraGitCommitStamp=defg '-extldflags=-static'",
"-race", "-race",