commit:     e61ffcd622d34570b294e7f4a3e922bdc980cd65
Author:     Marek BehĂșn <kabel <AT> kernel <DOT> org>
AuthorDate: Thu Aug 18 18:01:58 2022 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Aug 23 05:23:56 2022 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e61ffcd6

toolchain.eclass: build multilibs for ARM's A, R and M architecture profiles

For ARM targets, with USE=multilib and with CTARGET that does not imply
any of --with-arch, --with-cpu, --with-mode or --with-float options to
gcc's configuration (when arm_arch=arm), pass option
--with-multilib-list=aprofile,rmprofile to gcc's configuration to make
it build multilibs for A, R and M architecture profiles.

This makes it possible to have one compiler capable of generating
correct code (linking correct libgcc/CRT) for various ARM targets: from
armv6 to armv7, for both soft float and half float, for various FPU
types.

Example of arm-none-eabi-gcc -print-libgcc-file-name output for various
options:
  default:
    /usr/lib/gcc/arm-none-eabi/12.1.1/libgcc.a
  -mcpu=cortex-m0
    /usr/lib/gcc/arm-none-eabi/12.1.1/thumb/v6-m/nofp/libgcc.a
  -march=armv7-m
    /usr/lib/gcc/arm-none-eabi/12.1.1/thumb/v7-m/nofp/libgcc.a
  -march=armv7-a
    /usr/lib/gcc/arm-none-eabi/12.1.1/thumb/v7-a/nofp/libgcc.a
  -march=armv7-a -mhard-float -mfpu=neon
    /usr/lib/gcc/arm-none-eabi/12.1.1/thumb/v7-a+simd/hard/libgcc.a
  -march=armv7-a -mhard-float -mfpu=vfp
    /usr/lib/gcc/arm-none-eabi/12.1.1/thumb/v7-a+fp/hard/libgcc.a

Signed-off-by: Marek BehĂșn <kabel <AT> kernel.org>
Signed-off-by: Sam James <sam <AT> gentoo.org>

 eclass/toolchain.eclass | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
index ed473e0c626f..29076efc3f54 100644
--- a/eclass/toolchain.eclass
+++ b/eclass/toolchain.eclass
@@ -1213,6 +1213,17 @@ toolchain_src_configure() {
                                        armv7*) confgcc+=( --with-fpu=vfpv3-d16 
) ;;
                                esac
                        fi
+
+                       # If multilib is used, make the compiler build multilibs
+                       # for A or R and M architecture profiles. Do this only
+                       # when no specific arch/mode/float is specified, e.g.
+                       # for target arm-none-eabi, since doing this is
+                       # incompatible with --with-arch/cpu/float/fpu.
+                       if is_multilib && [[ ${arm_arch} == arm ]] && \
+                          tc_version_is_at_least 7.1
+                       then
+                               confgcc+=( 
--with-multilib-list=aprofile,rmprofile  )
+                       fi
                        ;;
                mips)
                        # Add --with-abi flags to set default ABI

Reply via email to