FS#73137 - [gnu-efi] Better CFLAGS (for systemd-boot)

Attached to Project: Arch Linux
Opened by Jan (medhefgo) - Friday, 24 December 2021, 10:52 GMT
Last edited by David Runge (dvzrv) - Friday, 08 April 2022, 18:45 GMT
Task Type Bug Report
Category Packages: Extra
Status Closed
Assigned To David Runge (dvzrv)
Architecture All
Severity Low
Priority Normal
Reported Version
Due in Version Undecided
Due Date Undecided
Percent Complete 100%
Votes 0
Private No

Details

With v250 systemd-boot gained support for LTO builds (which already works for the current build in testing). But it could benefit even more if gnu-efi was built with LTO too…

Additionally, while looking at the PKGBUILD, I noticed that we currently pass our userspace CFLAGS as-is to make. I consider this a bad idea for gnu-efi as it's not your typical userspace program. It's a freestanding compilation and as such, the compile flags should be heavily restricted. One example that could easily break things is '-march=x86_64-v3': This would allow the compiler to use instructions that may not be available *yet* at the time the boot loader runs because they might need to be enabled explicitly or because the firmware APIs that are called aren't prepared to save relevant CPU states.

As such, I would strongly suggest to only use these CFLAGS in PKGBUILD and let gnu-efi decide on anything else it wants:
export CFLAGS="-O2 -flto -ffat-lto-objects"
This task depends upon

Closed by  David Runge (dvzrv)
Friday, 08 April 2022, 18:45 GMT
Reason for closing:  Fixed
Additional comments about closing:  Fixed with gnu-efi 3.0.14-3
Comment by Jan (medhefgo) - Thursday, 30 December 2021, 13:24 GMT
Also, this requires "options=(!strip)".
Comment by David Runge (dvzrv) - Friday, 11 February 2022, 20:35 GMT
@medhefgo: Thanks for the report and the valuable input!

I'll look into this! :)
Comment by David Runge (dvzrv) - Friday, 08 April 2022, 18:09 GMT
@medhefgo: Can you check whether gnu-efi 3.0.14-3 in [testing] represents what you had in mind?
Comment by Jan (medhefgo) - Friday, 08 April 2022, 18:35 GMT
I tested both debug and LTO release builds and both work as expected now. This even shaves some 14k from systemd-boot. :D
Comment by David Runge (dvzrv) - Friday, 08 April 2022, 18:44 GMT
Excellent, thanks for confirming! :)

Loading...