smaller executable for openwrt #912

Open
opened 2025-11-20 05:19:45 -05:00 by saavagebueno · 7 comments
Owner

Originally created by @JakubZukal on GitHub (May 20, 2024).

Is your feature request related to a problem? Please describe.
Hi. We are using Netbird on a Collie Router (GL-X300B) and cannot upgrade from version 0.25.3 (5.8M) to 0.27.* (9.8M) due to insufficient space on overlayfs:/overlay. Unfortunately, increasing the space might not be possible for us.

Describe the solution you'd like
Smaller executable.

Describe alternatives you've considered
I've tried to minify the executable, but it's still not enough.

dckr-build# GOARCH=mipsle GOOS=linux GOMIPS=softfloat go build -ldflags="-s -w" -o collie_netbird
dckr-build# ls -la collie_netbird
-rwxr-xr-x 1 root root 36241591 May 20 20:11 collie_netbird

dckr-build# mipsel-linux-gnu-strip collie_netbird
dckr-build# ls -la collie_netbird
-rwxr-xr-x 1 root root 36180352 May 20 20:11 collie_netbird

dckr-build# upx --best collie_netbird
-rwxr-xr-x 1 root root 9711584 May 20 20:11 collie_netbird

Additional context
Nope.

Is there a way to further shrink the binary a little bit more?

Originally created by @JakubZukal on GitHub (May 20, 2024). **Is your feature request related to a problem? Please describe.** Hi. We are using Netbird on a Collie Router (GL-X300B) and cannot upgrade from version 0.25.3 (5.8M) to 0.27.* (9.8M) due to insufficient space on overlayfs:/overlay. Unfortunately, increasing the space might not be possible for us. **Describe the solution you'd like** Smaller executable. **Describe alternatives you've considered** I've tried to minify the executable, but it's still not enough. ```sh dckr-build# GOARCH=mipsle GOOS=linux GOMIPS=softfloat go build -ldflags="-s -w" -o collie_netbird dckr-build# ls -la collie_netbird -rwxr-xr-x 1 root root 36241591 May 20 20:11 collie_netbird dckr-build# mipsel-linux-gnu-strip collie_netbird dckr-build# ls -la collie_netbird -rwxr-xr-x 1 root root 36180352 May 20 20:11 collie_netbird dckr-build# upx --best collie_netbird -rwxr-xr-x 1 root root 9711584 May 20 20:11 collie_netbird ``` **Additional context** Nope. Is there a way to further shrink the binary a little bit more?
saavagebueno added the feature-requestclient labels 2025-11-20 05:19:45 -05:00
Author
Owner

@JaSei commented on GitHub (Jun 6, 2024):

An interesting solution would be to use a different compiler for this, like tinygo. Unfortunately it doesn't work with MIPS arch.
https://github.com/tinygo-org/tinygo/issues/1075

@JaSei commented on GitHub (Jun 6, 2024): An interesting solution would be to use a different compiler for this, like tinygo. Unfortunately it doesn't work with MIPS arch. https://github.com/tinygo-org/tinygo/issues/1075
Author
Owner

@lixmal commented on GitHub (Jun 6, 2024):

Tinygo also doesn't support net/http/httptrace which is used by http2/grpc

@lixmal commented on GitHub (Jun 6, 2024): Tinygo also [doesn't support net/http/httptrace](https://tinygo.org/docs/reference/lang-support/stdlib/#nethttphttptrace) which is used by http2/grpc
Author
Owner

@mlsmaycon commented on GitHub (Jun 25, 2024):

@JakubZukal can you check if the latest version has improved with UPX? we removed some dependencies that were adding 5MB in binary size since v0.27

@mlsmaycon commented on GitHub (Jun 25, 2024): @JakubZukal can you check if the latest version has improved with UPX? we removed some dependencies that were adding 5MB in binary size since v0.27
Author
Owner

@JakubZukal commented on GitHub (Jun 25, 2024):

builder# GOARCH=mipsle GOOS=linux GOMIPS=softfloat go build -ldflags="-s -w" -o collie_netbird
builder# ls -la collie_netbird
-rwxr-xr-x 1 root root 29229239 Jun 25 08:12 collie_netbird

builder# mipsel-linux-gnu-strip collie_netbird
builder# ls -la collie_netbird
-rwxr-xr-x 1 root root 29215776 Jun 25 08:17 collie_netbird

builder# upx --best collie_netbird
builder# ls -la collie_netbird
-rwxr-xr-x 1 root root 8332280 Jun 25 08:17 collie_netbird

It is 14.2% smaller than my previous attempt. Great work! I'll try some other options to minify it a bit more, as I need it to be around 7 MB. I'll let you know ASAP.

@JakubZukal commented on GitHub (Jun 25, 2024): ```sh builder# GOARCH=mipsle GOOS=linux GOMIPS=softfloat go build -ldflags="-s -w" -o collie_netbird builder# ls -la collie_netbird -rwxr-xr-x 1 root root 29229239 Jun 25 08:12 collie_netbird builder# mipsel-linux-gnu-strip collie_netbird builder# ls -la collie_netbird -rwxr-xr-x 1 root root 29215776 Jun 25 08:17 collie_netbird builder# upx --best collie_netbird builder# ls -la collie_netbird -rwxr-xr-x 1 root root 8332280 Jun 25 08:17 collie_netbird ``` It is 14.2% smaller than my previous attempt. Great work! I'll try some other options to minify it a bit more, as I need it to be around 7 MB. I'll let you know ASAP.
Author
Owner

@mlsmaycon commented on GitHub (Jun 25, 2024):

We have some work planned around replacing gopacket with an alternative, which should also reduce a few MBs.

This will take some time as we are introducing some significant relay changes

@mlsmaycon commented on GitHub (Jun 25, 2024): We have some work planned around replacing [gopacket](https://github.com/google/gopacket) with an alternative, which should also reduce a few MBs. This will take some time as we are introducing some significant relay changes
Author
Owner

@JakubZukal commented on GitHub (Aug 13, 2024):

Hi. JFYI, I was able to significantly minify the executable. I'm currently testing it on the gl-x300b, and it seems to be running just fine.

builder# GOMIPS=softfloat GOARCH=mips GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w -X github.com/netbirdio/netbird/version.version=v0.28.7" -gcflags="all=-l" -o netbird
builder# ls -la netbird
-rwxr-xr-x 1 root root 26017975 Aug 13 15:15 netbird

builder# upx --best --lzma netbird
builder# ls -la netbird
-rwxr-xr-x 1 root root 4692292 Aug 13 15:15 netbird
@JakubZukal commented on GitHub (Aug 13, 2024): Hi. JFYI, I was able to significantly minify the executable. I'm currently testing it on the gl-x300b, and it seems to be running just fine. ``` builder# GOMIPS=softfloat GOARCH=mips GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w -X github.com/netbirdio/netbird/version.version=v0.28.7" -gcflags="all=-l" -o netbird builder# ls -la netbird -rwxr-xr-x 1 root root 26017975 Aug 13 15:15 netbird builder# upx --best --lzma netbird builder# ls -la netbird -rwxr-xr-x 1 root root 4692292 Aug 13 15:15 netbird ```
Author
Owner

@nazarewk commented on GitHub (May 14, 2025):

just noting the use case is related to https://github.com/netbirdio/netbird/issues/496

@nazarewk commented on GitHub (May 14, 2025): just noting the use case is related to https://github.com/netbirdio/netbird/issues/496
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/netbird#912