Skip to content

netbird: strip debug symbols to reduce size#28638

Open
ShayBox wants to merge 1 commit intoopenwrt:masterfrom
Shays-Forks:master
Open

netbird: strip debug symbols to reduce size#28638
ShayBox wants to merge 1 commit intoopenwrt:masterfrom
Shays-Forks:master

Conversation

@ShayBox
Copy link

@ShayBox ShayBox commented Feb 26, 2026

📦 Package Details

Maintainer: @wehagy

Description: Changes the build flags to strip debug symbols, to reduce the binary size so that the package can be installed on consumer routers with limited flash storage.


🧪 Run Testing Details

  • OpenWrt Version: 25.12.0-rc5
  • OpenWrt Target/Subtarget: ath79/generic
  • OpenWrt Device: TP-Link Archer C7 v5

✅ Formalities

  • I have reviewed the CONTRIBUTING.md file for detailed contributing guidelines.

Signed-off-by: ShayBox <shaybox@shaybox.com>
@LGA1150
Copy link
Contributor

LGA1150 commented Feb 26, 2026

I don't think you need to add those manually:

PKG_GO_LDFLAGS?= \
-buildid '$(SOURCE_DATE_EPOCH)' \
-linkmode external \
-extldflags '$(patsubst -z%,-Wl$(comma)-z$(comma)%,$(TARGET_LDFLAGS))' \
$(if $(CONFIG_NO_STRIP)$(CONFIG_DEBUG),,-s -w)
PKG_GO_INSTALL_ARGS?= \
-buildvcs=false \
-trimpath \
-ldflags "all=$(PKG_GO_LDFLAGS)" \
$(if $(PKG_GO_GCFLAGS),-gcflags "all=$(PKG_GO_GCFLAGS)") \
$(if $(PKG_GO_ASMFLAGS),-asmflags "all=$(PKG_GO_ASMFLAGS)") \
$(if $(filter $(GO_PKG_ENABLE_PIE),1),-buildmode pie)

@egc112
Copy link
Contributor

egc112 commented Feb 26, 2026

NetBird is huge indeed so any shrinking can be helpful
Have you checked that this actually works as I think some optimisations like -s -w are already standard.
We might need the help of the golang expert @GeorgeSapkin


GO_PKG:=github.com/netbirdio/netbird
GO_PKG_BUILD_PKG:=$(GO_PKG)/client
GO_PKG_LDFLAGS:=-s -w
Copy link
Member

Choose a reason for hiding this comment

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

This is roughly the same as stripping.

GO_PKG_BUILD_PKG:=$(GO_PKG)/client
GO_PKG_LDFLAGS:=-s -w
GO_PKG_LDFLAGS_X:=$(GO_PKG)/version.version=$(PKG_VERSION)
GO_PARAMS_EXTRA:=-trimpath
Copy link
Member

Choose a reason for hiding this comment

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

This is set already in the default vars. Is this package not using them?

$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin $(1)/etc/init.d
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/client $(1)/usr/bin/netbird
strip --strip-all $(1)/usr/bin/netbird
Copy link
Member

Choose a reason for hiding this comment

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

The toolchain already strips binaries by default. Is this somehow not the case for Netbird?

@wehagy
Copy link
Member

wehagy commented Feb 26, 2026

Like @GeorgeSapkin and @LGA1150 mentioned, this option is already the default and netbird doesn't change any of these options.

@ShayBox, can you build a package and an image with and without your patch and show the difference?

@wehagy wehagy self-assigned this Feb 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants