On Sun, Oct 27, 2019 at 1:32 PM Hauke Mehrtens <ha...@hauke-m.de> wrote:
>
> On 10/27/19 8:05 PM, Rosen Penev wrote:
> > On Sun, Oct 27, 2019 at 10:46 AM Hauke Mehrtens <ha...@hauke-m.de> wrote:
> >>
> >> This tristate choose allows to select to build only some applications
> >> with PIE enabled. On MIPS binaries are getting about 30% bigger when PIE
> >> is activated for the, which is a huge increase.
> > Some of the size increase can be mitigated with extra compile-time options:
> >
> > TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
> > TARGET_LDFLAGS += -Wl,--gc-sections,--as-needed
> >
> > LTO sometimes causes problems but the others should be safe.
> >
> > PKG_ASLR_PIE applies $(FPIC) to both C and LDFLAGS. I've noticed that
> > applying it only to the former increases the size but not as much as
> > with both. No idea why.
>
> Hi Rosen,
>
> Thank you for the hints.
>
> I activated -flto for dnsmasq and the size was decreased by 8% which is
> nice. I will test this a little bit and then send a patch to the mailing
> list.
>
> The GCC documentation says the following about -pie:
> ---------------------------------------------------------------------
> -pie
>     Produce a dynamically linked position independent executable on
> targets that support it. For predictable results, you must also specify
> the same set of options used for compilation (-fpie, -fPIE, or model
> suboptions) when you specify this linker option.
> ---------------------------------------------------------------------
> https://gcc.gnu.org/onlinedocs/gcc/Link-Options.html#Link-Options
>
> So we should set it for compiling and linking.
>
> GCC can activate -flto also when only some of the compile units used
> LTO, but it should also be set for both steps.]
In my experience, setting -flto is LDFLAGS usually does nothing.
CFLAGS is where it makes the difference. But yes, I agree.
>
> Hauke
>

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

Reply via email to