diff mbox

MULTILIB_DEFAULTS needs an update for ARM multilib builds

Message ID 4FA13622.7060202@ubuntu.com
State New
Headers show

Commit Message

Matthias Klose May 2, 2012, 1:26 p.m. UTC
I did see gcc-4.7 fail to build for an ARM soft-float/hard-float multilib
configuration. The reason is that gcc -print-multi-directory doesn't print
anything for the non-default, and gcc -print-multi-lib only prints `.' (and then
not building the runtime libs for the non-default).  The reason is that
set_multilib_dir in gcc.c only consults MULTILIB_DEFAULTS (only defined in
linux-elf.h), but not configure_default_options in configargs.h.  This proposed
patch updates MULTILIB_DEFAULTS depending on the configure options. An
alternative approach would be to update set_multilib_dir and print_multilib_info
to lookup configure_default_options in configargs.h as well.

Note that this didn't fail to build in gcc-4.6, but I can't see yet what change
did cause the build failure.

I didn't check if other targets need an update as well.

Ok for the trunk?

  Matthias
# DP: Set MULTILIB_DEFAULTS for ARM multilib builds

	* config.gcc (arm*-*-*): Set TARGET_CONFIGURED_FLOAT_ABI and
	TARGET_CONFIGURED_THUMB_MODE when configured --with-float and
	--with-mode.
	* config/arm/linux-eabi.h (MULTILIB_DEFAULTS): Set depending
	on TARGET_CONFIGURED_FLOAT_ABI, TARGET_CONFIGURED_THUMB_MODE and
	TARGET_BIG_ENDIAN_DEFAULT.

Comments

Richard Earnshaw May 2, 2012, 2:53 p.m. UTC | #1
On 02/05/12 14:26, Matthias Klose wrote:
> I did see gcc-4.7 fail to build for an ARM soft-float/hard-float multilib
> configuration. The reason is that gcc -print-multi-directory doesn't print
> anything for the non-default, and gcc -print-multi-lib only prints `.' (and then
> not building the runtime libs for the non-default).  The reason is that
> set_multilib_dir in gcc.c only consults MULTILIB_DEFAULTS (only defined in
> linux-elf.h), but not configure_default_options in configargs.h.  This proposed
> patch updates MULTILIB_DEFAULTS depending on the configure options. An
> alternative approach would be to update set_multilib_dir and print_multilib_info
> to lookup configure_default_options in configargs.h as well.
> 
> Note that this didn't fail to build in gcc-4.6, but I can't see yet what change
> did cause the build failure.
> 
> I didn't check if other targets need an update as well.
> 
> Ok for the trunk?
> 
>   Matthias
> 

This patch doesn't appear to be based of FSF trunk...


> @@ -68,6 +82,28 @@
>     "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
>      %{!mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "}"
>  

This pre-amble code has never existed in the FSF build.


Please ensure you are testing patches against the FSF sources, not some
custom variant.

R.
diff mbox

Patch

Index: b/src/gcc/config.gcc
===================================================================
--- a/src/gcc/config.gcc	2012-05-02 10:24:10.585842104 +0000
+++ b/src/gcc/config.gcc	2012-05-02 10:26:12.509846641 +0000
@@ -3047,10 +3047,18 @@ 
 		esac
 
 		case "$with_float" in
-		"" \
-		| soft | hard | softfp)
+		"")
 			# OK
 			;;
+		soft)
+			tm_defines="${tm_defines} TARGET_CONFIGURED_FLOAT_ABI=0"
+			;;
+		softfp)
+			tm_defines="${tm_defines} TARGET_CONFIGURED_FLOAT_ABI=1"
+			;;
+		hard)
+			tm_defines="${tm_defines} TARGET_CONFIGURED_FLOAT_ABI=2"
+			;;
 		*)
 			echo "Unknown floating point type used in --with-float=$with_float" 1>&2
 			exit 1
@@ -3094,6 +3102,9 @@ 
 		"" \
 		| arm | thumb )
 			#OK
+			if test "$with_mode" = thumb; then
+				tm_defines="${tm_defines} TARGET_CONFIGURED_THUMB_MODE=1"
+			fi
 			;;
 		*)
 			echo "Unknown mode used in --with-mode=$with_mode"
Index: b/src/gcc/config/arm/linux-eabi.h
===================================================================
--- a/src/gcc/config/arm/linux-eabi.h	2012-05-02 10:24:10.585842104 +0000
+++ b/src/gcc/config/arm/linux-eabi.h	2012-05-02 10:26:55.141848227 +0000
@@ -34,7 +34,21 @@ 
 /* We default to a soft-float ABI so that binaries can run on all
    target hardware.  */
 #undef  TARGET_DEFAULT_FLOAT_ABI
+#ifdef TARGET_CONFIGURED_FLOAT_ABI
+#if TARGET_CONFIGURED_FLOAT_ABI == 2
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_HARD
+#define MULTILIB_DEFAULT_FLOAT_ABI "mfloat-abi=hard"
+#elif TARGET_CONFIGURED_FLOAT_ABI == 1
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFTFP
+#define MULTILIB_DEFAULT_FLOAT_ABI "mfloat-abi=softfp"
+#else
+#define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+#define MULTILIB_DEFAULT_FLOAT_ABI "mfloat-abi=soft"
+#endif
+#else
 #define TARGET_DEFAULT_FLOAT_ABI ARM_FLOAT_ABI_SOFT
+#define MULTILIB_DEFAULT_FLOAT_ABI "mfloat-abi=soft"
+#endif
 
 /* We default to the "aapcs-linux" ABI so that enums are int-sized by
    default.  */
@@ -68,6 +82,28 @@ 
    "%{mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_HARD_FLOAT "} \
     %{!mfloat-abi=hard:" GLIBC_DYNAMIC_LINKER_SOFT_FLOAT "}"
 
+/* Set the multilib defaults according the configuration, needed to
+   let gcc -print-multi-dir do the right thing.  */
+
+#if TARGET_BIG_ENDIAN_DEFAULT
+#define MULTILIB_DEFAULT_ENDIAN "mbig-endian"
+#else
+#define MULTILIB_DEFAULT_ENDIAN "mlittle-endian"
+#endif
+
+#ifndef TARGET_CONFIGURED_THUMB_MODE
+#define MULTILIB_DEFAULT_MODE "marm"
+#elif TARGET_CONFIGURED_THUMB_MODE == 1
+#define MULTILIB_DEFAULT_MODE "mthumb"
+#else
+#define MULTILIB_DEFAULT_MODE "marm"
+#endif
+
+#undef  MULTILIB_DEFAULTS
+#define MULTILIB_DEFAULTS \
+	{ MULTILIB_DEFAULT_MODE, MULTILIB_DEFAULT_ENDIAN, \
+	  MULTILIB_DEFAULT_FLOAT_ABI, "mno-thumb-interwork" }
+
 /* At this point, bpabi.h will have clobbered LINK_SPEC.  We want to
    use the GNU/Linux version, not the generic BPABI version.  */
 #undef  LINK_SPEC