diff mbox series

[OpenWrt-Devel] libevent2: Add -Wl, --gc-sections to reduce size a little.

Message ID 20190219210157.2177-1-rosenp@gmail.com
State Superseded
Headers show
Series [OpenWrt-Devel] libevent2: Add -Wl, --gc-sections to reduce size a little. | expand

Commit Message

Rosen Penev Feb. 19, 2019, 9:01 p.m. UTC
Saves ~4KB. Also reorganized configure arguments to improve compilation
speed.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 package/libs/libevent2/Makefile | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Petr Štetiar Feb. 20, 2019, 6:19 a.m. UTC | #1
Rosen Penev <rosenp@gmail.com> [2019-02-19 13:01:57]:

> -TARGET_CFLAGS += $(FPIC)

Why did you removed this? I can see, that you've added --with-pic configure
option, but I'm wondering if it's going to provide same result on all
platforms.

> +TARGET_LDFLAGS += -Wl,--gc-sections

I'm not sure whether this is a good idea on library, or is it?

> +	--disable-libevent-regress \

I'm wondering how this might reduce the binary size. It might be enabled by
default for some reason, so I'm not sure if disabling regression tests for
saving some build time (BTW how much?) is a good idea.

You've forget to add on which platforms you've build and run tested this
change, and mainly on which platform you're seeing this 4KB size reduction.

-- ynezz
Rosen Penev Feb. 20, 2019, 6:45 a.m. UTC | #2
On Tue, Feb 19, 2019 at 10:19 PM Petr Štetiar <ynezz@true.cz> wrote:
>
> Rosen Penev <rosenp@gmail.com> [2019-02-19 13:01:57]:
>
> > -TARGET_CFLAGS += $(FPIC)
>
> Why did you removed this? I can see, that you've added --with-pic configure
> option, but I'm wondering if it's going to provide same result on all
> platforms.
Don't see why not. it adds fPIC and dPIC
>
> > +TARGET_LDFLAGS += -Wl,--gc-sections
>
> I'm not sure whether this is a good idea on library, or is it?
Doesn't have any negative effects on other packages from what I've seen.
>
> > +     --disable-libevent-regress \
>
> I'm wondering how this might reduce the binary size. It might be enabled by
> default for some reason, so I'm not sure if disabling regression tests for
> saving some build time (BTW how much?) is a good idea.
Seems to also be done elsewhere.
>
> You've forget to add on which platforms you've build and run tested this
> change, and mainly on which platform you're seeing this 4KB size reduction.
ramips. I doubt it's much different elsewhere.
>
> -- ynezz
Petr Štetiar Feb. 20, 2019, 8:45 a.m. UTC | #3
Rosen Penev <rosenp@gmail.com> [2019-02-19 22:45:37]:

> On Tue, Feb 19, 2019 at 10:19 PM Petr Štetiar <ynezz@true.cz> wrote:
> >
> > Rosen Penev <rosenp@gmail.com> [2019-02-19 13:01:57]:
> >
> > > -TARGET_CFLAGS += $(FPIC)
> >
> > Why did you removed this? I can see, that you've added --with-pic configure
> > option, but I'm wondering if it's going to provide same result on all
> > platforms.
>
> Don't see why not. it adds fPIC and dPIC

Just that there's following in rules.mk:

 ifeq ($(ARCH),powerpc)
   FPIC:=-fPIC
 else
   FPIC:=-fpic
 endif

so let's hope it's handled properly in autofoo stuff.

> > > +     --disable-libevent-regress \
> >
> > I'm wondering how this might reduce the binary size. It might be enabled by
> > default for some reason, so I'm not sure if disabling regression tests for
> > saving some build time (BTW how much?) is a good idea.
>
> Seems to also be done elsewhere.

Ok, what does it mean elsewhere? Why do you think, that it's a good idea to
disable the regression tests which might be actually a poor man's Q&A during
toolchain/binutils bumps.  Isn't it better to catch any potential issues
during build phase, then later on the device?

> > You've forget to add on which platforms you've build and run tested this
> > change, and mainly on which platform you're seeing this 4KB size reduction.
>
> ramips. I doubt it's much different elsewhere.

I would expect, that you've at least tried to build all the packages which
depends on the libevent2, and ideally tried to run them as well. The list
isn't that small:

package/network/services/lldpd admin/zabbix lang/php7-pecl-http
lang/php7-pecl-libevent libs/libevhtp net/addrwatch net/memcached
net/nfs-kernel-server net/ntpd net/ratechecker net/redsocks net/seafile-ccnet
net/seafile-server net/sstp-client net/tor net/transmission sound/forked-daapd
utils/tmux

-- ynezz
Rosen Penev Feb. 20, 2019, 8:48 a.m. UTC | #4
On Wed, Feb 20, 2019 at 12:45 AM Petr Štetiar <ynezz@true.cz> wrote:
>
> Rosen Penev <rosenp@gmail.com> [2019-02-19 22:45:37]:
>
> > On Tue, Feb 19, 2019 at 10:19 PM Petr Štetiar <ynezz@true.cz> wrote:
> > >
> > > Rosen Penev <rosenp@gmail.com> [2019-02-19 13:01:57]:
> > >
> > > > -TARGET_CFLAGS += $(FPIC)
> > >
> > > Why did you removed this? I can see, that you've added --with-pic configure
> > > option, but I'm wondering if it's going to provide same result on all
> > > platforms.
> >
> > Don't see why not. it adds fPIC and dPIC
>
> Just that there's following in rules.mk:
>
>  ifeq ($(ARCH),powerpc)
>    FPIC:=-fPIC
>  else
>    FPIC:=-fpic
>  endif
>
> so let's hope it's handled properly in autofoo stuff.
>
> > > > +     --disable-libevent-regress \
> > >
> > > I'm wondering how this might reduce the binary size. It might be enabled by
> > > default for some reason, so I'm not sure if disabling regression tests for
> > > saving some build time (BTW how much?) is a good idea.
> >
> > Seems to also be done elsewhere.
>
> Ok, what does it mean elsewhere? Why do you think, that it's a good idea to
> disable the regression tests which might be actually a poor man's Q&A during
> toolchain/binutils bumps.  Isn't it better to catch any potential issues
> during build phase, then later on the device?
Usually they get disabled as they cause issues when cross compiling.
Not here though.
>
> > > You've forget to add on which platforms you've build and run tested this
> > > change, and mainly on which platform you're seeing this 4KB size reduction.
> >
> > ramips. I doubt it's much different elsewhere.
>
> I would expect, that you've at least tried to build all the packages which
> depends on the libevent2, and ideally tried to run them as well. The list
> isn't that small:
I've only tested transmission. It works fine.
>
> package/network/services/lldpd admin/zabbix lang/php7-pecl-http
> lang/php7-pecl-libevent libs/libevhtp net/addrwatch net/memcached
> net/nfs-kernel-server net/ntpd net/ratechecker net/redsocks net/seafile-ccnet
> net/seafile-server net/sstp-client net/tor net/transmission sound/forked-daapd
> utils/tmux
>
> -- ynezz
diff mbox series

Patch

diff --git a/package/libs/libevent2/Makefile b/package/libs/libevent2/Makefile
index f7223a01d6..c264fed0c4 100644
--- a/package/libs/libevent2/Makefile
+++ b/package/libs/libevent2/Makefile
@@ -9,7 +9,7 @@  include $(TOPDIR)/rules.mk
 
 PKG_NAME:=libevent2
 PKG_VERSION:=2.1.8
-PKG_RELEASE:=3
+PKG_RELEASE:=4
 
 PKG_SOURCE:=libevent-$(PKG_VERSION)-stable.tar.gz
 PKG_SOURCE_URL:=https://github.com/libevent/libevent/releases/download/release-$(PKG_VERSION)-stable
@@ -108,15 +108,16 @@  define Package/libevent2-pthreads/description
 	threading & locking.
 endef
 
-TARGET_CFLAGS += $(FPIC)
+TARGET_LDFLAGS += -Wl,--gc-sections
 
 CONFIGURE_ARGS += \
 	--enable-shared \
 	--enable-static \
-	--disable-debug-mode
-
-MAKE_FLAGS += \
-	CFLAGS="$(TARGET_CFLAGS)"
+	--disable-debug-mode \
+	--disable-gcc-warnings \
+	--disable-libevent-regress \
+	--disable-samples \
+	--with-pic
 
 define Build/InstallDev
 	$(INSTALL_DIR) $(1)/usr/include