<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>14490</bug_id>
          
          <creation_ts>2021-07-23 22:14:52 +0000</creation_ts>
          <short_desc>gcc ICE building grub with LTO</short_desc>
          <delta_ts>2021-09-15 21:42:26 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>3.4</version>
          <rep_platform>x86</rep_platform>
          <op_sys>x86_64</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium+</priority>
          <bug_severity>major</bug_severity>
          <target_milestone>3.4 M3</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Tony Battersby">tonyb</reporter>
          <assigned_to name="Tony Battersby">tonyb</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>91018</commentid>
    <comment_count>0</comment_count>
    <who name="Tony Battersby">tonyb</who>
    <bug_when>2021-07-23 22:14:52 +0000</bug_when>
    <thetext>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 = &quot;genericx86-64&quot;
require conf/distro/include/lto.inc
DISTRO_FEATURES_append = &quot; lto&quot;

bitbake grub
...
| during IPA pass: inline
| lto1: internal compiler error: Segmentation fault
...
| 0x14ff7ae internal_error(char const*, ...)
| 	???:0
| 0x8a0b1e modref_tree&lt;int&gt;::merge(modref_tree&lt;int&gt;*, vec&lt;modref_parm_map, va_heap, vl_ptr&gt;*)
| 	???:0
| 0x897feb ipa_merge_modref_summary_after_inlining(cgraph_edge*)
| 	???:0
| 0x88a956 inline_call(cgraph_edge*, bool, vec&lt;cgraph_edge*, va_heap, vl_ptr&gt;*, 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 &lt;https://gcc.gnu.org/bugs/&gt; 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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91020</commentid>
    <comment_count>1</comment_count>
    <who name="Tony Battersby">tonyb</who>
    <bug_when>2021-07-26 15:47:11 +0000</bug_when>
    <thetext>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&apos;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 = &quot;&quot;

I will submit a patch for that as part of my patch set to make reproducible LTO builds.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91021</commentid>
    <comment_count>2</comment_count>
    <who name="Tony Battersby">tonyb</who>
    <bug_when>2021-07-26 16:48:19 +0000</bug_when>
    <thetext>Upstream bug report:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=101625</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91413</commentid>
    <comment_count>3</comment_count>
    <who name="Tony Battersby">tonyb</who>
    <bug_when>2021-09-15 21:42:26 +0000</bug_when>
    <thetext>Resolved by poky commit a7762efa03b9113f039c682eb066a623ca02ebb1 (&quot;lto.inc: disable LTO for grub&quot;).</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>