Skip to content
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

build: reduce binary size by adding -s -w to ldflags #716

Merged
merged 4 commits into from
Dec 18, 2024

Conversation

chenrui333
Copy link
Contributor

@chenrui333 chenrui333 commented Dec 17, 2024

Add -s (omit symbol table and debug info) and -w (omit DWARF debug info) to linker flags to minimize the size of the generated binaries.

## before

$ ls -alh /opt/homebrew/Cellar/malcontent/1.6.0/bin/mal
-r-xr-xr-x  1 rui  wheel    37M Dec 17 15:44 /opt/homebrew/Cellar/malcontent/1.6.0/bin/mal

## after

$ ls -alh /opt/homebrew/Cellar/malcontent/1.6.0/bin/mal
-r-xr-xr-x  1 rui  wheel    32M Dec 17 15:45 /opt/homebrew/Cellar/malcontent/1.6.0/bin/mal

relates to Homebrew/homebrew-core#201530

Add `-s` (omit symbol table and debug info) and `-w` (omit DWARF debug info) to linker flags to minimize the size of the generated binaries.

Signed-off-by: Rui Chen <rui@chenrui.dev>
@egibs egibs enabled auto-merge (squash) December 18, 2024 00:28
@egibs
Copy link
Member

egibs commented Dec 18, 2024

Thanks!

@egibs egibs merged commit 0937ef5 into chainguard-dev:main Dec 18, 2024
8 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.

2 participants