<?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>14317</bug_id>
          
          <creation_ts>2021-03-23 03:28:37 +0000</creation_ts>
          <short_desc>kernel.bbclass cleans files written by make-mod-scripts recipe</short_desc>
          <delta_ts>2021-05-15 23:04:12 +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>kernel</component>
          <version>unspecified</version>
          <rep_platform>All</rep_platform>
          <op_sys>Multiple</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>normal</bug_severity>
          <target_milestone>3.4 M1</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Kameron Larsen">kroylar+yoctobugzilla</reporter>
          <assigned_to name="Bruce Ashfield">bruce.ashfield</assigned_to>
          <cc>randy.macleod</cc>
    
    <cc>tom.zanussi</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>Don&apos;t know</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>89690</commentid>
    <comment_count>0</comment_count>
    <who name="Kameron Larsen">kroylar+yoctobugzilla</who>
    <bug_when>2021-03-23 03:28:37 +0000</bug_when>
    <thetext>Any kernel module recipe will contain `inherit module`. This references meta/classes/module.bbclass which contains `inherit module-base`. This references meta/classes/module-base.bbclass which contains:

# We do the dependency this way because the output is not preserved
# in sstate, so we must force do_compile to run (once).
do_configure[depends] += &quot;make-mod-scripts:do_compile&quot;

The make-mod-scripts recipe (at meta/recipes-kernel/make-mod-scripts/make-mod-scripts.bb) adds files to the {build_dir}/tmp/work-shared/{MACHINE}/kernel-build-artifacts directory. (This is referenced as STAGING_KERNEL_BUILDDIR which is set in conf/bitbake.conf.)

Unfortunately, the kernel recipe will remove everything in the STAGING_KERNEL_BUILDDIR directory, since that directory is added to the `do_shared_workdir[cleandirs]` variable in meta/classes/kernel.bbclass. This ends up removing files that make-mod-scripts put there as well.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89703</commentid>
    <comment_count>1</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2021-03-23 12:25:51 +0000</bug_when>
    <thetext>(In reply to comment #0)
&gt; Any kernel module recipe will contain `inherit module`. This references
&gt; meta/classes/module.bbclass which contains `inherit module-base`. This
&gt; references meta/classes/module-base.bbclass which contains:
&gt; 
&gt; # We do the dependency this way because the output is not preserved
&gt; # in sstate, so we must force do_compile to run (once).
&gt; do_configure[depends] += &quot;make-mod-scripts:do_compile&quot;
&gt; 
&gt; The make-mod-scripts recipe (at
&gt; meta/recipes-kernel/make-mod-scripts/make-mod-scripts.bb) adds files to the
&gt; {build_dir}/tmp/work-shared/{MACHINE}/kernel-build-artifacts directory.
&gt; (This is referenced as STAGING_KERNEL_BUILDDIR which is set in
&gt; conf/bitbake.conf.)
&gt; 
&gt; Unfortunately, the kernel recipe will remove everything in the
&gt; STAGING_KERNEL_BUILDDIR directory, since that directory is added to the
&gt; `do_shared_workdir[cleandirs]` variable in meta/classes/kernel.bbclass. This
&gt; ends up removing files that make-mod-scripts put there as well.

What&apos;s the actual issue though ?

If you&apos;ve cleaned the kernel, anything that uses what make-mod-scripts installs will trigger the dependency on the kernel and they are rebuild and reinstalled to the shared directory.

If you&apos;ve found a set of steps that get around this, share them here and we can have a look.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89712</commentid>
    <comment_count>2</comment_count>
    <who name="Kameron Larsen">kroylar+yoctobugzilla</who>
    <bug_when>2021-03-23 16:15:28 +0000</bug_when>
    <thetext>Oh sorry! I actually didn&apos;t explain that very well.

Since cleaning the kernel removes files put in the STAGING_KERNEL_BUILDDIR by make-mod-scripts, anything that depends on make-mod-scripts (all external kernel modules inheriting the module bbclass) will fail to build with this error:

ERROR: Kernel configuration is invalid.
       include/generated/autoconf.h or include/config/auto.conf are missing.
       Run &apos;make oldconfig &amp;&amp; make prepare&apos; on kernel src to fix it.


So the situation is:

1. build an image
2. bitbake -c cleansstate &lt;kernel&gt;
3. bitbake -c cleansstate &lt;external-module&gt;
4. rebuild the image

That last rebuild will correctly detect that both &lt;kernel&gt; and &lt;external-module&gt; need to be rebuilt. But it will not detect that make-mod-scripts also needs to be rebuilt. This causes the confusing error above.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89715</commentid>
    <comment_count>3</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2021-03-23 17:42:45 +0000</bug_when>
    <thetext>(In reply to comment #2)
&gt; Oh sorry! I actually didn&apos;t explain that very well.
&gt; 
&gt; Since cleaning the kernel removes files put in the STAGING_KERNEL_BUILDDIR
&gt; by make-mod-scripts, anything that depends on make-mod-scripts (all external
&gt; kernel modules inheriting the module bbclass) will fail to build with this
&gt; error:
&gt; 
&gt; ERROR: Kernel configuration is invalid.
&gt;        include/generated/autoconf.h or include/config/auto.conf are missing.
&gt;        Run &apos;make oldconfig &amp;&amp; make prepare&apos; on kernel src to fix it.
&gt; 
&gt; 
&gt; So the situation is:
&gt; 
&gt; 1. build an image
&gt; 2. bitbake -c cleansstate &lt;kernel&gt;
&gt; 3. bitbake -c cleansstate &lt;external-module&gt;
&gt; 4. rebuild the image
&gt; 
&gt; That last rebuild will correctly detect that both &lt;kernel&gt; and
&gt; &lt;external-module&gt; need to be rebuilt. But it will not detect that
&gt; make-mod-scripts also needs to be rebuilt. This causes the confusing error
&gt; above.

Perfect!

I&apos;ll see what&apos;s up with the dependencies.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89819</commentid>
    <comment_count>4</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2021-03-29 17:39:10 +0000</bug_when>
    <thetext>This didn&apos;t reproduce on one of my builders, trying on a second setup:

I&apos;ve added &quot;hello-mod&quot; from meta-skeleton to my test image, and have done the following:

 2627  bitbake core-image-minimal
 2628  bitbake -c cleansstate linux-yocto-dev
 2629  bitbake -c cleansstate hello-mod
 2630  bitbake core-image-minimal

I&apos;ll update with my next test when available.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89821</commentid>
    <comment_count>5</comment_count>
    <who name="Kameron Larsen">kroylar+yoctobugzilla</who>
    <bug_when>2021-03-29 20:06:59 +0000</bug_when>
    <thetext>I may have mis-represented step 4. It should actually be:

4. bitbake &lt;external-module&gt;

I think re-building the whole image will correctly rebuild the kernel and make-mod-scripts recipe before trying to build the external module.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89824</commentid>
    <comment_count>6</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2021-03-29 23:48:23 +0000</bug_when>
    <thetext>I switched to try this:

 1708  bitbake core-image-minimal
 1709  bitbake -c cleansstate linux-yocto
 1710  bitbake -c cleansstate hello-mod
 1711  bitbake hello-mod

Still not triggering the error.

Is this with master ? And which machine / kernel provider are you using ?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89913</commentid>
    <comment_count>7</comment_count>
    <who name="Kameron Larsen">kroylar+yoctobugzilla</who>
    <bug_when>2021-04-09 00:07:01 +0000</bug_when>
    <thetext>Sorry for the late reply. I was using the warrior branch, but I will try to reproduce with master myself now. I had assumed it would be easily reproducible because that code hasn&apos;t changed since warrior. I&apos;ll get back to you with my results.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>89914</commentid>
    <comment_count>8</comment_count>
    <who name="Bruce Ashfield">bruce.ashfield</who>
    <bug_when>2021-04-09 02:32:19 +0000</bug_when>
    <thetext>(In reply to comment #7)
&gt; Sorry for the late reply. I was using the warrior branch, but I will try to
&gt; reproduce with master myself now. I had assumed it would be easily
&gt; reproducible because that code hasn&apos;t changed since warrior. I&apos;ll get back
&gt; to you with my results.

No worries. thanks for the follow up.

I&apos;ll keep digging in the meantime, and see if I can see anything in the core code may have changed how the dependencies are processed between those two points.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90397</commentid>
    <comment_count>9</comment_count>
    <who name="Kameron Larsen">kroylar+yoctobugzilla</who>
    <bug_when>2021-05-15 21:49:49 +0000</bug_when>
    <thetext>I&apos;m not yet able to reproduce this. I think my initial reproduction steps were incorrect and that the problem may arise with the use of devtool. But I&apos;ve been experimenting with that as well to no avail.

The problem is that I wasn&apos;t the one who originally ran into this, but it was my colleague, who doesn&apos;t have the history of what caused it.

Perhaps we can close this ticket for now. If I ever see it happen again, I&apos;ll get solid reproducing steps before re-opening it or opening a new bug.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90398</commentid>
    <comment_count>10</comment_count>
    <who name="Kameron Larsen">kroylar+yoctobugzilla</who>
    <bug_when>2021-05-15 21:55:03 +0000</bug_when>
    <thetext>Wait! As I sent that I realized that I was able to reproduce it!

I reproduced it in our custom environment, but I&apos;ll try again with these steps, which I think will work.

bitbake core-image-minimal
devtool modify linux-yocto-dev
bitbake linux-yocto-dev
bitbake -c cleansstate hello-mod
devtool reset linux-yocto-dev
bitbake hello-mod</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>90399</commentid>
    <comment_count>11</comment_count>
    <who name="Kameron Larsen">kroylar+yoctobugzilla</who>
    <bug_when>2021-05-15 23:04:12 +0000</bug_when>
    <thetext>Well, it actually seems to be fixed in master, or at least those same steps don&apos;t reproduce the problem. Sorry for the noise.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>