On Mon, May 02, 2022 at 02:46:27PM +0600, NRK wrote: > Hi, > > Was wondering why most suckless program doesn't seem to strip the > installed binary. strip (1p) is specified by POSIX so it should be > portable. > > I noticed the binary size dropping a fair bit after stripping; the > following result is with vanilla/upstream Makefile and CFLAGS etc. > > dwm 60K -> 50K > dmenu 42K -> 35K > st 100K -> 87K > > Attached patches to strip the binary on installation for dwm, dmenu and > st. > > - NRK
> From c3df2f8f35e2f223505eb1091ed079b20ab8784e Mon Sep 17 00:00:00 2001 > From: NRK <n...@disroot.org> > Date: Sun, 13 Mar 2022 21:40:11 +0600 > Subject: [PATCH] strip the installed binary > > --- > Makefile | 1 + > config.mk | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/Makefile b/Makefile > index 77bcbc0..b5acd11 100644 > --- a/Makefile > +++ b/Makefile > @@ -40,6 +40,7 @@ install: all > mkdir -p ${DESTDIR}${PREFIX}/bin > cp -f dwm ${DESTDIR}${PREFIX}/bin > chmod 755 ${DESTDIR}${PREFIX}/bin/dwm > + ${STRIP} ${DESTDIR}${PREFIX}/bin/dwm > mkdir -p ${DESTDIR}${MANPREFIX}/man1 > sed "s/VERSION/${VERSION}/g" < dwm.1 > ${DESTDIR}${MANPREFIX}/man1/dwm.1 > chmod 644 ${DESTDIR}${MANPREFIX}/man1/dwm.1 > diff --git a/config.mk b/config.mk > index b6eb7e0..6e3c725 100644 > --- a/config.mk > +++ b/config.mk > @@ -36,3 +36,4 @@ LDFLAGS = ${LIBS} > > # compiler and linker > CC = cc > +STRIP = strip > -- > 2.35.1 > > From f6e51ed0a6b287f183373cd21032b90c035152e4 Mon Sep 17 00:00:00 2001 > From: NRK <n...@disroot.org> > Date: Mon, 14 Mar 2022 18:40:47 +0600 > Subject: [PATCH] strip the installed binary > > --- > Makefile | 1 + > config.mk | 1 + > 2 files changed, 2 insertions(+) > > diff --git a/Makefile b/Makefile > index 470ac86..bbfe6d2 100644 > --- a/Makefile > +++ b/Makefile > @@ -44,6 +44,7 @@ install: st > mkdir -p $(DESTDIR)$(PREFIX)/bin > cp -f st $(DESTDIR)$(PREFIX)/bin > chmod 755 $(DESTDIR)$(PREFIX)/bin/st > + $(STRIP) $(DESTDIR)$(PREFIX)/bin/st > mkdir -p $(DESTDIR)$(MANPREFIX)/man1 > sed "s/VERSION/$(VERSION)/g" < st.1 > $(DESTDIR)$(MANPREFIX)/man1/st.1 > chmod 644 $(DESTDIR)$(MANPREFIX)/man1/st.1 > diff --git a/config.mk b/config.mk > index 4c4c5d5..a38f120 100644 > --- a/config.mk > +++ b/config.mk > @@ -33,3 +33,4 @@ STLDFLAGS = $(LIBS) $(LDFLAGS) > > # compiler and linker > # CC = c99 > +STRIP = strip > -- > 2.35.1 > > From fc982f669e2d436226467a928e02be8eb507bfab Mon Sep 17 00:00:00 2001 > From: NRK <n...@disroot.org> > Date: Sun, 13 Mar 2022 23:14:33 +0600 > Subject: [PATCH] strip the installed binary > > --- > Makefile | 2 ++ > config.mk | 1 + > 2 files changed, 3 insertions(+) > > diff --git a/Makefile b/Makefile > index a03a95c..7d21307 100644 > --- a/Makefile > +++ b/Makefile > @@ -44,9 +44,11 @@ install: all > mkdir -p $(DESTDIR)$(PREFIX)/bin > cp -f dmenu dmenu_path dmenu_run stest $(DESTDIR)$(PREFIX)/bin > chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu > + $(STRIP) $(DESTDIR)$(PREFIX)/bin/dmenu > chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_path > chmod 755 $(DESTDIR)$(PREFIX)/bin/dmenu_run > chmod 755 $(DESTDIR)$(PREFIX)/bin/stest > + $(STRIP) $(DESTDIR)$(PREFIX)/bin/stest > mkdir -p $(DESTDIR)$(MANPREFIX)/man1 > sed "s/VERSION/$(VERSION)/g" < dmenu.1 > > $(DESTDIR)$(MANPREFIX)/man1/dmenu.1 > sed "s/VERSION/$(VERSION)/g" < stest.1 > > $(DESTDIR)$(MANPREFIX)/man1/stest.1 > diff --git a/config.mk b/config.mk > index 0df3fc8..508327e 100644 > --- a/config.mk > +++ b/config.mk > @@ -29,3 +29,4 @@ LDFLAGS = $(LIBS) > > # compiler and linker > CC = cc > +STRIP = strip > -- > 2.35.1 > Hi NRK, I don't like this. I'd rather have it so the Makefile respects the system or package system CFLAGS and LDFLAGS by default. Then someone can do: make CFLAGS="-Os" LDFLAGS="-s" etc. LDFLAGS="-s" is practically the same as calling strip and stripping it. It is up to the distro package/ports maintainer to strip symbols (or not). This can be an additional packaging step. As a off-topic side-note I think we removing config.mk and just having the Makefile is simpler too. -- Kind regards, Hiltjo