Skip to content

Add -w to buildx ldflags #1212

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2025
Merged

Add -w to buildx ldflags #1212

merged 1 commit into from
Jun 5, 2025

Conversation

tianon
Copy link
Contributor

@tianon tianon commented Jun 5, 2025

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.

See also:

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: Tianon Gravi <admwiggin@gmail.com>
@thaJeztah
Copy link
Member

Is this something we can / should do for other binaries as well?

oh; recalls me that I tried to update to compat 13, which had a todo that an override could be removed, but that doesn't seem to work 😅

@thaJeztah
Copy link
Member

@tonistiigi @crazy-max PTAL

Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SGTM

but asked Tonis and Kevin to have a look

@tianon
Copy link
Contributor Author

tianon commented Jun 5, 2025

It is something you could/should do for other binaries, but I think they're all using upstream build scripts, so those changes don't happen in this repository. (For Compose in particular, this already happened back in docker/compose#10325, for example.)

@tonistiigi
Copy link
Member

but asked Tonis and Kevin to have a look

We already do this in upstream iiuc

@tianon
Copy link
Contributor Author

tianon commented Jun 5, 2025

We already do this in upstream iiuc

Yep, quoted in my OP: 😅

(IMO that should drop -s so that govulncheck can work on the binaries, but that's a separate discussion)

@thaJeztah
Copy link
Member

We already do this in upstream iiuc

I'll assume that's a "LGTM", so let me merge this one.

@thaJeztah thaJeztah merged commit 6b1c6b9 into docker:master Jun 5, 2025
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants