@@ -15,6 +15,11 @@ EAT_TARGET_SYS:aarch64 ?= "${@ 'aarch64-none-linux-gnu' if os.path.exists('${EXT
EAT_TARGET_SYS = "${TARGET_SYS}"
TARGET_PREFIX = "${EAT_TARGET_SYS}-"
+EXTERNAL_TOOLCHAIN_LIBDIR = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', '/usr/lib', '/lib', d)}"
+EXTERNAL_TOOLCHAIN_DYN_LINKER_PATH:arm ?= " -Wl,--dynamic-linker=${EXTERNAL_TOOLCHAIN_LIBDIR}/ld-linux-armhf.so.3"
+EXTERNAL_TOOLCHAIN_DYN_LINKER_PATH:aarch64 ?= " -Wl,--dynamic-linker=${EXTERNAL_TOOLCHAIN_LIBDIR}/ld-linux-aarch64.so.1"
+TARGET_LDFLAGS:append:class-target = "${EXTERNAL_TOOLCHAIN_DYN_LINKER_PATH}"
+
EAT_LIBDIR:arm = "lib"
EAT_LIBDIR:aarch64 = "lib64"
usrmerge nowaday required by systemd [1] but it broke external-arm-toolchain in several ways... When usrmerge is enabled, /lib is no longer part of SYSROOT_DIRS list while the prebuilt toolchain expect the dynamic loader to be placed in /lib not /usr/lib. There is no /lib directory in the per-package sysroot directory generated to build each package: [...]/build/tmp/sysroots-components/<target>/<package>/ sysroot-providers/ usr/ But the cross-compiler still generate binaries with dynamic loarder path set to "/lib/ld-linux-<target>.so*" strings sanitycheckc_cross.exe | grep ld /lib/ld-linux-aarch64.so.1 A symlink /lib -> /usr/lib is crated in the final rootfs image. But this broke the meson-qemuwrapper used when "qemu-usermode" (MACHINE_FEATURES) is available: See [2]: do_write_config:append:class-target() { # Write out a qemu wrapper that will be used as exe_wrapper so that meson # can run target helper binaries through that. qemu_binary="${@qemu_wrapper_cmdline(d, '$STAGING_DIR_HOST', ['$STAGING_DIR_HOST/${libdir}','$STAGING_DIR_HOST/${base_libdir}'])}" It produce a runtime issue while running a meson sanity check: meson-qemuwrapper [...]/build/meson-private/sanitycheckc_cross.exe qemu-aarch64: Could not open '/lib/ld-linux-aarch64.so.1': No such file or directory Note: The binaries build by the Yocto internal toolchain seems be "patched" [3] to look at /usr/lib instead of /lib. We use -Wl,--dynamic-linker to make sure that the cross-compiler generate binaries using the dynamic loader path defined by usrmerge for all packages build by Yocto. [1] https://git.openembedded.org/openembedded-core/commit/?id=802e853eeddf16d73db1900546cc5f045d1fb7ed [2] https://git.openembedded.org/openembedded-core/tree/meta/classes-recipe/meson.bbclass?h=2024-04.3-scarthgap#n130 [3] https://github.com/openembedded/openembedded-core/blob/scarthgap/meta/recipes-devtools/gcc/gcc/0007-Define-GLIBC_DYNAMIC_LINKER-and-UCLIBC_DYNAMIC_LINKE.patch Signed-off-by: Romain Naour <romain.naour@smile.fr> --- .../conf/distro/include/tcmode-external-arm.inc | 5 +++++ 1 file changed, 5 insertions(+)