public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Handle MULTILIB_REUSE in auto-generated SYSROOT_SUFFIX_SPEC macro
@ 2014-06-05 19:23 Julian Brown
  2014-06-24 11:26 ` Julian Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Julian Brown @ 2014-06-05 19:23 UTC (permalink / raw)
  To: gcc-patches

[-- Attachment #1: Type: text/plain, Size: 2463 bytes --]

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.

[-- Attachment #2: arm-sysroot-mlib-arrangement-1.diff --]
[-- Type: text/x-patch, Size: 1656 bytes --]

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

[-- Attachment #3: multilib-reuse-sysroot-suffix-fsf-1.diff --]
[-- Type: text/x-patch, Size: 1276 bytes --]

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Handle MULTILIB_REUSE in auto-generated SYSROOT_SUFFIX_SPEC macro
  2014-06-05 19:23 Handle MULTILIB_REUSE in auto-generated SYSROOT_SUFFIX_SPEC macro Julian Brown
@ 2014-06-24 11:26 ` Julian Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Julian Brown @ 2014-06-24 11:26 UTC (permalink / raw)
  Cc: gcc-patches

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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-06-24 11:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-05 19:23 Handle MULTILIB_REUSE in auto-generated SYSROOT_SUFFIX_SPEC macro Julian Brown
2014-06-24 11:26 ` Julian Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).