When attempting to set up an environment for cross-compiling for Yocto Linux, I am getting an unusual build error when it’s building some of the host tools used by the Linux kernel. This seems to be due to an unusual libc.so library file that is actually an LD linker script. Due to that linker script, when I run make modules_prepare
in the Linux kernel source tree for my Yocto target, it fails while building the extract-cert
host utility:
/usr/bin/ld: cannot find /lib64/libc.so.6: No such file or directory
/usr/bin/ld: cannot find /usr/lib64/libc_nonshared.a: No such file or directory
The specific build command that is failing is this:
gcc -Wp,-MMD,scripts/.extract-cert.d -Wall -Wmissing-prototypes -Wstrict-prototypes -O2 -fomit-frame-pointer -std=gnu89 -o scripts/extract-cert scripts/extract-cert.c -L/opt/windriver/wrlinux/22.33/sysroots/core2-64-wrs-linux/usr/lib64 -lcrypto
However, the failure can be reduced to just this command:
gcc scripts/extract-cert.c -L/opt/windriver/wrlinux/22.33/sysroots/core2-64-wrs-linux/usr/lib64 -lcrypto
Removing the -L
library path option from GCC is enough to make either command above succeed. It seems to be due to the libc.so
file found inside that folder which has this contents:
/* GNU ld script
Use the shared library, but some functions are only in
the static library, so try that secondarily. */
OUTPUT_FORMAT(elf64-x86-64)
GROUP ( /lib64/libc.so.6 /usr/lib64/libc_nonshared.a AS_NEEDED ( /lib64/ld-linux-x86-64.so.2 ) )
Another valid workaround seems to be removing that libc.so
file from that folder. After doing that, the make modules_prepare
command succeeds and I can now build external modules with that source tree.
The specific version of Yocto I am building is Wind River Linux LTS 22. The build of the image itself was successful and it is booted and running. The host system is Ubuntu Linux 22.04.4 LTS. The SDK was build using the populate_sdk
task with bitbake after adding modifying TOOLCHAIN_TARGET_TASK
to include kernel-devsrc
so the SDK would include the kernel sources. The SDK was installed onto the same system.
Once the SDK was installed, I ran make modules_prepare
in the kernel build tree that came with the SDK in order to build the module next. However, it failed with the aforementioned error. What is the correct resolution for this? What is the goal of that file above and how do I avoid it interfering with the build of the kernel? Is there a way to get Yocto to pre-prepare the kernel sources so that this step is not needed? If not, what should be done so the SDK installer that Yocto builds can at least be prepared without that libc.so-related error?
I expect to be able to prepare the kernel sources after a fresh install of the kernel without triggering build errors at a minimum. Ideally, I’d like for the SDK to prepare the sources automatically as part of the install so I can immediately go to building kernel modules with it.