diff mbox

Handle MULTILIB_REUSE in auto-generated SYSROOT_SUFFIX_SPEC macro

Message ID 20140605202327.0432bbe9@octopus
State New
Headers show

Commit Message

Julian Brown June 5, 2014, 7:23 p.m. UTC
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.

Comments

Julian Brown June 24, 2014, 11:26 a.m. UTC | #1
On Thu, 5 Jun 2014 20:23:27 +0100
Julian Brown <julian@codesourcery.com> wrote:

> 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:

Ping? (Note that no in-tree targets use both print-sysroot-suffix.sh
and MULTILIB_REUSE, AFAICT, so this patch is mostly useful to
3rd-party integrators.)

Julian
diff mbox

Patch

--- 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 $@