From c9a4dbe38359b6c5478c28a4ea667857b3173d36 Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 20 Mar 2023 21:22:06 -0700 Subject: [PATCH] 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 --- tool/gocross/gocross-wrapper.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tool/gocross/gocross-wrapper.sh b/tool/gocross/gocross-wrapper.sh index 2cfca0b2b..5372b2b1f 100755 --- a/tool/gocross/gocross-wrapper.sh +++ b/tool/gocross/gocross-wrapper.sh @@ -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.