* [Buildroot] Question about Compilation Flags
@ 2016-11-11 9:19 Anand Sivaram
2016-11-11 14:03 ` Thomas Petazzoni
0 siblings, 1 reply; 5+ messages in thread
From: Anand Sivaram @ 2016-11-11 9:19 UTC (permalink / raw)
To: buildroot
Dear All,
I am using buildroot on a MIPS system. My uncompressed rootfs created by
buildroot is around 25MB.
In order to save some more space, I enabled -ffunction-sections
-fdata-sections and --gcsections as below.
File: package/Makefile.in
TARGET_CFLAGS += -ffunction-sections -fdata-sections
TARGET_LDFLAGS += -Wl,--gc-sections
Everything went fine, I saved around 1MB. But lighttpd with mod-fcgi
enabled got SIGSEGV with the above change.
I have a question? Could I disable these flags *only* for lighttpd, that
means using the above flags in all packages except lighttpd.
Any help would be really appreciated.
Thanks and Best Regards
Anand
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20161111/21f31330/attachment.html>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] Question about Compilation Flags
2016-11-11 9:19 [Buildroot] Question about Compilation Flags Anand Sivaram
@ 2016-11-11 14:03 ` Thomas Petazzoni
2016-11-12 7:36 ` Anand Sivaram
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2016-11-11 14:03 UTC (permalink / raw)
To: buildroot
Hello,
On Fri, 11 Nov 2016 14:49:42 +0530, Anand Sivaram wrote:
> File: package/Makefile.in
> TARGET_CFLAGS += -ffunction-sections -fdata-sections
> TARGET_LDFLAGS += -Wl,--gc-sections
You can also pass these through "menuconfig", using
BR2_TARGET_OPTIMIZATION and BR2_TARGET_LDFLAGS.
> Everything went fine, I saved around 1MB. But lighttpd with mod-fcgi
> enabled got SIGSEGV with the above change.
>
> I have a question? Could I disable these flags *only* for lighttpd, that
> means using the above flags in all packages except lighttpd.
Yes, you can adapt lighttpd.mk for that. You need to do something like
this:
LIGHTTPD_CONF_ENV = \
CFLAGS=$(filter-out -ffunction-sections -fdata-section,$(TARGET_CFLAGS)) \
LDFLAGS=$(filter-out -Wl,--gc-sections,$(TARGET_LDFLAGS))
BTW, how much space did you save by using those options? What was the
filesystem size before adding those options and after?
Best regards,
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] Question about Compilation Flags
2016-11-11 14:03 ` Thomas Petazzoni
@ 2016-11-12 7:36 ` Anand Sivaram
2016-11-12 9:21 ` Thomas Petazzoni
0 siblings, 1 reply; 5+ messages in thread
From: Anand Sivaram @ 2016-11-12 7:36 UTC (permalink / raw)
To: buildroot
Thomas,
Thank you very much for the reply. I think BR2_TARGET_OPTIMIZATION and
BR2_TARGET_LDFLAGS are
better solutions than what I did in config/Makefile.in
I will try lighttpd.mk changes as you suggested.
These are the numbers I found without changing lighttpd in a special way.
du -ks output/target/ (default buildroot for mips without
function/data/gc-section)
26188 output/target/
du -ks output/target/ (with function/data/gc-sections)
25012 output/target/
That gives a saving of 1176 KB then.
Thanks and Best Regards
Anand
On 11 November 2016 at 19:33, Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> On Fri, 11 Nov 2016 14:49:42 +0530, Anand Sivaram wrote:
>
> > File: package/Makefile.in
> > TARGET_CFLAGS += -ffunction-sections -fdata-sections
> > TARGET_LDFLAGS += -Wl,--gc-sections
>
> You can also pass these through "menuconfig", using
> BR2_TARGET_OPTIMIZATION and BR2_TARGET_LDFLAGS.
>
> > Everything went fine, I saved around 1MB. But lighttpd with mod-fcgi
> > enabled got SIGSEGV with the above change.
> >
> > I have a question? Could I disable these flags *only* for lighttpd, that
> > means using the above flags in all packages except lighttpd.
>
> Yes, you can adapt lighttpd.mk for that. You need to do something like
> this:
>
> LIGHTTPD_CONF_ENV = \
> CFLAGS=$(filter-out -ffunction-sections -fdata-section,$(TARGET_CFLAGS))
> \
> LDFLAGS=$(filter-out -Wl,--gc-sections,$(TARGET_LDFLAGS))
>
> BTW, how much space did you save by using those options? What was the
> filesystem size before adding those options and after?
>
> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20161112/ddb43102/attachment.html>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] Question about Compilation Flags
2016-11-12 7:36 ` Anand Sivaram
@ 2016-11-12 9:21 ` Thomas Petazzoni
2016-11-12 9:54 ` Anand Sivaram
0 siblings, 1 reply; 5+ messages in thread
From: Thomas Petazzoni @ 2016-11-12 9:21 UTC (permalink / raw)
To: buildroot
Hello,
On Sat, 12 Nov 2016 13:06:11 +0530, Anand Sivaram wrote:
> Thank you very much for the reply. I think BR2_TARGET_OPTIMIZATION and
> BR2_TARGET_LDFLAGS are
> better solutions than what I did in config/Makefile.in
>
> I will try lighttpd.mk changes as you suggested.
>
> These are the numbers I found without changing lighttpd in a special way.
>
> du -ks output/target/ (default buildroot for mips without
> function/data/gc-section)
> 26188 output/target/
> du -ks output/target/ (with function/data/gc-sections)
> 25012 output/target/
>
> That gives a saving of 1176 KB then.
That's not bad indeed, about 4.4% space saving.
Thanks for the feedback!
Thomas
--
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux and Kernel engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 5+ messages in thread
* [Buildroot] Question about Compilation Flags
2016-11-12 9:21 ` Thomas Petazzoni
@ 2016-11-12 9:54 ` Anand Sivaram
0 siblings, 0 replies; 5+ messages in thread
From: Anand Sivaram @ 2016-11-12 9:54 UTC (permalink / raw)
To: buildroot
Thomas,
A couple of points I noticed. ffunction-sections/data-sections increase
the size because each function/data goes to its own section with section
header etc.
But if the library/application has unused functions they would be removed
at link time by gc-sections. If the lib/app has been written carefully
without any unused function, then we will not get any savings at all.
The problem with lighttpd is that it uses dlopen() to load different
plugins like mod_cgi, most_fastcgi etc. Programs like vlc/gstreamer who
use plugins framework also do the same. But, gc-section could be removing
some essential functions marking them as unused. There is a --entry option
used by ld (as per man ld) which we could use to specifiy the entry
function.
Currently I am planning to use function/data section for the whole
buildroot but avoiding lighttpd as you suggested.
Thanks and Regards
Anand
On 12 November 2016 at 14:51, Thomas Petazzoni <
thomas.petazzoni@free-electrons.com> wrote:
> Hello,
>
> On Sat, 12 Nov 2016 13:06:11 +0530, Anand Sivaram wrote:
>
> > Thank you very much for the reply. I think BR2_TARGET_OPTIMIZATION and
> > BR2_TARGET_LDFLAGS are
> > better solutions than what I did in config/Makefile.in
> >
> > I will try lighttpd.mk changes as you suggested.
> >
> > These are the numbers I found without changing lighttpd in a special way.
> >
> > du -ks output/target/ (default buildroot for mips without
> > function/data/gc-section)
> > 26188 output/target/
> > du -ks output/target/ (with function/data/gc-sections)
> > 25012 output/target/
> >
> > That gives a saving of 1176 KB then.
>
> That's not bad indeed, about 4.4% space saving.
>
> Thanks for the feedback!
>
> Thomas
> --
> Thomas Petazzoni, CTO, Free Electrons
> Embedded Linux and Kernel engineering
> http://free-electrons.com
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20161112/350dbb2e/attachment.html>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-11-12 9:54 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-11-11 9:19 [Buildroot] Question about Compilation Flags Anand Sivaram
2016-11-11 14:03 ` Thomas Petazzoni
2016-11-12 7:36 ` Anand Sivaram
2016-11-12 9:21 ` Thomas Petazzoni
2016-11-12 9:54 ` Anand Sivaram
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox