tool/gocross: correctly embed the git commit into gocross

Previously, the build ended up embedding an empty string, which made
the shell wrapper rebuild gocross on every invocation. This is still
reasonably fast, but fixing the bypass shaves 80% off gocross's overhead
when no rebuild is needed.

Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
David Anderson 2023-03-20 21:22:06 -07:00 committed by Dave Anderson
parent f11c270c6b
commit c9a4dbe383
1 changed files with 2 additions and 2 deletions

View File

@ -82,9 +82,9 @@ fi
# Anyway, build gocross in a stripped down universe.
gocross_path="$repo_root/gocross"
gocross_ok=0
wantver="$(git rev-parse HEAD)"
if [ -x "$gocross_path" ]; then
gotver="$($gocross_path gocross-version 2>/dev/null || echo '')"
wantver="$(git rev-parse HEAD)"
if [ "$gotver" = "$wantver" ]; then
gocross_ok=1
fi
@ -95,7 +95,7 @@ if [ "$gocross_ok" = "0" ]; then
unset GO111MODULE
unset GOROOT
export CGO_ENABLED=0
"$toolchain/bin/go" build -o "$gocross_path" -ldflags='-X tailscale.com/version/gitCommitStamp=$wantver' tailscale.com/tool/gocross
"$toolchain/bin/go" build -o "$gocross_path" -ldflags "-X tailscale.com/version.gitCommitStamp=$wantver" tailscale.com/tool/gocross
fi
) # End of the subshell execution.