tianocore / edk2

EDK II
https://github.com/tianocore/tianocore.github.io/wiki/EDK-II
Other
4.54k stars 2.45k forks source link

BaseTools/tools_def CLANGDWARF: Always use -Oz in RELEASE mode #5991

Closed ardbiesheuvel closed 1 month ago

ardbiesheuvel commented 1 month ago

GCC5, as well as CLANGDWARF for IA32/X64, use -Os or -Oz as the optimization level, which aggressively optimizes for the smallest possible object code.

On AARCH64, RISCV64 and ARM, we use -O3 instead, which results in considerable image bloat, to the point where the Raspberry Pi 4 build in edk2-platforms does not even build with -D SECURE_BOOT_ENABLE.

So let's align CLANGDWARF across all architectures, and use -Oz throughout.

Note that O3 is still used for the linker, which build in LTO mode and therefore performs some code generation as well. This is deliberate: LLD does not support the Os/Oz optimization levels at all, and using Oz for the compile pass is sufficient to reduce the code size substantially.