<?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>13853</bug_id>
          
          <creation_ts>2020-04-03 05:17:05 +0000</creation_ts>
          <short_desc>buildtools-extended-tarball: link search for librt not relocated</short_desc>
          <delta_ts>2020-04-08 04:15:19 +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.1</version>
          <rep_platform>x86</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>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Jeremy A. Puhlman">jpuhlman</reporter>
          <assigned_to name="Jeremy A. Puhlman">jpuhlman</assigned_to>
          <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>TicoTimo</cc>
    
    <cc>tim.orling</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>86897</commentid>
    <comment_count>0</comment_count>
    <who name="Jeremy A. Puhlman">jpuhlman</who>
    <bug_when>2020-04-03 05:17:05 +0000</bug_when>
    <thetext>Building nspr-native, there is a point where it links -lpthread and requires rt components, however it pulls in the host version of librt.

gcc   exit.o -Xlinker -L../../dist/lib -lplc4 -L../../dist/lib -lnspr4 -lpthread  -o exit
/home/jpuhlman/builds/master/profiles/opencgx-x86-generic-64/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/9.3.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib64/librt.so.1: undefined reference to `__clock_getcpuclockid@GLIBC_PRIVATE&apos;
/home/jpuhlman/builds/master/profiles/opencgx-x86-generic-64/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/9.3.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib64/librt.so.1: undefined reference to `__clock_nanosleep@GLIBC_PRIVATE&apos;
/home/jpuhlman/builds/master/profiles/opencgx-x86-generic-64/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/9.3.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib64/librt.so.1: undefined reference to `__clock_settime@GLIBC_PRIVATE&apos;
/home/jpuhlman/builds/master/profiles/opencgx-x86-generic-64/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/9.3.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib64/librt.so.1: undefined reference to `__clock_getres@GLIBC_PRIVATE&apos;

Stracing it down:

3061991 openat(AT_FDCWD, &quot;/home/jpuhlman/builds/master/profiles/opencgx-x86-generic-64/security/tmp/work/x86_64-linux/nspr-native/4.25-r0/recipe-sysroot-native/usr/lib/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/home/jpuhlman/builds/master/profiles/opencgx-x86-generic-64/security/tmp/work/x86_64-linux/nspr-native/4.25-r0/recipe-sysroot-native/lib/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/usr/lib64/atlas/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/usr/lib64//bind9-export/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/usr/lib64/dyninst/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/usr/lib64/iscsi/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/usr/lib64/mysql/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/usr/lib64/qt-3.3/lib/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/opt/poky/3.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/x86_64-pokysdk-linux/lib64/librt.so.1&quot;, O_RDONLY) = -1 EACCES (Permission denied)
3061991 openat(AT_FDCWD, &quot;/opt/poky/3.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib64/librt.so.1&quot;, O_RDONLY) = -1 EACCES (Permission denied)
3061991 openat(AT_FDCWD, &quot;/usr/local/lib64/librt.so.1&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, &quot;/lib64/librt.so.1&quot;, O_RDONLY) = 26

The access for:
/opt/poky/3.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/x86_64-pokysdk-linux/lib64/
and 
/opt/poky/3.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib64/

Should be relocated to wherever the compiler is installed rather than the default path. This only occurs if you just do -lpthread. This can be worked around in the build, by changing -lpthread to -lpthread -lrt so I don&apos;t think it is a ship stopper but its something that should likely be fixed at some point.

I am currently poking at this.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86898</commentid>
    <comment_count>1</comment_count>
    <who name="Jeremy A. Puhlman">jpuhlman</who>
    <bug_when>2020-04-03 05:18:08 +0000</bug_when>
    <thetext>Adding Tim, since he did a lot of work on this and may have some insight.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86904</commentid>
    <comment_count>2</comment_count>
    <who name="Jeremy A. Puhlman">jpuhlman</who>
    <bug_when>2020-04-03 16:51:59 +0000</bug_when>
    <thetext>Here is the issue:

3061991 openat(AT_FDCWD, &quot;/home/jpuhlman/builds/master/profiles/opencgx-x86-generic-64/buildtools/sysroots/x86_64-pokysdk-linux/etc/etc/ld.so.conf&quot;, O_RDONLY) = -1 ENOENT (No such file or directory)</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86905</commentid>
    <comment_count>3</comment_count>
    <who name="Jeremy A. Puhlman">jpuhlman</who>
    <bug_when>2020-04-03 17:39:17 +0000</bug_when>
    <thetext>Looks like the issue is ld_sysconfigdir is set to /&lt;sysroot path&gt;/ then we add /etc/ld.so.conf as well in the binutils ld patch. The following should fix it, currently testing.


diff --git a/meta/recipes-devtools/binutils/binutils/0003-binutils-nativesdk-Search-for-alternative-ld.so.conf.patch b/meta/recipes-devtools/binutils/bin
index 8b59ba5..4b4d73d 100644
--- a/meta/recipes-devtools/binutils/binutils/0003-binutils-nativesdk-Search-for-alternative-ld.so.conf.patch
+++ b/meta/recipes-devtools/binutils/binutils/0003-binutils-nativesdk-Search-for-alternative-ld.so.conf.patch
@@ -65,7 +65,7 @@ index 2e27cf48a8..a095d6aac5 100644
        info.path = NULL;
        info.len = info.alloc = 0;
 -      tmppath = concat (ld_sysroot, prefix, &quot;/etc/ld.so.conf&quot;,
-+      tmppath = concat (ld_sysconfdir, &quot;/etc/ld.so.conf&quot;,
++      tmppath = concat (ld_sysconfdir, &quot;/ld.so.conf&quot;,
                        (const char *) NULL);
        if (!ldelf_parse_ld_so_conf (&amp;info, tmppath))
        {</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86906</commentid>
    <comment_count>4</comment_count>
    <who name="Jeremy A. Puhlman">jpuhlman</who>
    <bug_when>2020-04-03 17:40:52 +0000</bug_when>
    <thetext>(In reply to comment #3)
&gt; Looks like the issue is ld_sysconfigdir is set to /&lt;sysroot path&gt;/ then we
&gt; add /etc/ld.so.conf as well in the binutils ld patch. 

That should be /&lt;sysroot path&gt;/etc then we add /etc/ld.so.conf to the end.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86911</commentid>
    <comment_count>5</comment_count>
    <who name="Tim Orling">tim.orling</who>
    <bug_when>2020-04-03 23:30:25 +0000</bug_when>
    <thetext>Looks like you figured out the root cause?

https://patchwork.openembedded.org/patch/171584/</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86912</commentid>
    <comment_count>6</comment_count>
    <who name="Jeremy A. Puhlman">jpuhlman</who>
    <bug_when>2020-04-03 23:34:27 +0000</bug_when>
    <thetext>(In reply to comment #5)
&gt; Looks like you figured out the root cause?
&gt; 
&gt; https://patchwork.openembedded.org/patch/171584/

Yes. Once the path is fixed nspr-native builds correctly. 

Moving to in progress review since its sitting in master-next.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>86930</commentid>
    <comment_count>7</comment_count>
    <who name="Jeremy A. Puhlman">jpuhlman</who>
    <bug_when>2020-04-08 04:15:19 +0000</bug_when>
    <thetext>In dunfell now. Moving to resolved.

https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?h=dunfell&amp;id=8b8d6897542f07cf47a4ee9def6d00d0fece96f1</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>