Skip to content

Commit 956c520

Browse files
committed
pkg(buildx): add -w to ldflags
This disables DWARF generation, which dramatically decreases the size of the binary. Notably, this does *not* include `-s` which disables the symbol table, as doing so would *also* make it so that `govulncheck` cannot be run on the resulting binary with meaningful results. Before is ~90M and after is ~72M. If we add `-s` as well, that ~72M drops to ~63M, but we also lose `govulncheck` so again, IMO, that's not worth doing. Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
1 parent 6e5bcd5 commit 956c520

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

pkg/buildx/deb/rules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ override_dh_auto_build:
1010
go build \
1111
-mod=vendor \
1212
-trimpath \
13-
-ldflags "-X github.com/docker/buildx/version.Version=$(VERSION) -X github.com/docker/buildx/version.Revision=$(REVISION) -X github.com/docker/buildx/version.Package=github.com/docker/buildx" \
13+
-ldflags "-w -X github.com/docker/buildx/version.Version=$(VERSION) -X github.com/docker/buildx/version.Revision=$(REVISION) -X github.com/docker/buildx/version.Package=github.com/docker/buildx" \
1414
-o "/usr/libexec/docker/cli-plugins/docker-buildx" \
1515
./cmd/buildx
1616

pkg/buildx/rpm/docker-buildx-plugin.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pushd ${RPM_BUILD_DIR}/src/buildx
2727
go build \
2828
-mod=vendor \
2929
-trimpath \
30-
-ldflags="-X github.com/docker/buildx/version.Version=%{_origversion} -X github.com/docker/buildx/version.Revision=%{_commit} -X github.com/docker/buildx/version.Package=github.com/docker/buildx" \
30+
-ldflags="-w -X github.com/docker/buildx/version.Version=%{_origversion} -X github.com/docker/buildx/version.Revision=%{_commit} -X github.com/docker/buildx/version.Package=github.com/docker/buildx" \
3131
-o "bin/docker-buildx" \
3232
./cmd/buildx
3333
popd

0 commit comments

Comments
 (0)