When building grub with Link Time Optimization enabled, gcc crashes with an internal compiler error. Distro is current poky master (Yocto 3.4, gcc 11.1); last commit was 17aabc012743 on 2021-07-22. local.conf: MACHINE = "genericx86-64" require conf/distro/include/lto.inc DISTRO_FEATURES_append = " lto" bitbake grub ... | during IPA pass: inline | lto1: internal compiler error: Segmentation fault ... | 0x14ff7ae internal_error(char const*, ...) | ???:0 | 0x8a0b1e modref_tree<int>::merge(modref_tree<int>*, vec<modref_parm_map, va_heap, vl_ptr>*) | ???:0 | 0x897feb ipa_merge_modref_summary_after_inlining(cgraph_edge*) | ???:0 | 0x88a956 inline_call(cgraph_edge*, bool, vec<cgraph_edge*, va_heap, vl_ptr>*, int*, bool, bool*) | ???:0 | Please submit a full bug report, | with preprocessed source if appropriate. | Please include the complete backtrace with any bug report. | See <https://gcc.gnu.org/bugs/> for instructions. | lto-wrapper: fatal error: x86_64-poky-linux-gcc returned 1 exit status | compilation terminated. | make[3]: *** [Makefile:31565: zstd.module] Error 1
I just reproduced the same problem with gcc 11.1.1 from current git outside of Yocto. I will submit an upstream bug report. Regarding grub, we already know that grub doesn't like being compiled with -O2: https://bugzilla.yoctoproject.org/show_bug.cgi?id=14367 https://lists.yoctoproject.org/g/yocto/message/53321 With gcc 10.2 under Hardknott, compiling with -flto makes the /usr/lib/grub/i386-pc/*.mod files not binary reproducible: https://bugzilla.yoctoproject.org/show_bug.cgi?id=14481 So for now a good workaround is to disable LTO for grub with the following: LTO_pn-grub = "" I will submit a patch for that as part of my patch set to make reproducible LTO builds.
Upstream bug report: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101625
Resolved by poky commit a7762efa03b9113f039c682eb066a623ca02ebb1 ("lto.inc: disable LTO for grub").