From: Richard Purdie Date: Wed, 14 May 2025 14:29:16 +0000 (+0100) Subject: gcc: Fix riscv multilib issues in plain toolchains X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3081f62c18fcee642ab43efa717c8f71d51ae587;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git gcc: Fix riscv multilib issues in plain toolchains RISC-V multilib currently doesn't work at all. We could disable multilib for the riscv platform but that would then behave differently to all our others. Instead, copy the non-multilib config over the multilib config for now for riscv, meaning we can keep the platforms similar. This isn't quite enough as the triplet specific c++ headers are in the wrong place leading to compiler issues and testimage failures. Work around that too until someone adds full multilib support for the platform (if desired). Signed-off-by: Richard Purdie --- diff --git a/meta/recipes-devtools/gcc/gcc-multilib-config.inc b/meta/recipes-devtools/gcc/gcc-multilib-config.inc index 2dbbc23c94..d9959364c3 100644 --- a/meta/recipes-devtools/gcc/gcc-multilib-config.inc +++ b/meta/recipes-devtools/gcc/gcc-multilib-config.inc @@ -34,6 +34,7 @@ python gcc_multilib_setup() { '%s/aarch64/aarch64-linux.h' % src_conf_dir, '%s/aarch64/aarch64-cores.def' % src_conf_dir, '%s/arm/linux-eabi.h' % src_conf_dir, + '%s/riscv/t-linux*' % src_conf_dir, '%s/*/linux.h' % src_conf_dir, '%s/linux.h' % src_conf_dir) @@ -45,6 +46,9 @@ python gcc_multilib_setup() { bb.utils.mkdirhier('%s/%s' % (build_conf_dir, parent_dir)) bb.utils.copyfile(fn, '%s/%s' % (build_conf_dir, rel_path)) + # For now, force the riscv multilib view to our own meaning we can always enable multilib + bb.utils.copyfile('%s/riscv/t-linux' % src_conf_dir, '%s/riscv/t-linux-multilib' % build_conf_dir) + pn = d.getVar('PN') multilibs = (d.getVar('MULTILIB_VARIANTS') or '').split() if not multilibs and pn != "nativesdk-gcc": @@ -145,6 +149,7 @@ python gcc_multilib_setup() { 'i686' : ['gcc/config/i386/t-linux64'], 'mips' : ['gcc/config/mips/t-linux64'], 'mips64' : ['gcc/config/mips/t-linux64'], + 'riscv64' : ['gcc/config/riscv/t-linux-multilib'], 'powerpc' : ['gcc/config/rs6000/t-linux64'], 'powerpc64' : ['gcc/config/rs6000/t-linux64'], 'aarch64' : ['gcc/config/aarch64/t-aarch64'], @@ -161,6 +166,7 @@ python gcc_multilib_setup() { 'powerpc64' : ['gcc/config/linux.h', 'gcc/config/rs6000/linux64.h'], 'aarch64' : ['gcc/config/linux.h', 'gcc/config/aarch64/aarch64-linux.h', 'gcc/config/arm/linux-eabi.h'], 'arm' : ['gcc/config/linux.h', 'gcc/config/aarch64/aarch64-linux.h', 'gcc/config/arm/linux-eabi.h'], + 'riscv64' : ['gcc/config/linux.h'], } libdir32 = 'SYSTEMLIBS_DIR' diff --git a/meta/recipes-devtools/gcc/gcc-runtime.inc b/meta/recipes-devtools/gcc/gcc-runtime.inc index afcc13a310..fe1f43b2fd 100644 --- a/meta/recipes-devtools/gcc/gcc-runtime.inc +++ b/meta/recipes-devtools/gcc/gcc-runtime.inc @@ -144,6 +144,11 @@ do_install:append:class-target () { ln -sf ../${X86ARCH32}${TARGET_VENDOR}-${TARGET_OS} ${D}${includedir}/c++/${BINV}/${TARGET_ARCH}${TARGET_VENDOR}-${TARGET_OS}/32 fi + if [ "${TARGET_ARCH}" = "riscv64" -a "${MULTILIB_VARIANTS}" = "" ]; then + mv ${D}${includedir}/c++/${BINV}/${TARGET_SYS}/bits/* ${D}${includedir}/c++/${BINV}/bits + mv ${D}${includedir}/c++/${BINV}/${TARGET_SYS}/ext/* ${D}${includedir}/c++/${BINV}/ext + fi + if [ "${TCLIBC}" != "glibc" ]; then case "${TARGET_OS}" in "linux-musl" | "linux-*spe") extra_target_os="linux";;