Bug 14521 - glibc 2.34 and pseudo break with uninative
Summary: glibc 2.34 and pseudo break with uninative
Status: RESOLVED FIXED
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 3.3
Hardware: x86 Multiple
: Undecided normal
Target Milestone: ---
Assignee: Unassigned
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2021-08-20 16:50 UTC by Richard Purdie
Modified: 2021-08-26 15:00 UTC (History)
8 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 Richard Purdie 2021-08-20 16:50:59 UTC
With the upgrade to glibc 2.34, testing with buildtools tarball reveals a problem. This can be seen with:

bitbake buildtools-extended-tarball
bitbake buildtools-extended-tarball -c testsdk

where linux-libc-headers:do_install will fail due to being unable to load pseudo. The real error is in bitbake-cookerdaemon.log where the issue with symbol mismatches will be seen. There are some fixes in master-next

pseudo: Fix to work with glibc 2.34 systems
gcc: also relocate the musl loader
gcc: Fix nativesdk builds and multilib fixes with gcc
glibc-package.inc: Fix builds of pseudo with glibc 2.34

however these aren't enough and don't full avoid the problems.

The issue is that pseudo-native is compiled against the buildtools compiler which means glibc 2.34. If a binary is then run by the host system which doesn't use glibc 2.34, the symbol differences become apparent. This happens with libpseudo.so since it is an LD_PRELOAD.

In particular, libpseudo.so uses a pthread mutex and dlerror(), dlsym() and dlvsym() calls. In 2.34 these moved from libpthread and libdl to libc. In linking with newer libs, the lib references are dropped. Even adding DT_NEEDED sections isn't enough since the linker helpfully optimises through to libc.so's symbols.

The huge problem is that as soon as distros start shipping with glibc 2.34, pseudo-native will work with the glibc it was built with but not the other set. We therefore have a problem which will soon cause us a lot of pain.

In the past we made pseudo-native host specific. The broke eSDKs in ways which ended with us reverting that change.

I did ask for ideas on the libc list:

https://sourceware.org/pipermail/libc-help/2021-August/005985.html

I have tried:

* adding sysroot-uninative to libpseudo.so's RUNPATH but it is not used by the linker for loading libc.so for host binaries
* injecting the sysroot-uninative path into pseudo's LD_LIBRARY_PATH and this does load the right libc.so however since the loader was the host's ld.so, this errors
* the pseudo patch referenced above which changes the symbol versioning of dlerror/dlsym/dlvsym however the linker still resolves the symbols to libc.so rather than libdl.so

I'd note that the pthread symbols don't use 2.34 versioning so are slightly less problematic but that the pthread APIs look to have changed meaning that using an older pthread lib with newer compiled calls may be highly suspect.

Other ideas:

* adding a dummy libdl to link against to fool libpseudo into looking as we need it
* downloading older binaries to link pseudo-native against
Comment 1 Richard Purdie 2021-08-20 17:05:08 UTC
I guess the alternative plan is to go back to host specific pseudo-native recipes and remove that from the locked sigs in eSDK so that it can be rebuild it not correct. I'm struggling to find any better/sane idea.
Comment 2 Richard Purdie 2021-08-21 09:50:55 UTC
There is another problem. If we make pseudo-native host specific and allow the eSDK to rebuild where necessary then we need to change runqueue to optimise that workflow. If pseudo-native isn't present currently, it will mean it can't install large chunks of the system from sstate as there would be no fakeroot env to do so. The "hard dep" handling in runqueue would need to be rewritten.
Comment 3 Richard Purdie 2021-08-21 11:47:42 UTC
For reference you can't statically link in libpthread:

| 	pseudo_wrappers.o pseudo_tables.o pseudo_util.o -L/media/build1/poky/build/tmp/work/x86_64-linux/pseudo-native/1.9.0+gitAUTOINC+b988b0a6b8-r0/recipe-sysroot-native/usr/lib                         -L/media/build1/poky/build/tmp/work/x86_64-linux/pseudo-native/1.9.0+gitAUTOINC+b988b0a6b8-r0/recipe-sysroot-native/lib                         -Wl,--enable-new-dtags                         -Wl,-rpath-link,/media/build1/poky/build/tmp/work/x86_64-linux/pseudo-native/1.9.0+gitAUTOINC+b988b0a6b8-r0/recipe-sysroot-native/usr/lib                         -Wl,-rpath-link,/media/build1/poky/build/tmp/work/x86_64-linux/pseudo-native/1.9.0+gitAUTOINC+b988b0a6b8-r0/recipe-sysroot-native/lib                         -Wl,-rpath,/media/build1/poky/build/tmp/work/x86_64-linux/pseudo-native/1.9.0+gitAUTOINC+b988b0a6b8-r0/recipe-sysroot-native/usr/lib                         -Wl,-rpath,/media/build1/poky/build/tmp/work/x86_64-linux/pseudo-native/1.9.0+gitAUTOINC+b988b0a6b8-r0/recipe-sysroot-native/lib                         -Wl,-O1 -Wl,--allow-shlib-undefined -Wl,--dynamic-linker=/media/build1/poky/build/tmp/sysroots-uninative/x86_64-linux/lib/ld-linux-x86-64.so.2  -Wl,-ldl -Wl,-Bstatic -Wl,-lpthread -Wl,-Bdynamic
| /media/build1/poky/build/tmp/hosttools/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libpthread.a(elision-lock.o): .preinit_array section is not allowed in DSO
| /media/build1/poky/build/tmp/hosttools/ld: failed to set dynamic section sizes: nonrepresentable section on output

(and statically linking in libdl would make no sense)
Comment 5 Richard Purdie 2021-08-26 15:00:59 UTC
See above for fix