Bug 44531 - [4.5/4.6 Regression] [SH] Multilib configuration does not work as expected on darwin
Summary: [4.5/4.6 Regression] [SH] Multilib configuration does not work as expected on...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.5.0
: P4 normal
Target Milestone: 4.5.1
Assignee: Not yet assigned to anyone
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2010-06-14 02:56 UTC by Lawrence Sebald
Modified: 2010-07-05 22:39 UTC (History)
2 users (show)

See Also:
Host: x86_64-apple-darwin10.3.1
Target: sh-unknown-elf
Build: x86_64-apple-darwin10.3.1
Known to work: 4.4.4
Known to fail: 4.5.0 4.6.0
Last reconfirmed: 2010-06-20 10:56:53


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Lawrence Sebald 2010-06-14 02:56:52 UTC
When building a clean GCC 4.5.0 targeting sh-elf, the multilib configuration of the compiler does not appear to work at all. For instance, building GCC 4.5.0 with the following set of configure flags:

../gcc-4.5.0/configure --target=sh-elf --prefix=/usr/local/dc2/sh-elf --with-newlib --enable-languages=c --disable-libssp --disable-tls --without-headers --disable-nls --with-multilib-list=m4-single-only,m4-nofpu,m4 --with-endian=little --with-cpu=m4-single-only

Results in a compiler that can only compile with -m4-single-only. -m4 and -m4-nofpu do not work at all, even though they were explicitly specified in the --with-multilib-list.

Attempting to specify -m4 results in the following error (similar for -m4-nofpu):
cc1: error: command line option '-m4' is not supported by this configuration

Configuring GCC 4.4.4 with the same set of configure flags results in a compiler that does support all of -m4, -m4-single-only, and -m4-nofpu (and defaults to -m4-single-only, as expected).
Comment 1 Kazumoto Kojima 2010-06-19 09:50:25 UTC
I can't reproduce it on my i686-pc-linux-gnu host with
a similar configuration

/home/kkojima/kaz/xsh-elf-combined-450/combined/configure --target=sh-unknown-elf --disable-libmudflap --disable-libssp --disable-libgomp --with-gnu-as --with-gnu-ld --enable-languages=c --disable-shared --with-newlib --disable-nls --prefix=/home/kkojima/kaz/xsh-elf-combined-450/install --with-headers=yes --disable-gdbtk --with-mpfr=/opt2/i686-pc-linux-gnu --with-gmp=/opt2/i686-pc-linux-gnu --with-multilib-list=m4-single-only,m4-nofpu,m4 --with-endian=little --with-cpu=m4-single-only

for vanilla gcc-4.5.0 under a usual combined tree setting.
It can be something configuration issue including a host
specific problem.  My gcc/tm.h starts like as:

#ifndef GCC_TM_H
#define GCC_TM_H
#define TARGET_CPU_DEFAULT (SELECT_SH4_SINGLE_ONLY)
#ifndef SH_MULTILIB_CPU_DEFAULT
# define SH_MULTILIB_CPU_DEFAULT "m4-single-only"
#endif
#ifndef SUPPORT_SH4_SINGLE_ONLY
# define SUPPORT_SH4_SINGLE_ONLY 1
#endif
#ifndef SUPPORT_SH4_SINGLE_ONLY
# define SUPPORT_SH4_SINGLE_ONLY 1
#endif
#ifndef SUPPORT_SH4_NOFPU
# define SUPPORT_SH4_NOFPU 1
#endif
#ifndef SUPPORT_SH4
# define SUPPORT_SH4 1
#endif

Could you look at how your gcc/tm.h is generated?
Comment 2 Lawrence Sebald 2010-06-19 15:58:05 UTC
Judging by what I see from my gcc/tm.h file, I'm guessing it might well be a host-specific problem (I'm on x86_64-apple-darwin10.3.1). Here's the start of my gcc/tm.h file:

#ifndef GCC_TM_H
#define GCC_TM_H
#define TARGET_CPU_DEFAULT (SELECT_SH4_SINGLE_ONLY)
#ifndef SH_MULTILIB_CPU_DEFAULT
# define SH_MULTILIB_CPU_DEFAULT "m4-single-only"
#endif
#ifndef SUPPORT_SH4_SINGLE_ONLY
# define SUPPORT_SH4_SINGLE_ONLY 1
#endif

So, from the looks of it, it seems to be a Mac OS X/Darwin host specific issue.
Comment 3 Kazumoto Kojima 2010-06-20 10:56:51 UTC
I can reproduce it on an old ppc darwin.  It looks that this
darwin's sed doesn't support the 'i' modifier for the 's' command
and drops all multilibs list specified.
Does the patch below work for you?

--- gcc/config.gcc~	2010-04-07 19:34:00.000000000 +0900
+++ gcc/config.gcc	2010-06-20 18:08:46.000000000 +0900
@@ -2315,7 +2315,7 @@ sh-*-symbianelf* | sh[12346l]*-*-symbian
 	target_cpu_default=SELECT_`echo ${sh_cpu_default}|tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`
 	tm_defines=${tm_defines}' SH_MULTILIB_CPU_DEFAULT=\"'`echo $sh_cpu_default|sed s/sh/m/`'\"'
 	tm_defines="$tm_defines SUPPORT_`echo $sh_cpu_default | sed 's/^m/sh/' | tr abcdefghijklmnopqrstuvwxyz- ABCDEFGHIJKLMNOPQRSTUVWXYZ_`=1"
-	sh_multilibs=`echo $sh_multilibs | sed -e 's/,/ /g' -e 's/^sh/m/i' -e 's/ sh/ m/gi' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ_ abcdefghijklmnopqrstuvwxyz-`
+	sh_multilibs=`echo $sh_multilibs | sed -e 's/,/ /g' -e 's/^[Ss][Hh]/m/' -e 's/ [Ss][Hh]/ m/g' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ_ abcdefghijklmnopqrstuvwxyz-`
 	for sh_multilib in ${sh_multilibs}; do
 		case ${sh_multilib} in
 		m1 | m2 | m2e | m3 | m3e | \
Comment 4 Lawrence Sebald 2010-06-20 14:01:08 UTC
The patch does indeed work, and everything builds as expected once patched. Thanks.
Comment 5 Kazumoto Kojima 2010-06-20 22:23:29 UTC
Thanks for the confirmation.  I'll apply it when the usual
bootstrap&regression tests are done on 4.5/4.6.
Comment 6 Kazumoto Kojima 2010-07-04 22:07:42 UTC
Subject: Bug 44531

Author: kkojima
Date: Sun Jul  4 22:07:29 2010
New Revision: 161807

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161807
Log:
	PR target/44531
	* config.gcc (sh*-*-*): Use regular expressions instead of
	the 'i' modifier for sed substitutions.


Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config.gcc

Comment 7 Kazumoto Kojima 2010-07-05 22:34:10 UTC
Subject: Bug 44531

Author: kkojima
Date: Mon Jul  5 22:33:58 2010
New Revision: 161857

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=161857
Log:
	Backport from mainline:
	PR target/44531
	* config.gcc (sh*-*-*): Use regular expressions instead of
	the 'i' modifier for sed substitutions.


Modified:
    branches/gcc-4_5-branch/gcc/ChangeLog
    branches/gcc-4_5-branch/gcc/config.gcc

Comment 8 Kazumoto Kojima 2010-07-05 22:39:17 UTC
Fixed.