Bug 13853 - buildtools-extended-tarball: link search for librt not relocated
Summary: buildtools-extended-tarball: link search for librt not relocated
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: devtools / tool chain (show other bugs)
Version: 3.1
Hardware: x86 Multiple
: Undecided normal
Target Milestone: ---
Assignee: Jeremy A. Puhlman
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2020-04-03 05:17 UTC by Jeremy A. Puhlman
Modified: 2020-04-08 04:15 UTC (History)
4 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: No (bug/feature does not impact docs)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy A. Puhlman 2020-04-03 05:17:05 UTC
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'
/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'
/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'
/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'

Stracing it down:

3061991 openat(AT_FDCWD, "/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", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/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", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/usr/lib64/atlas/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/usr/lib64//bind9-export/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/usr/lib64/dyninst/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/usr/lib64/iscsi/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/usr/lib64/mysql/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/usr/lib64/qt-3.3/lib/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/opt/poky/3.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/x86_64-pokysdk-linux/lib64/librt.so.1", O_RDONLY) = -1 EACCES (Permission denied)
3061991 openat(AT_FDCWD, "/opt/poky/3.0+snapshot/sysroots/x86_64-pokysdk-linux/usr/lib64/librt.so.1", O_RDONLY) = -1 EACCES (Permission denied)
3061991 openat(AT_FDCWD, "/usr/local/lib64/librt.so.1", O_RDONLY) = -1 ENOENT (No such file or directory)
3061991 openat(AT_FDCWD, "/lib64/librt.so.1", 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't think it is a ship stopper but its something that should likely be fixed at some point.

I am currently poking at this.
Comment 1 Jeremy A. Puhlman 2020-04-03 05:18:08 UTC
Adding Tim, since he did a lot of work on this and may have some insight.
Comment 2 Jeremy A. Puhlman 2020-04-03 16:51:59 UTC
Here is the issue:

3061991 openat(AT_FDCWD, "/home/jpuhlman/builds/master/profiles/opencgx-x86-generic-64/buildtools/sysroots/x86_64-pokysdk-linux/etc/etc/ld.so.conf", O_RDONLY) = -1 ENOENT (No such file or directory)
Comment 3 Jeremy A. Puhlman 2020-04-03 17:39:17 UTC
Looks like the issue is ld_sysconfigdir is set to /<sysroot path>/ 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, "/etc/ld.so.conf",
-+      tmppath = concat (ld_sysconfdir, "/etc/ld.so.conf",
++      tmppath = concat (ld_sysconfdir, "/ld.so.conf",
                        (const char *) NULL);
        if (!ldelf_parse_ld_so_conf (&info, tmppath))
        {
Comment 4 Jeremy A. Puhlman 2020-04-03 17:40:52 UTC
(In reply to comment #3)
> Looks like the issue is ld_sysconfigdir is set to /<sysroot path>/ then we
> add /etc/ld.so.conf as well in the binutils ld patch. 

That should be /<sysroot path>/etc then we add /etc/ld.so.conf to the end.
Comment 5 Tim Orling 2020-04-03 23:30:25 UTC
Looks like you figured out the root cause?

https://patchwork.openembedded.org/patch/171584/
Comment 6 Jeremy A. Puhlman 2020-04-03 23:34:27 UTC
(In reply to comment #5)
> Looks like you figured out the root cause?
> 
> 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.
Comment 7 Jeremy A. Puhlman 2020-04-08 04:15:19 UTC
In dunfell now. Moving to resolved.

https://git.yoctoproject.org/cgit/cgit.cgi/poky/commit/?h=dunfell&id=8b8d6897542f07cf47a4ee9def6d00d0fece96f1