Hi, The print-sysroot-suffix.sh script that can be used (via the t-sysroot-suffix makefile fragment) to auto-generate the SYSROOT_SUFFIX_SPEC macro for non-trivial multilib setups does not take into account the MULTILIB_REUSE target fragment variable.
I'm not sure of a way to demonstrate how this causes problems with a vanilla tree, but consider the attached patch (arm-sysroot-mlib-arrangement-1.diff) intended to create a compiler with three multilibs: .; (little-endian, soft float) be;@mbig-endian (big-endian, soft float) vfp;@mfloat-abi=softfp (little-endian, hardware FP) Notice that we are not building a multilib for the be+vfp combination. Instead we use the MULTILIB_REUSE macro to make that combination fall back to using just the soft-float big-endian multilib: MULTILIB_REUSE = mbig-endian=mbig-endian/mfloat-abi.softfp But now, compiling code will fail with errors such as: $ arm-none-linux-gnueabi-gcc hello.c -mbig-endian -mfloat-abi=softfp \ -o hello ../arm-none-linux-gnueabi/bin/ld: /path/to/install/arm-none-linux-gnueabi/libc/usr/lib/libc.a(s_signbit.o): compiled for a little endian system and target is big endian Invoking the compiler with -print-sysroot vs. -print-multi-directory illustrates the problem: $ arm-none-linux-gnueabi-gcc hello.c -mbig-endian -mfloat-abi=softfp \ -print-sysroot /path/to/install/arm-none-linux-gnueabi/libc $ arm-none-linux-gnueabi-gcc hello.c -mbig-endian -mfloat-abi=softfp \ -print-multi-directory be What we wanted was for the first command to give the same result that invoking without -mfloat-abi=softfp does (which was the purpose of the MULTILIB_REUSE setting): $ arm-none-linux-gnueabi-gcc hello.c -mbig-endian -print-sysroot /path/to/install/arm-none-linux-gnueabi/libc/be but, that doesn't work at present. The attached patch fixes that: it's based on a part of CodeSourcery's earlier MULTILIB_ALIASES support (by Paul Brook originally, I think -- I don't think it ever made it upstream, but it worked quite similarly to MULTILIB_REUSE, that did), and allows the above multilib arrangement to work correctly. OK for mainline? (The ARM bits are for reference only and are not meant to be committed, of course.) Thanks, Julian ChangeLog gcc/ * config/print-sysroot-suffix.sh: Handle MULTILIB_REUSE settings. * config/t-sysroot-suffix (sysroot-suffix.h): Pass MULTILIB_REUSE to print-sysroot-suffix.sh script.
Index: gcc/config.gcc =================================================================== --- gcc/config.gcc (revision 210209) +++ gcc/config.gcc (working copy) @@ -1014,7 +1014,9 @@ arm*-*-linux-*) # ARM GNU/Linux with E ;; esac tmake_file="${tmake_file} arm/t-arm arm/t-arm-elf arm/t-bpabi arm/t-linux-eabi" + tmake_file="$tmake_file t-sysroot-suffix" tm_file="$tm_file arm/bpabi.h arm/linux-eabi.h arm/aout.h arm/arm.h" + tm_file="$tm_file ./sysroot-suffix.h" # Define multilib configuration for arm-linux-androideabi. case ${target} in *-androideabi) Index: gcc/config/arm/t-linux-eabi =================================================================== --- gcc/config/arm/t-linux-eabi (revision 210209) +++ gcc/config/arm/t-linux-eabi (working copy) @@ -20,8 +20,15 @@ # CLEAR_INSN_CACHE in linux-gas.h does not work in Thumb mode. # If you set MULTILIB_OPTIONS to a non-empty value you should also set # MULTILIB_DEFAULTS in linux-elf.h. -MULTILIB_OPTIONS = -MULTILIB_DIRNAMES = +MULTILIB_OPTIONS = mbig-endian mfloat-abi=softfp +MULTILIB_DIRNAMES = be vfp +MULTILIB_OSDIRNAMES = mbig-endian=!be mfloat-abi.softfp=!vfp +MULTILIB_MATCHES = +MULTILIB_EXCEPTIONS = + +MULTILIB_REUSE = mbig-endian=mbig-endian/mfloat-abi.softfp + +MULTILIB_REQUIRED = mbig-endian mfloat-abi=softfp #MULTILIB_OPTIONS += mcpu=fa606te/mcpu=fa626te/mcpu=fmp626/mcpu=fa726te #MULTILIB_DIRNAMES += fa606te fa626te fmp626 fa726te Index: gcc/config/print-sysroot-suffix.sh =================================================================== Index: gcc/config/t-sysroot-suffix ===================================================================
--- gcc/config/print-sysroot-suffix.sh (revision 210209) +++ gcc/config/print-sysroot-suffix.sh (working copy) @@ -29,6 +29,7 @@ # MULTILIB_OSDIRNAMES \ # MULTILIB_OPTIONS \ # MULTILIB_MATCHES \ +# MULTILIB_REUSE # > t-sysroot-suffix.h # The three options exactly correspond to the variables of the same @@ -54,6 +55,7 @@ set -e dirnames="$1" options="$2" matches="$3" +reuse="$4" cat > print-sysroot-suffix3.sh <<\EOF #! /bin/sh @@ -80,7 +82,14 @@ shift 2 n="\" \\ $padding\"" if [ $# = 0 ]; then + case $optstring in EOF +for x in $reuse; do + l=`echo $x | sed -e 's/=.*$//' -e 's/\./=/g'` + r=`echo $x | sed -e 's/^.*=//' -e 's/\./=/g'` + echo "/$r/) optstring=\"/$l/\" ;;" >> print-sysroot-suffix2.sh +done +echo " esac" >> print-sysroot-suffix2.sh pat= for x in $dirnames; do --- gcc/config/t-sysroot-suffix (revision 210209) +++ gcc/config/t-sysroot-suffix (working copy) @@ -3,5 +3,5 @@ sysroot-suffix.h: $(srcdir)/config/print-sysroot-suffix.sh $(SHELL) $(srcdir)/config/print-sysroot-suffix.sh \ "$(MULTILIB_OSDIRNAMES)" "$(MULTILIB_OPTIONS)" \ - "$(MULTILIB_MATCHES)" > tmp-sysroot-suffix.h + "$(MULTILIB_MATCHES)" "$(MULTILIB_REUSE)" > tmp-sysroot-suffix.h mv tmp-sysroot-suffix.h $@