<?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>11777</bug_id>
          
          <creation_ts>2017-07-10 19:31:35 +0000</creation_ts>
          <short_desc>systemd ldconfig.service: always re-generates ld.so.cache (?) and fails on read-only rootfs</short_desc>
          <delta_ts>2021-09-28 16:52:34 +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>core</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>WORKSFORME</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</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Patrick Ohly">patrick.ohly</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>juro.bystricky</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>rap</cc>
    
    <cc>stephano</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>74904</commentid>
    <comment_count>0</comment_count>
    <who name="Patrick Ohly">patrick.ohly</who>
    <bug_when>2017-07-10 19:31:35 +0000</bug_when>
    <thetext>When booting into a read-only image with systemd as init system, ldconfig.service fails with:

Jul 10 19:00:39 intel-corei7-64 ldconfig[461]: /sbin/ldconfig: Can&apos;t create temporary cache file /etc/ld.so.cache~: Read-only file system
Jul 10 19:00:39 intel-corei7-64 systemd[1]: [[0;1;39mldconfig.service: Main process exited, code=exited, status=1/FAILURE[[0m
Jul 10 19:00:39 intel-corei7-64 systemd[1]: [[0;1;31mFailed to start Rebuild Dynamic Linker Cache.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd[1]: [[0;1;39mldconfig.service: Unit entered failed state.[[0m
Jul 10 19:00:39 intel-corei7-64 systemd[1]: [[0;1;39mldconfig.service: Failed with result &apos;exit-code&apos;.[[0m

I think (but haven&apos;t checked again) that ld.so.cache also gets re-generated unnecessarily when booting into a read/write image.

Avoiding unnecessary re-generation might be the right solution. However, I don&apos;t know how one would check the &quot;unnecessary&quot; part. If that can&apos;t be done, then the situation might have to stay the same for read/write (always re-generate) and for read-only the service needs to be disabled.

Can be reproduced with refkit-image-installer under qemu. See also bug #11776, which affects the same configuration.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>76521</commentid>
    <comment_count>1</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2017-09-05 13:31:12 +0000</bug_when>
    <thetext>Would this be solved by this which just landed into master:

    initramfs-live-boot: disable systemd-update-done.service on live images</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79107</commentid>
    <comment_count>2</comment_count>
    <who name="Patrick Ohly">patrick.ohly</who>
    <bug_when>2018-01-17 14:57:10 +0000</bug_when>
    <thetext>(In reply to comment #1)
&gt; Would this be solved by this which just landed into master:
&gt; 
&gt;     initramfs-live-boot: disable systemd-update-done.service on live images

No, that only solves the issue for an initramfs that uses init-live.sh.

It is not solved for a normal read-only rootfs, not does it address the &quot;ld.so.cache also gets re-generated unnecessarily when booting into a read/write image&quot; part.

But probably the technique used in that patch can be generalized also for the other scenarios.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79154</commentid>
    <comment_count>3</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2018-01-18 20:08:33 +0000</bug_when>
    <thetext>Maxin, can you take this?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79155</commentid>
    <comment_count>4</comment_count>
    <who name="Maxin B. John">maxin.john</who>
    <bug_when>2018-01-18 21:09:09 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; Maxin, can you take this?

Sure.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>79932</commentid>
    <comment_count>5</comment_count>
    <who name="Juro Bystricky">juro.bystricky</who>
    <bug_when>2018-03-22 09:41:20 +0000</bug_when>
    <thetext>(In reply to comment #0)

&gt; 
&gt; I think (but haven&apos;t checked again) that ld.so.cache also gets re-generated
&gt; unnecessarily when booting into a read/write image.
&gt; 

This has been puzzling me for a while, looking at the source code of ldconfig

https://github.com/lattera/glibc/blob/master/elf/ldconfig.c

We can see the the cache file contains directory entries. So I don&apos;t understand how you can actually &quot;cross-compile&quot; a cache file, as the directory entries reflect the build host machine. So the way I understand this, a cross-compiled ld.so.cache needs to re-generate right away, as all entries are originally invalid, originating from the build host.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>82705</commentid>
    <comment_count>6</comment_count>
    <who name="Kai Kang">kai.kang</who>
    <bug_when>2019-01-08 03:20:09 +0000</bug_when>
    <thetext>Can&apos;t reproduce. ldconfig.service not even to start because start condition is not met.

root@qemux86-64:~# touch /abc
touch: /abc: Read-only file system
root@qemux86-64:~#
root@qemux86-64:~# systemctl status ldconfig| more                                                                                                        
● ldconfig.service - Rebuild Dynamic Linker Cache
   Loaded: loaded (/lib/systemd/system/ldconfig.service; static; vendor preset: enabled)                                                                  
   Active: inactive (dead)
Condition: start condition failed at Tue 2019-01-08 03:05:36 UTC; 5min ago
           ├─ ConditionNeedsUpdate=|/etc was not met
           └─ ConditionFileNotEmpty=|!/etc/ld.so.cache was not met
     Docs: man:ldconfig(8)


Patrick, did you have extra configure?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86067</commentid>
    <comment_count>7</comment_count>
    <who name="Rasmus Pedersen">rap</who>
    <bug_when>2020-01-20 14:30:34 +0000</bug_when>
    <thetext>(In reply to comment #6)
&gt; Can&apos;t reproduce. ldconfig.service not even to start because start condition
&gt; is not met.
&gt; 
&gt; root@qemux86-64:~# touch /abc
&gt; touch: /abc: Read-only file system
&gt; root@qemux86-64:~#
&gt; root@qemux86-64:~# systemctl status ldconfig| more                          
&gt; 
&gt; ● ldconfig.service - Rebuild Dynamic Linker Cache
&gt;    Loaded: loaded (/lib/systemd/system/ldconfig.service; static; vendor
&gt; preset: enabled)                                                            
&gt; 
&gt;    Active: inactive (dead)
&gt; Condition: start condition failed at Tue 2019-01-08 03:05:36 UTC; 5min ago
&gt;            ├─ ConditionNeedsUpdate=|/etc was not met
&gt;            └─ ConditionFileNotEmpty=|!/etc/ld.so.cache was not met
&gt;      Docs: man:ldconfig(8)
&gt; 
&gt; 
&gt; Patrick, did you have extra configure?

Hi

I just ran into this issue.
We get the same error as OP.

We have a bb file adding a symlink like so:
ln -s /var/run/ld.so.cache ${D}${sysconfdir}/ld.so.cache</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>91606</commentid>
    <comment_count>8</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2021-09-28 16:52:34 +0000</bug_when>
    <thetext>I built a systemd image (core-image-sato) and agree this seems to work fine for me:

root@qemux86-64:~# systemctl status ldconfig
○ ldconfig.service - Rebuild Dynamic Linker Cache
     Loaded: loaded (/lib/systemd/system/ldconfig.service; static)
     Active: inactive (dead)
  Condition: start condition failed at Tue 2021-09-28 16:41:57 UTC; 2min 49s ago
             ├─ ConditionNeedsUpdate=|/etc was not met
             └─ ConditionFileNotEmpty=|!/etc/ld.so.cache was not met

with ldconfig -p showing cache entries which seem to match the system.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>