Bug 14112

Summary: nspr-native with OE/Yocto build tools doesn't build [Ubuntu 16.04.6]: undefined reference to `__clock_getres@GLIBC_PRIVATE'
Product: [Build System, Metadata & Runtime] OE-Core Reporter: David Abdurachmanov <david.abdurachmanov>
Component: devtools / tool chainAssignee: Richard Purdie <richard.purdie>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: Medium+ CC: akuster808, meta.mr.watcher, meta.watcher, randy.macleod
Version: unspecified   
Target Milestone: 3.3 M2   
Hardware: x86   
OS: Multiple   
Whiteboard: backport?
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Don't know

Description David Abdurachmanov 2020-11-02 23:29:10 UTC
I am running Ubuntu 16.04.6 LTS which has too old GCC (5.4) for OpenEmbedded. I use build tools from Yocto which brings 10.2.0 version. It used to work just fine until very recently.

I am no more able to build nspr-native. OE-Core (check out at Nov 3rd, master branch, 34ef5c2a8d77fcb4a51c875a443f7b97b409586e). Meta-OE (check out at Nov 3rd, master branch, ac4ccd2fbbb599d75ca4051911fcbaca39dbe6d7).

[..]
| gcc  -o abstract.o -c -fvisibility=hidden   -isystem/build/tmp-glibc/work/x86_64-linux/nspr-native/4.29-r0/recipe-sysroot-native/usr/include -isystem/build/tmp-glib
c/work/x86_64-linux/nspr-native/4.29-r0/recipe-sysroot-native/usr/include -O2 -pipe -Wall -pthread -g -fno-inline -fPIC  -UNDEBUG -DDEBUG_not_whoami -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STR
ING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE_URL=\"\" -DDEBUG=1 -DHAVE_VISIBILITY_HIDDEN_ATTRIBUTE=1 -DHAVE_VISIBILITY_PRAGMA=1 -DXP_UNIX=1 -D_GNU_SOURCE=1 -DHAVE_FCNTL_FILE_LOCKING=1 -DHAVE_POINTER_LOCALTIME_R=1 -DLINUX=1 -DHAVE
_DLADDR=1 -DHAVE_GETTID=1 -DHAVE_LCHOWN=1 -DHAVE_SETPRIORITY=1 -DHAVE_STRERROR=1 -DHAVE_SYSCALL=1 -DHAVE_SECURE_GETENV=1 -D_REENTRANT=1 -DFORCE_PR_LOG -D_PR_PTHREADS -UHAVE_CVAR_BUILT_ON_SEM -D_PR_INET6 -I../../dist/include/nspr
 -I../../../nspr-4.29/nspr/pr/include -I../../../nspr-4.29/nspr/pr/include/private  ../../../nspr-4.29/nspr/pr/tests/abstract.c
| gcc   abstract.o -Xlinker -L../../dist/lib -lplc4 -L../../dist/lib -lnspr4 -lpthread -o abstract
| /openembedded-core/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/10.2.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib/x86_64-linux-gnu/librt.so.1: undefined reference 
to `__clock_getcpuclockid@GLIBC_PRIVATE'
| /openembedded-core/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/10.2.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib/x86_64-linux-gnu/librt.so.1: undefined reference 
to `__clock_nanosleep@GLIBC_PRIVATE'
| /openembedded-core/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/10.2.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib/x86_64-linux-gnu/librt.so.1: undefined reference 
to `__clock_settime@GLIBC_PRIVATE'
| /openembedded-core/buildtools/sysroots/x86_64-pokysdk-linux/usr/lib/gcc/x86_64-pokysdk-linux/10.2.0/../../../../x86_64-pokysdk-linux/bin/ld: /lib/x86_64-linux-gnu/librt.so.1: undefined reference 
to `__clock_getres@GLIBC_PRIVATE'
| collect2: error: ld returned 1 exit status
| make: *** [Makefile:380: abstract] Error 1
| make: Leaving directory '/build/tmp-glibc/work/x86_64-linux/nspr-native/4.29-r0/build/pr/tests'
| WARNING: /build/tmp-glibc/work/x86_64-linux/nspr-native/4.29-r0/temp/run.do_compile.458191:196 exit 1 from 'exit 1'
[..]

The same issue was reported back in May 2020:

https://patchwork.openembedded.org/patch/172346/

I have tried to incl. nativesdk-glibc into buildtools-extended-tarball, but that didn't solve the issue.
Comment 1 David Abdurachmanov 2020-11-03 01:37:51 UTC
I noticed that my old builds are working fine, so I tested the last 3 versions of build tools:

./openembedded-core/scripts/install-buildtools -r yocto-3.2_M1 -t 20200617
./openembedded-core/scripts/install-buildtools -r yocto-3.2_M2 -t 20200729
./openembedded-core/scripts/install-buildtools -r yocto-3.2_M3 -t 20200923

M1 and M2 worked fine with oe-core & meta-oe being at master. M3 and my own built from the master do not work with nspr-native package.
Comment 2 akuster 2020-11-05 07:48:46 UTC
meta-oe did update the nspr package oct 19.
Comment 3 David Abdurachmanov 2020-11-05 08:19:58 UTC
I have tried to downgrade nspr version, but that was failing the same way.
Comment 4 Richard Purdie 2021-02-09 14:21:55 UTC
As mentioned in:

https://patchwork.openembedded.org/patch/172346/

the real issue is that you likely need:

https://patchwork.openembedded.org/patch/171584/

which is a patch for binutils. That should ensure it looks at librt from the sysroot before it looks at the one from host system and should resolve this issue.
Comment 5 David Abdurachmanov 2021-02-09 14:26:26 UTC
IIRC it did incl. this commit, but the patch didn't solve the problem.

The patch was committed in April, and I was using oe-core master in November.

Maybe I should give it another try as ~3 months have passed.