[VAULT-39942] tools: always statically link and strip binaries (#9909) (#9918)

Occasionally it seems that the tools will get built and linked against
the platform glibc. We definitely do not want that.

Now we always disable CGO when building tools. While doing this I
realized that we could also strip debug symbols and reduce the size of
the tools significantly, so that is included as well.

Signed-off-by: Ryan Cragun <me@ryan.ec>
Co-authored-by: Ryan Cragun <me@ryan.ec>
This commit is contained in:
Vault Automation 2025-10-07 16:14:11 -04:00 committed by GitHub
parent 0671becbd3
commit f199191f88
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,7 +11,11 @@ repo_root() {
# Install an external Go tool.
go_install() {
if go install "$1"; then
local tags=""
if [ "$(go env GOOS)" == "darwin" ]; then
tags="netcgo"
fi
if eval CGO_ENABLED=0 go install "-tags=${tags}" \"-ldflags=-w -s\" "$1"; then
echo "--> $1"
else
echo "--> $1"