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

Reduce binary size #39

Merged
merged 1 commit into from Apr 13, 2022
Merged

Reduce binary size #39

merged 1 commit into from Apr 13, 2022

Conversation

hSATAC
Copy link
Contributor

@hSATAC hSATAC commented Apr 13, 2022

Add linker flags -s and -w to reduce binary size by removing debug and DWARF symbols

Saved around 6M before compression.

Ref: https://pkg.go.dev/cmd/link

-s
Omit the symbol table and debug information.
-w
Omit the DWARF symbol table.

Comparison

# Before
$ go build -o bin/avc -ldflags ' -X github.com/infuseai/artivc/cmd.tagVersion= -X github.com/infuseai/artivc/cmd.gitCommit=6895c74b6ca090770e0338447bf62d2c7a2bb1e3 -X github.com/infuseai/artivc/cmd.gitTreeState=clean ' main.go
$ stat -f%z bin/avc
29522322

# After
$ go build -o bin/avc -ldflags ' -X github.com/infuseai/artivc/cmd.tagVersion= -X github.com/infuseai/artivc/cmd.gitCommit=6895c74b6ca090770e0338447bf62d2c7a2bb1e3 -X github.com/infuseai/artivc/cmd.gitTreeState=dirty -s -w ' main.go
$ stat -f%z bin/avc
23132178

Signed-off-by: Ash Wu hSATAC@gmail.com

Signed-off-by: Ash Wu <hSATAC@gmail.com>
@popcornylu popcornylu merged commit 4951a77 into main Apr 13, 2022
@popcornylu popcornylu deleted the feature/reduce-binary-size branch April 18, 2022 04:58
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.

None yet

3 participants