<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>15722</bug_id>
          
          <creation_ts>2025-01-20 14:54:21 +0000</creation_ts>
          <short_desc>Add multilib support to nativesdk-gcc in x86-64 buildtools-extended-tarball</short_desc>
          <delta_ts>2025-01-29 19:41:18 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>OE-Core</product>
          <component>devtools / tool chain</component>
          <version>5.3</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>IN PROGRESS IMPLEMENTATION</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Medium</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>5.99</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Hongxu Jia">hongxu.jia</reporter>
          <assigned_to name="Hongxu Jia">hongxu.jia</assigned_to>
          <cc>hongxu.jia</cc>
    
    <cc>meta.mr.watcher</cc>
    
    <cc>meta.watcher</cc>
    
    <cc>randy.macleod</cc>
    
    <cc>ross.burton</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>New (Never tested)</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>100699</commentid>
    <comment_count>0</comment_count>
    <who name="Hongxu Jia">hongxu.jia</who>
    <bug_when>2025-01-20 14:54:21 +0000</bug_when>
    <thetext>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 &lt;&lt; ENDOF &gt; main.c
#include &lt;stdio.h&gt;
int main() {
  printf(&quot;Hello world&quot;);
  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:
&apos;&apos;&apos;
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
&apos;&apos;&apos;

Yocto rejected to add multilib bbclass extension support for nativesdk recipe,
but figure out the root cause:
&apos;&apos;&apos;
  the issue is that buildtools-extended-tarball
  doesn&apos;t contain 32 bit libgcc/glibc on 64 bit platforms and therefore
  can&apos;t build 32 bit binaries.
&apos;&apos;&apos;
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:
&apos;&apos;&apos;
  aarch64, i586, i686, loongarch64, ppc64, ppc64le, riscv64, x86_64
&apos;&apos;&apos;
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</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100717</commentid>
    <comment_count>1</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2025-01-23 15:42:59 +0000</bug_when>
    <thetext>Discussed in YP bug review. 
It&apos;s a very rare corner-case and RP isn&apos;t sure how to handle it since it adds some complexity that would need to be maintained by YP maintainers.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100764</commentid>
    <comment_count>2</comment_count>
    <who name="Ross Burton">ross.burton</who>
    <bug_when>2025-01-29 16:16:50 +0000</bug_when>
    <thetext>Has anyone investigated why lib32-luajit needs a 32-bit capable host compiler? Is this an x86-specific thing? What if I&apos;m building lib32-luajit for qemux86-64 on an aarch64 builder?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>100765</commentid>
    <comment_count>3</comment_count>
    <who name="Randy MacLeod">randy.macleod</who>
    <bug_when>2025-01-29 19:41:18 +0000</bug_when>
    <thetext>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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>