From 83d2e5923b7a1d109479822de1c2ae0ea9c80187 Mon Sep 17 00:00:00 2001 From: Alexander Barker Date: Tue, 12 May 2026 09:32:47 -0700 Subject: [PATCH 1/3] sys-devel/crossdev forces multilib for arm toolchains Add support for more specific arm toolchain tripples allowing for USE=-multilib in some scenarios Closes: https://bugs.gentoo.org/868636 Signed-off-by: Alexander Barker (https://github.com/kwhat) --- .github/workflows/crossdev.yml | 16 +++++++++++++ crossdev | 42 +++++++++++++--------------------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/.github/workflows/crossdev.yml b/.github/workflows/crossdev.yml index 044beba..a6e839b 100644 --- a/.github/workflows/crossdev.yml +++ b/.github/workflows/crossdev.yml @@ -189,6 +189,22 @@ jobs: args: --skip-system gcc: true llvm: false + - target: armv4-none-eabisf + args: --skip-system + gcc: true + llvm: false + - target: armv5tej-none-eabisf + args: --skip-system + gcc: true + llvm: false + - target: armv6j-none-eabihf + args: --skip-system + gcc: true + llvm: false + - target: armv7a-none-eabi + args: --skip-system + gcc: true + llvm: false - target: avr args: --skip-system gcc: true diff --git a/crossdev b/crossdev index 25dea3f..93cae96 100755 --- a/crossdev +++ b/crossdev @@ -273,7 +273,7 @@ parse_target() { KPKG="[none]" LCAT="dev-embedded" LPKG="avr-libc" GUSE+=" -openmp -fortran -go" # doesn't work - MULTILIB_USE="yes" #377039 + MULTILIB_USE="yes" # avr requires multilib, that provides libgcc for all sub-architectures #378387, #377039 BUSE+=" cxx" WITH_DEF_HEADERS="no" ;; @@ -342,7 +342,8 @@ parse_target() { # for that. GUSE+=" zlib zstd" - # We need multilib for openmp to be built w/ -mgomp + # We need multilib for openmp to be built w/ -mgomp + # https://gcc.gnu.org/legacy-ml/gcc-help/2020-01/msg00106.html MULTILIB_USE="yes" WITH_DEF_HEADERS="no" ;; @@ -367,6 +368,7 @@ parse_target() { GUSE+=" zlib zstd" # We need multilib for openmp to be built w/ -mgomp + # https://gcc.gnu.org/legacy-ml/gcc-help/2020-01/msg00106.html MULTILIB_USE="yes" WITH_DEF_HEADERS="no" ;; @@ -446,7 +448,7 @@ parse_target() { ;; # Bare metal targets - *-newlib|*-elf|*-eabi|*-rtems*) + *-newlib|*-elf|*-eabi*|*-rtems*) LPKG="newlib" KPKG="[none]" GMASK+=" default-stack-clash-protection hardened ssp" @@ -454,7 +456,9 @@ parse_target() { GUSE+=" -fortran" #589672, needs syscalls GUSE+=" -hardened" #687598, needs -fstack-check=specific support GUSE+=" -default-stack-clash-protection -ssp" # SSP isn't supported for freestanding anyway - MULTILIB_USE="yes" #407275 + + [[ "$CTARGET" != armv*-eabi[hs]f ]] \ + && MULTILIB_USE="yes" #868636, #407275 WITH_DEF_HEADERS="no" ;; @@ -546,7 +550,7 @@ parse_target() { mingw*|*-mingw*) pie_support=no ;; # Many bare-metal targets don't work with pie as-is - *-elf|*-eabi) + *-elf|*-eabi*) # mips can't generate freestanding PIC: # cc1: error: position-independent code requires ‘-mabicalls’ # arm firmware packages don't expect pie-by-default: @@ -1528,27 +1532,12 @@ set_portage() { [[ ${pkg} == "[none]" ]] && return 0 - case ${CTARGET} in - # avr requires multilib, that provides - # libgcc for all sub-architectures #378387 - avr*) - mask+=" -multilib" - force+=" multilib" - ;; - accel-nvptx*|nvptx*|*-newlib|*-elf|*-eabi) - # nvptx: needs multilib because of https://gcc.gnu.org/legacy-ml/gcc-help/2020-01/msg00106.html. - mask+=" -multilib" - force+=" multilib" - ;; - *) - if [[ ${MULTILIB_USE} == "yes" ]] ; then - mask+=" -multilib" - force+=" multilib" - else - mask+=" multilib" - fi - ;; - esac + if [[ ${MULTILIB_USE} == "yes" ]]; then + mask+=" -multilib" + force+=" multilib" + else + mask+=" multilib" + fi set_use_mask ${pkg} "${mask}" set_use_force ${pkg} "${force}" @@ -1840,6 +1829,7 @@ doemerge() { [[ ${pn} == "[none]" ]] && return 0 + # MULTILIB_USE could be overriden at runtime set_use ${pn} ${USE} $( [[ ${MULTILIB_USE} == "no" ]] && echo - )multilib [[ ${INIT_TARGET_ONLY} == "yes" ]] && return 0 From aa29694e3e4f2934cf13f24855acb9b2bc3c26a8 Mon Sep 17 00:00:00 2001 From: Alexander Barker Date: Wed, 27 May 2026 16:45:59 -0700 Subject: [PATCH 2/3] Adding support for targets like armv6m-none-eabi that do not have an FPU but can be built with --disable-multilib. I'm not sure how much other than != armv*-eabi* should be multilib. There is likely armv* and maybe things like riscv64-rtems6? --- crossdev | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crossdev b/crossdev index 93cae96..fa29552 100755 --- a/crossdev +++ b/crossdev @@ -457,7 +457,7 @@ parse_target() { GUSE+=" -hardened" #687598, needs -fstack-check=specific support GUSE+=" -default-stack-clash-protection -ssp" # SSP isn't supported for freestanding anyway - [[ "$CTARGET" != armv*-eabi[hs]f ]] \ + [[ "$CTARGET" != armv*-eabi* ]] \ && MULTILIB_USE="yes" #868636, #407275 WITH_DEF_HEADERS="no" ;; From 9f9db562147b93a6ef41b8db5c7f555e0b5319fc Mon Sep 17 00:00:00 2001 From: Alexander Barker Date: Wed, 27 May 2026 20:35:58 -0700 Subject: [PATCH 3/3] Adding support for all the individual non-multilib arm targets I can come up with. I hav eno idea how to test this without making an operations engeineer at microsoft cry. --- .github/workflows/crossdev.yml | 114 ++++++++++++++++++++++++++++++--- scripts/container_test.sh | 8 +++ 2 files changed, 114 insertions(+), 8 deletions(-) diff --git a/.github/workflows/crossdev.yml b/.github/workflows/crossdev.yml index a6e839b..e0b05b9 100644 --- a/.github/workflows/crossdev.yml +++ b/.github/workflows/crossdev.yml @@ -184,27 +184,125 @@ jobs: - target: x86_64-unknown-linux-musl gcc: true llvm: true - # Embedded or otherwise special targets + # Arm multilib target - target: arm-none-eabi args: --skip-system gcc: true llvm: false - - target: armv4-none-eabisf - args: --skip-system + # Cortex-M / ARMv6-M → ARMv8.1-M non-multilib targets + - target: armv6m-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv6s-m --with-mode=thumb --with-float=soft"' gcc: true llvm: false - - target: armv5tej-none-eabisf - args: --skip-system + - target: armv7m-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7-m --with-mode=thumb --with-float=soft"' gcc: true llvm: false - - target: armv6j-none-eabihf - args: --skip-system + - target: armv7em-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7e-m --with-mode=thumb --with-float=soft"' gcc: true llvm: false + - target: armv7em-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7e-m --with-mode=thumb --with-fpu=fpv4-sp-d16 --with-float=hard"' + gcc: true + llvm: false + - target: armv7em-none-eabisf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7e-m --with-mode=thumb --with-fpu=fpv4-sp-d16 --with-float=softfp"' + gcc: true + llvm: false + - target: armv8m.base-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8-m.base --with-mode=thumb --with-float=soft"' + gcc: true + llvm: false + - target: armv8m.main-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8-m.main --with-mode=thumb --with-float=soft"' + gcc: true + llvm: false + - target: armv8m.main-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8-m.main --with-mode=thumb --with-fpu=fpv5-sp-d16 --with-float=hard"' + gcc: true + llvm: false + - target: armv8m.main-none-eabisf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8-m.main --with-mode=thumb --with-fpu=fpv5-sp-d16 --with-float=softfp"' + gcc: true + llvm: false + - target: armv8.1m.main-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8.1-m.main+pacbti --with-mode=thumb --with-float=soft"' + gcc: true + llvm: false + - target: armv8.1m.main-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8.1-m.main+mve --with-mode=thumb --with-float=hard"' + gcc: true + llvm: false + - target: armv8.1m.main-none-eabisf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8.1-m.main+pacbti+fp --with-mode=thumb --with-float=softfp"' + gcc: true + llvm: false + ## Cortex-A / ARMv7-A, ARMv7-R, ARMv8-A non-multilib targets - target: armv7a-none-eabi - args: --skip-system + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7-a --with-mode=thumb --with-float=soft"' + gcc: true + llvm: false + - target: armv7a-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7-a --with-mode=thumb --with-fpu=vfpv3-d16 --with-float=hard"' gcc: true llvm: false + - target: armv7a-none-eabisf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7-a --with-mode=thumb --with-fpu=vfpv3-d16 --with-float=softfp"' + gcc: true + llvm: false + - target: armv7ve-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7ve --with-mode=thumb --with-fpu=neon-vfpv4 --with-float=hard"' + gcc: true + llvm: false + - target: armv7ve-none-eabisf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7ve --with-mode=thumb --with-fpu=neon-vfpv4 --with-float=softfp"' + gcc: true + llvm: false + - target: armv7r-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7-r --with-mode=thumb --with-fpu=vfpv3xd --with-float=hard"' + gcc: true + llvm: false + - target: armv7r-none-eabisf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7-r --with-mode=thumb --with-fpu=vfpv3xd --with-float=softfp"' + gcc: true + llvm: false + - target: armv8a-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8-a --with-mode=thumb --with-float=soft"' + gcc: true + llvm: false + - target: armv8a-none-eabisf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8-a --with-mode=thumb --with-fpu=neon-fp-armv8 --with-float=softfp"' + gcc: true + llvm: false + - target: armv8a-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv8-a --with-mode=thumb --with-fpu=neon-fp-armv8 --with-float=hard"' + gcc: true + llvm: false + ## Generic / ARMv5TE / ARMv7 + # FIXME I should be able to build this, but we cant determine multilib from the tripple. It would require a + # flag like --no-multilib or mabye --env 'MULTILIB_USE="no"'? + #- target: arm-none-eabi + # args: --skip-system --env 'EXTRA_ECONF="--disable-multilib --with-mode=thumb --with-float=soft"' + # gcc: true + # llvm: false + - target: armv7-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7 --with-mode=thumb --with-float=soft"' + gcc: true + llvm: false + - target: armv7-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv7 --with-mode=thumb --with-fpu=vfpv3-d16 --with-float=hard"' + gcc: true + llvm: false + - target: armv5te-none-eabi + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv5te --with-mode=arm --with-fpu=vfpv2 --with-float=softfp"' + gcc: true + llvm: false + - target: armv5te-none-eabihf + args: --skip-system --env 'EXTRA_ECONF="--with-arch=armv5te --with-mode=arm --with-fpu=vfpv2 --with-float=hard"' + gcc: true + llvm: false + # Embedded or otherwise special targets - target: avr args: --skip-system gcc: true diff --git a/scripts/container_test.sh b/scripts/container_test.sh index 4941a50..74af1c2 100755 --- a/scripts/container_test.sh +++ b/scripts/container_test.sh @@ -6,6 +6,7 @@ print_help() { echo "Usage: $0 [OPTIONS] Options: + --env Specify env settings for binutils/gdb/gcc/kernel/libc. --llvm Use LLVM/Clang as a cross compiler --skip-system Skip emerging the @system set after setting up crossdev. --tag Specify the container tag to use. Default is 'latest'. @@ -67,6 +68,10 @@ while [[ $# -gt 0 ]]; do print_help exit 0 ;; + --env) + ENV_SETTINGS="$2" + shift 2 + ;; --llvm) USE_LLVM=1 shift 1 @@ -99,6 +104,9 @@ EXTRA_ARGS=() if [[ "${USE_LLVM}" -eq 1 ]]; then EXTRA_ARGS+="--llvm" fi +if [[ -v ENV_SETTINGS ]]; then + EXTRA_ARGS+=("--env" "${ENV_SETTINGS}") +fi "${CONTAINER_ENGINE}" run -d \ --pull always \