Bug 14020 - environment-setup script in multilib eSDK doesn't work for multilib variant
Summary: environment-setup script in multilib eSDK doesn't work for multilib variant
Status: IN PROGRESS IMPLEMENTATION
Alias: None
Product: OE-Core
Classification: Build System, Metadata & Runtime
Component: core (show other bugs)
Version: 3.1.3
Hardware: x86 Multiple
: Medium+ major
Target Milestone: 6.2 M1
Assignee: Unassigned
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2020-08-23 15:21 UTC by Pascal Bach
Modified: 2026-10-01 17:48 UTC (History)
11 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments
dunfell: search and populate files in multilib manifest file (2.38 KB, patch)
2026-09-26 18:01 UTC, Jagadeesh Krishnanjanappa
no flags Details | Diff
master: search and populate files in multilib manifest file (4.28 KB, patch)
2026-09-26 18:02 UTC, Jagadeesh Krishnanjanappa
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Pascal Bach 2020-08-23 15:21:14 UTC
When building a multilib eSDK only the "default" environment-setup file works.
The secondary one can't compile any C++ code as it is missing some essential libraries and headers.


# Steps to reproduce:

1. Build a an eSDK  with multilib support (as described in the Manual):

MACHINE = "qemux86-64"
require conf/multilib.conf
MULTILIBS = "multilib:lib32"
DEFAULTTUNE_virtclass-multilib-lib32 = "x86"

2. Install the corresponding eSDK

It prints an info to source on of two toolchains:

 $ . /home/poky_esdk/environment-setup-core2-64-poky-linux
 $ . /home/poky_esdk/environment-setup-x86-pokymllib32-linux

3. Sourcing the toolchain


. /home/poky_esdk/environment-setup-core2-64-poky-linux => works and can compile

. /home/poky_esdk/environment-setup-x86-pokymllib32-linux => doesn't work as it can not find some headers (e.g. c++config.h) and libraries (e.g. gcc_s).
Comment 1 Randy MacLeod 2020-08-27 07:39:02 UTC
Robert, This seems like something that we should fix. Can you work on it/
Comment 2 Mark Hatle 2020-08-27 07:53:55 UTC
Check that this is not a compiler bug.  Look at the path the compiler is using to try to get to the files that are listed as missing.

In the past, I saw a similar bug (specific to C++ libraries) and it turns out that multilib settings within the compiler itself was breaking the path structure for C++.

Once the multilib "hack" was put into place, it resolved the problem.

The hack is located here:

https://git.openembedded.org/openembedded-core/tree/meta/recipes-devtools/gcc/gcc/0004-64-bit-multilib-hack.patch

Note, that it only covers the four main architectures.  If you are building something else -- or somehow this file wasn't included you will get C++ (and possibly other) failures.
Comment 3 Jeremy A. Puhlman 2020-08-27 12:23:29 UTC
Mark, I actually don't think that is likely the case here. Building the standard sdk works fine for multilib with the same image(I included something to drag in 32bit libstdc++), but fails with the same image target with extensible sdk.

[jp@localhost mulitlib-sdk]$ rm -rf foo; ./tmp/deploy/sdk/poky-glibc-x86_64-core-image-minimal-core2-64-qemux86-64-toolchain-3.1+snapshot.sh -d `pwd`/foo -y
Poky (Yocto Project Reference Distro) SDK installer version 3.1+snapshot
========================================================================
You are about to install the SDK to "/home/jp/master/mulitlib-sdk/foo". Proceed [Y/n]? Y
Extracting SDK...........................................................done
Setting it up...done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /home/jp/master/mulitlib-sdk/foo/environment-setup-core2-64-poky-linux
 $ . /home/jp/master/mulitlib-sdk/foo/environment-setup-x86-pokymllib32-linux
[jp@localhost mulitlib-sdk]$ bash
[jp@localhost mulitlib-sdk]$ source /home/jp/master/mulitlib-sdk/foo/environment-setup-x86-pokymllib32-linux
[jp@localhost mulitlib-sdk]$ $CXX foo.cpp -O2
[jp@localhost mulitlib-sdk]$


[jp@localhost mulitlib-sdk]$ rm -rf foo; ./tmp/deploy/sdk/poky-glibc-x86_64-core-image-minimal-core2-64-qemux86-64-toolchain-ext-3.1+snapshot.sh -d `pwd`/foo -y
Poky (Yocto Project Reference Distro) Extensible SDK installer version 3.1+snapshot
===================================================================================
You are about to install the SDK to "/home/jp/master/mulitlib-sdk/foo". Proceed [Y/n]? Y
Extracting SDK..............................................................................................done
Setting it up...
Extracting buildtools...
Preparing build system...
Loading cache: 100% |                                                                                                                    | ETA:  --:--:--
Parsing recipes: 100% |###################################################################################################################| Time: 0:00:29
Initialising tasks: 100% |################################################################################################################| Time: 0:00:03
Checking sstate mirror object availability: 100% |########################################################################################| Time: 0:00:00
Loading cache: 100% |#####################################################################################################################| Time: 0:00:00
Initialising tasks: 100% |################################################################################################################| Time: 0:00:00
done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /home/jp/master/mulitlib-sdk/foo/environment-setup-core2-64-poky-linux
 $ . /home/jp/master/mulitlib-sdk/foo/environment-setup-x86-pokymllib32-linux
[jp@localhost mulitlib-sdk]$ bash
[jp@localhost mulitlib-sdk]$ source /home/jp/master/mulitlib-sdk/foo/environment-setup-x86-pokymllib32-linux
[jp@localhost mulitlib-sdk]$ $CXX foo.cpp -O2
In file included from foo.cpp:1:
/home/jp/master/mulitlib-sdk/foo/tmp/sysroots/qemux86-64/usr/include/c++/10.2.0/iostream:38:10: fatal error: bits/c++config.h: No such file or directory
   38 | #include <bits/c++config.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.


No difference in the image itself.
Comment 4 Robert Yang 2020-09-11 01:11:24 UTC
Maybe it is because oe-core missed the following patch, I had sent it oe-core years ago, but didn't get merged:

  git://git.openembedded.org/openembedded-core-contrib rbt/multilib_esdk
  http://cgit.openembedded.org/openembedded-core-contrib/log/?h=rbt/multilib_esdk

Robert Yang (1):
  populate_sdk_ext.bbclass: fix for multilib


I will resend it, but it would be great if Pascal Bach and Jeremy A. Puhlman  can help verify it.
Comment 5 Pascal Bach 2020-09-28 02:19:44 UTC
I tried to verify the patch proposed by Robert Yang. And it doesn't solve the issue.

When I try to compile there are still some files missing.

Namely:
- libgcc_s.so
- libgcc.a 
- crti.o

From what I can tell these files are provided by the following packages:

- lib32-gcc-runtime
- lib32-glibc
- lib32-libgcc

I tried adding them to
SDK_DEPENDS_append = " lib32-gcc-runtime lib32-glibc lib32-libgcc"

But it doesn't seem to have any effect.
Comment 6 Pascal Bach 2020-09-28 11:44:48 UTC
I currently suspect that the issue is with the "build-sysroots" recipe as it does not seem to be including any of the lib32 packages.

Manually hacking "x86" in https://github.com/openembedded/openembedded-core/blob/master/meta/classes/staging.bbclass#L194 seems to make it include the lib32 packages in tmp/sysroots/qemux86-64.

But the resulting eSDK can't be installed as it throws some hash miss match errors.

So I think there are still some parts in that area that don't handle multilib properly.
Comment 7 Randy MacLeod 2023-07-26 21:21:56 UTC
Bulk move of 64 bugs to 4.3 M3 after a quick review.
If a bug is actually fixed, please add a commit link and resolve it.
-- Randy for YP bug team.
Comment 8 Trevor Gamblin 2023-09-14 16:37:00 UTC
Moved to M4.
Comment 9 Randy MacLeod 2023-10-30 15:29:12 UTC
Bulk move to 5.0 M1. -- Randy
Comment 10 Randy MacLeod 2023-12-21 23:28:26 UTC
Bulk move of 52 5.0-M1 bugs to M2.
Comment 11 Randy MacLeod 2024-01-25 14:28:51 UTC
Bulk move of bugs owned by "unassigned" from 5.0-M2 to 5.0-M3.
Comment 12 Randy MacLeod 2024-02-22 19:53:19 UTC
Bulk move of bugs from 5.0-M3 to 5.99.
The bugs in this list are all unassigned and are ones that I consider to be nice to do some time but not essential track from milestone to milestone in 5.0 or 5.1. We agreed on this bug handling approach in the YP bug review on Feb 22, 2024.

If you disagree, please move back to a 5.[012...]-M* milestone.
Comment 13 Randy MacLeod 2026-03-18 21:48:28 UTC
Doing old bug triage so just skimming.

Sundeep, 

Please have someone take a look at this bug report in the coming month.
Is it still a problem? 

Pascal,
Any news on this issue ?
Comment 14 Jagadeesh Krishnanjanappa 2026-09-26 18:01:57 UTC
Created attachment 5247 [details]
dunfell: search and populate files in multilib manifest file
Comment 15 Jagadeesh Krishnanjanappa 2026-09-26 18:02:26 UTC
Created attachment 5248 [details]
master: search and populate files in multilib manifest file
Comment 16 Jagadeesh Krishnanjanappa 2026-09-26 18:09:42 UTC
The missing header file (bits/c++config.h) is given by gcc-runtime recipe.
During the installing of eSDK, this file is populated
into the <eSDK_install_directory>/tmp/sysroots by the staging_populate_sysroot_dir function
by parsing SSTATE_MANFILEPREFIX file (i.e <esdk_installed_directory>/tmp/sstate-control/manifest-<pkgarch>-[lib32-]gcc-runtime.populate_sysroot ) under the directories listed by <pkgarch>. But the multilib-DEFAULTTUNE (i.e 'x86' in case of qemux86-64) is not part of
<pkgarch> of staging_populate_sysroot_dir function, hence the <esdk_installed_directory>/tmp/sstate-control/manifest-x86-lib32-gcc-runtime.populate_sysroot file is not parsed and
the files of lib32-gcc-runtime which are supposed to be populated under <eSDK_install_directory>/tmp/sysroots directory are absent.

Adding multilib-DEFAULTTUNE (i.e 'x86' in case of qemux86-64) as part of
<pkgarch> in staging_populate_sysroot_dir function solves the issue for dunfell.


On master branch, the eSDK does not install the multilib BASEDEPENDS i.e
virtual/lib32-cross-cc, virtual/lib32-compilerlibs, and virtual/lib32-libc even though the multilib configuration is enabled in the conf/local.conf. Due
to this we cannot compile source for multilib using the eSDK.
This patch adds dependency on multilib BASEDEPENDS in meta-extsdk-toolchain recipe if multilib configuration is enabled in the conf/local.conf.


The patches attachment 5247 [details] and attachment 5248 [details] are tested on dunfell and master. Below are the logs.

With Dunfell:
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ sh tmp/deploy/sdk/poky-glibc-x86_64-core-image-minimal-core2-64-qemux86-64-toolchain-ext-3.1.33.sh -d $PWD/sdk -y
Poky (Yocto Project Reference Distro) Extensible SDK installer version 3.1.33
=============================================================================
You are about to install the SDK to "/home/matti/work_jagadeesh/new_project/poky/build/sdk". Proceed [Y/n]? Y
Extracting SDK.................................................................................done
Setting it up...
Extracting buildtools...
Preparing build system...
WARNING: Host distribution "debian-12" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Parsing recipes: 100% |########################################################| Time: 0:00:04
Initialising tasks: 100% |#####################################################| Time: 0:01:22
Checking sstate mirror object availability: 100% |#############################| Time: 0:00:16
WARNING: Host distribution "debian-12" has not been validated with this version of the build system; you may possibly experience unexpected failures. It is recommended that you use a tested distribution.
Loading cache: 100% |##########################################################| Time: 0:00:38
Initialising tasks: 100% |#####################################################| Time: 0:00:00
done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /home/matti/work_jagadeesh/new_project/poky/build/sdk/environment-setup-core2-64-poky-linux
 $ . /home/matti/work_jagadeesh/new_project/poky/build/sdk/environment-setup-x86-pokymllib32-linux
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ . /home/matti/work_jagadeesh/new_project/poky/build/sdk/environment-setup-x86-pokymllib32-linux
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ cat foo.cpp
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ echo $CXX
i686-pokymllib32-linux-g++ -m32 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/matti/work_jagadeesh/new_project/poky/build/sdk/tmp/sysroots/qemux86-64
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ $CXX foo.cpp -O2 -o foo_32
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ file foo_32
foo_32: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux.so.2, BuildID[sha1]=9f06fc5d0b2abf2d954336f884e4888a20174b71, for GNU/Linux 3.2.0, with debug_info, not stripped
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ . /home/matti/work_jagadeesh/new_project/poky/build/sdk/environment-setup-core2-64-poky-linux
SDK environment now set up; additionally you may now run devtool to perform development tasks.
Run devtool --help for further details.
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ echo $CXX
x86_64-poky-linux-g++ -m64 -march=core2 -mtune=core2 -msse3 -mfpmath=sse -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/matti/work_jagadeesh/new_project/poky/build/sdk/tmp/sysroots/qemux86-64
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ $CXX foo.cpp -O2 -o foo_64
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$ file foo_64
foo_64: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/ld-linux-x86-64.so.2, BuildID[sha1]=3eede75c97eafd7f7bba6540f41dab71a27bb9d9, for GNU/Linux 3.2.0, with debug_info, not stripped
matti@cfarm422:~/work_jagadeesh/new_project/poky/build$
------------------------------------------------------------------

With master:
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ sh tmp/deploy/sdk/oecore-core-image-minimal-x86_64-x86-64-v3-qemux86-64-toolchain-ext-nodistro.0.sh -d $PWD/SDK -y
OpenEmbedded Extensible SDK installer version nodistro.0
========================================================
You are about to install the SDK to "/home/matti/work_jagadeesh/bitbake-builds/layers/openembedded-core/build/SDK". Proceed [Y/n]? Y
Extracting SDK..................................................................................................................................................................................done
Setting it up...
Extracting buildtools...
Preparing build system...
Loading cache: 100% |##########################################################| Time: 0:00:00
Parsing recipes: 100% |########################################################| Time: 0:00:21
Initialising tasks: 100% |#####################################################| Time: 0:00:11
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)... (17:26:31.173136)
Loading cache: 100% |##########################################################| Time: 0:00:00
Parsing recipes: 100% |########################################################| Time: 0:00:22
Initialising tasks: 100% |#####################################################| Time: 0:00:00
NOTE: Reconnecting to bitbake server...
NOTE: Retrying server connection (#1)... (17:27:01.199103)
Loading cache: 100% |##########################################################| Time: 0:00:02
Initialising tasks: 100% |#####################################################| Time: 0:00:00
done
SDK has been successfully set up and is ready to be used.
Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g.
 $ . /home/matti/work_jagadeesh/bitbake-builds/layers/openembedded-core/build/SDK/environment-setup-x86-64-v3-oe-linux
 $ . /home/matti/work_jagadeesh/bitbake-builds/layers/openembedded-core/build/SDK/environment-setup-x86-oemllib32-linux
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ . /home/matti/work_jagadeesh/bitbake-builds/layers/openembedded-core/build/SDK/environment-setup-x86-oemllib32-linux
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ cat foo.cpp
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ echo $CXX
i686-oemllib32-linux-g++ -m32 -D_TIME_BITS=64 -D_FILE_OFFSET_BITS=64 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/matti/work_jagadeesh/bitbake-builds/layers/openembedded-core/build/SDK/tmp/sysroots/qemux86-64
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ $CXX foo.cpp -O2 -o foo_32
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ file foo_32
foo_32: ELF 32-bit LSB pie executable, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /usr/lib/ld-linux.so.2, BuildID[sha1]=fdb221cf159085ac73f362090076aeb4a89e22b6, for GNU/Linux 5.15.0, with debug_info, not stripped
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ . /home/matti/work_jagadeesh/bitbake-builds/layers/openembedded-core/build/SDK/environment-setup-x86-64-v3-oe-linux
SDK environment now set up; additionally you may now run devtool to perform development tasks.
Run devtool --help for further details.
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ echo $CXX      x86_64-oe-linux-g++ -m64 -march=x86-64-v3 -fstack-protector-strong -O2 -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/matti/work_jagadeesh/bitbake-builds/layers/openembedded-core/build/SDK/tmp/sysroots/qemux86-64
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ $CXX foo.cpp -O2 -o foo_64
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$ file foo_64    foo_64: ELF 64-bit LSB pie executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /usr/lib64/ld-linux-x86-64.so.2, BuildID[sha1]=6441d615e59f58032a6cf5c0bdc00339150efeb5, for GNU/Linux 5.15.0, with debug_info, not stripped
matti@cfarm422:~/work_jagadeesh/bitbake-builds/layers/openembedded-core/build$
---

Regards,
Jagadeesh
Comment 17 Jagadeesh Krishnanjanappa 2026-10-01 01:22:29 UTC
Any suggestions/feedbacks on the patches?
Can I submit the patches for review and merge?

Thanks,
Jagadeesh
Comment 18 Randy MacLeod 2026-10-01 13:55:44 UTC
Jagadeesh, 
I moved to the milestone 6.2-M1 since we would want a change like this to 
soak in the dev tree before possibly being backported.

Please do post to the list since that's where code review takes place.
This will also result in your patch being run in the YP AB which
frequently helps to identify deficiencies.

../Randy
Comment 19 Jagadeesh Krishnanjanappa 2026-10-01 17:48:34 UTC
(In reply to Randy MacLeod from comment #18)
> Jagadeesh, 
> I moved to the milestone 6.2-M1 since we would want a change like this to 
> soak in the dev tree before possibly being backported.
> 
> Please do post to the list since that's where code review takes place.
> This will also result in your patch being run in the YP AB which
> frequently helps to identify deficiencies.
> 
> ../Randy

I have submitted the patches for review in the mailing list at

https://lists.openembedded.org/g/openembedded-core/topic/121532867
https://lists.openembedded.org/g/openembedded-core/topic/121532869
https://lists.openembedded.org/g/openembedded-core/topic/121532871

Thanks,
Jagadeesh