Link update_engine with --gc-sections to remove unused code.
This patch adds -Wl,--gc-sections to LDFLAGS to instruct the linker
to remove all the unused functions. It also adds -ffuntion-sections
to CFLAGS in order to have each function on its own section and thus
allowing the linker to remove them. Finally, libxml2 include
directory is derived from pkg-config and other minor formating is
adjusted.
This reduces the update_engine size from 1.1MB to 800KB and the
update_engine_client from 755KB to only 119KB. This is because we
include all the delta generation code on the link step, altough we
only need parts of it, also the update_engine_client doesn't use
much of the update_engine code.
The flags are added before the environment provided flags, so this
can be disabled passing:
LDFLAGS=-Wl,--no-gc-sections emerge-${BOARD} update_engine
BUG=chromium:359343
TEST=emerge-link update_engine (with and without the LDFLAGS passed)
TEST=gmerged on link, restarted, run update from it to my desktop.
Change-Id: Ic185a3c46bdc4b1c5f97e16f3ae520a44a9307da
Reviewed-on: https://chromium-review.googlesource.com/196379
Reviewed-by: Chris Sosa <sosa@chromium.org>
Reviewed-by: Mike Frysinger <vapier@chromium.org>
Commit-Queue: Alex Deymo <deymo@chromium.org>
Tested-by: Alex Deymo <deymo@chromium.org>
1 file changed