Re: [OpenWrt-Devel] [PATCH 1/4] dnsmasq: Activate LTO

2019-11-03 Thread Rosen Penev
On Sun, Nov 3, 2019 at 11:23 AM Jonas Gorski  wrote:
>
> On Fri, 1 Nov 2019 at 21:55, Hauke Mehrtens  wrote:
> >
> > This decreases the binary size when PIE ASLR is activated by 8% on MIPS BE.
> >
> > old:
> > 202,020 /usr/sbin/dnsmasq
> >
> > new:
> > 185,676 /usr/sbin/dnsmasq
>
> Nice reduction.
>
> >
> > Signed-off-by: Hauke Mehrtens 
> > ---
> >  package/network/services/dnsmasq/Makefile | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/package/network/services/dnsmasq/Makefile 
> > b/package/network/services/dnsmasq/Makefile
> > index 5c114eb1c6..e86b031e3f 100644
> > --- a/package/network/services/dnsmasq/Makefile
> > +++ b/package/network/services/dnsmasq/Makefile
> > @@ -127,8 +127,8 @@ endef
> >  Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
> >  Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
> >
> > -TARGET_CFLAGS += -ffunction-sections -fdata-sections
> > -TARGET_LDFLAGS += -Wl,--gc-sections
> > +TARGET_CFLAGS += -flto
> > +TARGET_LDFLAGS += -flto=jobserver
>
> Maybe add a PKG_LTO (or so) flag packages can set, and add these flags
> then automatically? Less code churn per package.
Second
>
>
> Regards
> Jonas
>
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/4] dnsmasq: Activate LTO

2019-11-03 Thread Jonas Gorski
On Fri, 1 Nov 2019 at 21:55, Hauke Mehrtens  wrote:
>
> This decreases the binary size when PIE ASLR is activated by 8% on MIPS BE.
>
> old:
> 202,020 /usr/sbin/dnsmasq
>
> new:
> 185,676 /usr/sbin/dnsmasq

Nice reduction.

>
> Signed-off-by: Hauke Mehrtens 
> ---
>  package/network/services/dnsmasq/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/package/network/services/dnsmasq/Makefile 
> b/package/network/services/dnsmasq/Makefile
> index 5c114eb1c6..e86b031e3f 100644
> --- a/package/network/services/dnsmasq/Makefile
> +++ b/package/network/services/dnsmasq/Makefile
> @@ -127,8 +127,8 @@ endef
>  Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
>  Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
>
> -TARGET_CFLAGS += -ffunction-sections -fdata-sections
> -TARGET_LDFLAGS += -Wl,--gc-sections
> +TARGET_CFLAGS += -flto
> +TARGET_LDFLAGS += -flto=jobserver

Maybe add a PKG_LTO (or so) flag packages can set, and add these flags
then automatically? Less code churn per package.


Regards
Jonas

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/4] dnsmasq: Activate LTO

2019-11-02 Thread Hauke Mehrtens
On 11/1/19 10:08 PM, Rosen Penev wrote:
> On Fri, Nov 1, 2019 at 1:55 PM Hauke Mehrtens  wrote:
>>
>> This decreases the binary size when PIE ASLR is activated by 8% on MIPS BE.
> A small note on LTO:
> 
> These packages do not generate libraries, but sometimes, LTO messes up
> dynamic linking (static even more so).
> 
> For example: 
> https://github.com/openwrt/packages/blob/master/libs/libwangle/Makefile#L31
> is missing -flto specifically because a package that depends on it
> (openr, not in the packages feed yet) fails to link libwangle when
> -flto is specified for libwangle (a specific function was optimized
> out of the library).

I activated LTO globally and also saw multiple link problems, but I
think it was mostly related to static linking.

If a function is optimized out it was probably not correctly declared as
needed.

>>
>> old:
>> 202,020 /usr/sbin/dnsmasq
>>
>> new:
>> 185,676 /usr/sbin/dnsmasq
>>
>> Signed-off-by: Hauke Mehrtens 
>> ---
>>  package/network/services/dnsmasq/Makefile | 4 ++--
>>  1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/package/network/services/dnsmasq/Makefile 
>> b/package/network/services/dnsmasq/Makefile
>> index 5c114eb1c6..e86b031e3f 100644
>> --- a/package/network/services/dnsmasq/Makefile
>> +++ b/package/network/services/dnsmasq/Makefile
>> @@ -127,8 +127,8 @@ endef
>>  Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
>>  Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
>>
>> -TARGET_CFLAGS += -ffunction-sections -fdata-sections
>> -TARGET_LDFLAGS += -Wl,--gc-sections
> I am curious why these were removed.

I saw no size differences. These options are also used to allow the
linker to remove unused functions and data sections and with LTO the
compiler does the same just more so this should not be needed any more.

>> +TARGET_CFLAGS += -flto
>> +TARGET_LDFLAGS += -flto=jobserver
>>
>>  COPTS = -DHAVE_UBUS \
>> $(if $(CONFIG_IPV6),,-DNO_IPV6)
>> --
>> 2.20.1



signature.asc
Description: OpenPGP digital signature
___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


Re: [OpenWrt-Devel] [PATCH 1/4] dnsmasq: Activate LTO

2019-11-01 Thread Rosen Penev
On Fri, Nov 1, 2019 at 1:55 PM Hauke Mehrtens  wrote:
>
> This decreases the binary size when PIE ASLR is activated by 8% on MIPS BE.
A small note on LTO:

These packages do not generate libraries, but sometimes, LTO messes up
dynamic linking (static even more so).

For example: 
https://github.com/openwrt/packages/blob/master/libs/libwangle/Makefile#L31
is missing -flto specifically because a package that depends on it
(openr, not in the packages feed yet) fails to link libwangle when
-flto is specified for libwangle (a specific function was optimized
out of the library).
>
> old:
> 202,020 /usr/sbin/dnsmasq
>
> new:
> 185,676 /usr/sbin/dnsmasq
>
> Signed-off-by: Hauke Mehrtens 
> ---
>  package/network/services/dnsmasq/Makefile | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/package/network/services/dnsmasq/Makefile 
> b/package/network/services/dnsmasq/Makefile
> index 5c114eb1c6..e86b031e3f 100644
> --- a/package/network/services/dnsmasq/Makefile
> +++ b/package/network/services/dnsmasq/Makefile
> @@ -127,8 +127,8 @@ endef
>  Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
>  Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
>
> -TARGET_CFLAGS += -ffunction-sections -fdata-sections
> -TARGET_LDFLAGS += -Wl,--gc-sections
I am curious why these were removed.
> +TARGET_CFLAGS += -flto
> +TARGET_LDFLAGS += -flto=jobserver
>
>  COPTS = -DHAVE_UBUS \
> $(if $(CONFIG_IPV6),,-DNO_IPV6)
> --
> 2.20.1
>
>
> ___
> openwrt-devel mailing list
> openwrt-devel@lists.openwrt.org
> https://lists.openwrt.org/mailman/listinfo/openwrt-devel

___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel


[OpenWrt-Devel] [PATCH 1/4] dnsmasq: Activate LTO

2019-11-01 Thread Hauke Mehrtens
This decreases the binary size when PIE ASLR is activated by 8% on MIPS BE.

old:
202,020 /usr/sbin/dnsmasq

new:
185,676 /usr/sbin/dnsmasq

Signed-off-by: Hauke Mehrtens 
---
 package/network/services/dnsmasq/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/package/network/services/dnsmasq/Makefile 
b/package/network/services/dnsmasq/Makefile
index 5c114eb1c6..e86b031e3f 100644
--- a/package/network/services/dnsmasq/Makefile
+++ b/package/network/services/dnsmasq/Makefile
@@ -127,8 +127,8 @@ endef
 Package/dnsmasq-dhcpv6/conffiles = $(Package/dnsmasq/conffiles)
 Package/dnsmasq-full/conffiles = $(Package/dnsmasq/conffiles)
 
-TARGET_CFLAGS += -ffunction-sections -fdata-sections
-TARGET_LDFLAGS += -Wl,--gc-sections
+TARGET_CFLAGS += -flto
+TARGET_LDFLAGS += -flto=jobserver
 
 COPTS = -DHAVE_UBUS \
$(if $(CONFIG_IPV6),,-DNO_IPV6)
-- 
2.20.1


___
openwrt-devel mailing list
openwrt-devel@lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel