mirror of
https://github.com/tailscale/tailscale.git
synced 2025-12-06 12:52:00 +00:00
tool/gocross: treat empty GOOS/GOARCH as native GOOS/GOARCH
Tracking down the side effect can otherwise be a pain, for example on Darwin an empty GOOS resulted in CGO being implicitly disabled. The user intended for `export GOOS=` to act like unset, and while this is a misunderstanding, the main toolchain would treat it this way. Fixes tailscale/corp#20059 Signed-off-by: James Tucker <james@tailscale.com>
This commit is contained in:
committed by
James Tucker
parent
76c30e014d
commit
87f00d76c4
@@ -275,6 +275,64 @@ GOMIPS=softfloat (was <nil>)
|
||||
GOOS=darwin (was <nil>)
|
||||
GOROOT=/goroot (was <nil>)
|
||||
GOTOOLCHAIN=local (was <nil>)
|
||||
TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
|
||||
wantArgv: []string{
|
||||
"gocross", "build",
|
||||
"-trimpath",
|
||||
"-tags=tailscale_go,omitidna,omitpemdecrypt",
|
||||
"-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",
|
||||
"./cmd/tailcontrol",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "darwin_arm64_to_darwin_arm64_empty_goos",
|
||||
argv: []string{"gocross", "build", "./cmd/tailcontrol"},
|
||||
env: map[string]string{
|
||||
"GOOS": "",
|
||||
},
|
||||
goroot: "/goroot",
|
||||
nativeGOOS: "darwin",
|
||||
nativeGOARCH: "arm64",
|
||||
|
||||
envDiff: `CC=cc (was <nil>)
|
||||
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
|
||||
CGO_ENABLED=1 (was <nil>)
|
||||
CGO_LDFLAGS= (was <nil>)
|
||||
GOARCH=arm64 (was <nil>)
|
||||
GOARM=5 (was <nil>)
|
||||
GOMIPS=softfloat (was <nil>)
|
||||
GOOS=darwin (was )
|
||||
GOROOT=/goroot (was <nil>)
|
||||
GOTOOLCHAIN=local (was <nil>)
|
||||
TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
|
||||
wantArgv: []string{
|
||||
"gocross", "build",
|
||||
"-trimpath",
|
||||
"-tags=tailscale_go,omitidna,omitpemdecrypt",
|
||||
"-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",
|
||||
"./cmd/tailcontrol",
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "darwin_arm64_to_darwin_arm64_empty_goarch",
|
||||
argv: []string{"gocross", "build", "./cmd/tailcontrol"},
|
||||
env: map[string]string{
|
||||
"GOARCH": "",
|
||||
},
|
||||
goroot: "/goroot",
|
||||
nativeGOOS: "darwin",
|
||||
nativeGOARCH: "arm64",
|
||||
|
||||
envDiff: `CC=cc (was <nil>)
|
||||
CGO_CFLAGS=-O3 -std=gnu11 (was <nil>)
|
||||
CGO_ENABLED=1 (was <nil>)
|
||||
CGO_LDFLAGS= (was <nil>)
|
||||
GOARCH=arm64 (was )
|
||||
GOARM=5 (was <nil>)
|
||||
GOMIPS=softfloat (was <nil>)
|
||||
GOOS=darwin (was <nil>)
|
||||
GOROOT=/goroot (was <nil>)
|
||||
GOTOOLCHAIN=local (was <nil>)
|
||||
TS_LINK_FAIL_REFLECT=0 (was <nil>)`,
|
||||
wantArgv: []string{
|
||||
"gocross", "build",
|
||||
|
||||
Reference in New Issue
Block a user