Linux: need to set -O2 when linking with lld

Created on 31 Jan 2019  路  4Comments  路  Source: ClangBuiltLinux/linux

looks like it's supported by bfd and gold.

0.34% size improvement with lld -O2 over lld for vmlinux.
3.3% size improvement with lld -O2 over lld for Image.lz4-dtb.

for bfd, didn't seem to change the size at all (I can't recall if this was arm64 or x86 I had tested with though).

[BUG] linux [PATCH] Rejected [TOOL] lld enhancement low priority polish

Most helpful comment

-O0: 4:07.67 total (247.67s)
-O2: 4:12.45 total (252.45s)
-1.9% overall build time for 0.34% size improvement in vmlinux and 3.3% Image.lz4-dtb improvement.
Probably should wrap this in a CONFIG_OPTIMIZE_FOR_SIZE.

All 4 comments

From reading the source to LLD, it looks like for ELF objects it performs section merging and string table tail merging. @rui314 suggested this to me on an internal thread based on my observation that the .strtab section is larger by 10.3% with LLD than BFD.

-O0: 4:07.67 total (247.67s)
-O2: 4:12.45 total (252.45s)
-1.9% overall build time for 0.34% size improvement in vmlinux and 3.3% Image.lz4-dtb improvement.
Probably should wrap this in a CONFIG_OPTIMIZE_FOR_SIZE.

maybe should be a config

Was this page helpful?
0 / 5 - 0 ratings