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.
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.