The background is we used extended buildtools SDK to provide gcc and other build tools on host for a Yocto build, but recipes that uses gcc-multilib and glibc-multilib on host will fail with extended buildtools. For example, lib32-luajit fails with extended buildtools. With a simple search, we have enabled multilib bbclass extension for target gcc [1][2] {noformat} $ cat << ENDOF > main.c #include <stdio.h> int main() { printf("Hello world"); return 0; } ENDOF $ gcc main.c -o main-64 $ gcc -m32 main.c -o main-32 $ file main-64 main-32 main-64: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6d51010a38e03f84ea07897cd4ba6fd97ef9c74b, for GNU/Linux 3.2.0, not stripped main-32: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=fc8c3058b07d98d2fd19d91a0bf9e35c715c7014, for GNU/Linux 3.2.0, not stripped {noformat} [1] https://bugzilla.yoctoproject.org/show_bug.cgi?id=1369 [2] https://git.openembedded.org/openembedded-core/commit/?id=b26819c85881e82ee1b5c68840011e78c321f18e Add this story is enable multilib for nativesdk gcc, similar like: ''' root@qemux86-64:~# ./x86_64-buildtools-extended-nativesdk-standalone-5.1.sh -d sdk root@qemux86-64:~# source sdk/environment-setup-x86_64-pokysdk-linux root@qemux86-64:~# which gcc /home/root/sdk/sysroots/x86_64-sdk-linux/usr/bin/gcc root@qemux86-64:~# gcc main.c -o main-64 root@qemux86-64:~# gcc -m32 main.c -o main-32 root@qemux86-64:~# file main-64 main-32 main-64: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter //home/root/sdk/sysroots/x86_64-sdk-linux/lib64/ld-linux-x86-64.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=3c912c568c7fce674deb3de2978abad0cfe41743, not stripped main-32: ELF 32-bit LSB pie executable, Intel i386, version 1 (SYSV), dynamically linked, interpreter //home/root/sdk/sysroots/x86_64-sdk-linux/lib/ld-linux.so.2, for GNU/Linux 3.2.0, BuildID[sha1]=49394a5afa840379278cf9e30ed6c7f8a251e850, not stripped ''' Yocto rejected to add multilib bbclass extension support for nativesdk recipe, but figure out the root cause: ''' the issue is that buildtools-extended-tarball doesn't contain 32 bit libgcc/glibc on 64 bit platforms and therefore can't build 32 bit binaries. ''' With a simple search, we could refer the multiconfig selftest case [3], add a nativesdk recipe nativesdk-multiconfig-multlib-toolchain-packager to fetch 32 bit libgcc/glibc from 32bit multiconfig build, package it and install to 64 bit buildtools-extended-tarball. Also reverse to fetch 64 bit libgcc/glibc from 64bit multiconfig build and instll to 32 bit buildtools-extended-tarball. [3] https://github.com/openembedded/openembedded-core/blob/master/meta-selftest/recipes-test/multiconfig/multiconfig-image-packager_0.1.bb Due to the supported SDKMACHINE is: ''' aarch64, i586, i686, loongarch64, ppc64, ppc64le, riscv64, x86_64 ''' Only i586 and x86_64, i686 and x86_64 have multilib relationship, I will choose i686 and x86_64 as the example, mainly includes - Enhance GCC to enable multilib for i686/x86_64/i586 nativesdk gcc - Enhance SDK to support multilib dynamic loaders relocation - Add a nativesdk recipe fetch and install missing libgcc/glibc - Add a template multlib-nativesdk-gcc to enable the feature for buildtools-extended-tarball build
Discussed in YP bug review. It's a very rare corner-case and RP isn't sure how to handle it since it adds some complexity that would need to be maintained by YP maintainers.
Has anyone investigated why lib32-luajit needs a 32-bit capable host compiler? Is this an x86-specific thing? What if I'm building lib32-luajit for qemux86-64 on an aarch64 builder?
lib32-luajit bug report: Cross-compiling 32 bit LuaJIT on a 64 bit host https://github.com/LuaJIT/LuaJIT/issues/664 resolved as an nice-to-do-but-not-for-me enhancement by upstream.