Bug 11716 - [mips] branch out of range when building fold-const.c
Summary: [mips] branch out of range when building fold-const.c
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 3.3.1
: P2 normal
Target Milestone: 3.3.4
Assignee: Richard Sandiford
URL:
Keywords: wrong-code
Depends on:
Blocks:
 
Reported: 2003-07-29 20:51 UTC by Debian GCC Maintainers
Modified: 2004-03-27 15:40 UTC (History)
2 users (show)

See Also:
Host: mips-linux
Target: mips64-linux
Build:
Known to work:
Known to fail:
Last reconfirmed: 2003-08-07 19:49:03


Attachments
preprocessed source (75.07 KB, application/x-bzip2)
2003-07-29 20:52 UTC, Debian GCC Maintainers
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Debian GCC Maintainers 2003-07-29 20:51:29 UTC
[forwarded from http://bugs.debian.org/202859]

3.3 CVS 20030722,
when building a mips-linux -> mips64-linux crosscompiler current gcc
creates assembler code as can't handle (Branch out of range)

The exact error messages is attached. Same happens with HEAD 20030722.
Compiler called as:
gcc --save-temps -c   -g -O2 -DIN_GCC -DCROSS_COMPILE  -W -Wall -Wwrite-strings
-Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -fno-common  
-DHAVE_CONFIG_H    -I. -I. -I../../gcc-cvs/gcc -I../../gcc-cvs/gcc/.
-I../../gcc-cvs/gcc/config -I../../gcc-cvs/gcc/../include 
../../gcc-cvs/gcc/fold-const.c -o fold-const.o
Comment 1 Debian GCC Maintainers 2003-07-29 20:52:14 UTC
Created attachment 4510 [details]
preprocessed source
Comment 2 Richard Sandiford 2003-08-07 18:24:48 UTC
Subject: Re:  New: [mips] branch out of range when building fold-const.c

"debian-gcc at lists dot debian dot org" <gcc-bugzilla@gcc.gnu.org> writes:
> when building a mips-linux -> mips64-linux crosscompiler current gcc
> creates assembler code as can't handle (Branch out of range)
> The exact error messages is attached. Same happens with HEAD 20030722.

Which assembler are you using?

Richard
Comment 3 Matthias Klose 2003-08-07 22:10:28 UTC
Subject: Re:  [mips] branch out of range when building fold-const.c

rsandifo at redhat dot com writes:
> Which assembler are you using?

binutils-2.14.90.0.5
Comment 4 Richard Sandiford 2003-08-08 06:36:56 UTC
Subject: Re:  [mips] branch out of range when building fold-const.c

"doko at cs dot tu-berlin dot de" <gcc-bugzilla@gcc.gnu.org> writes:
> > Which assembler are you using?
> 
> binutils-2.14.90.0.5

OK.  As far as the 3.3 goes, it's a known limitation.  gcc just doesn't
predict the length of macro instructions correctly.

Starting with gas 2.14, you can use:

    -Wa,-relax-branch

to get around this.

Mainline gcc is supposed to get it right though.  Could you attach
the preprocessed fold-const.i file?

Thanks,
Richard


Comment 5 Matthias Klose 2003-08-09 08:05:23 UTC
Subject: Re:  [mips] branch out of range when building fold-const.c

rsandifo at redhat dot com writes:
> Mainline gcc is supposed to get it right though.  Could you attach
> the preprocessed fold-const.i file?

hmm, it's already attached. or is this the wrong one?

	Matthias

Comment 6 Richard Sandiford 2003-08-09 09:23:21 UTC
Subject: Re:  [mips] branch out of range when building fold-const.c

"doko at cs dot tu-berlin dot de" <gcc-bugzilla@gcc.gnu.org> writes:
> rsandifo at redhat dot com writes:
> > Mainline gcc is supposed to get it right though.  Could you attach
> > the preprocessed fold-const.i file?
> 
> hmm, it's already attached. or is this the wrong one?

Ah, sorry about that.  For some reason I'd assumed you were using 3.3 to
cross-compile 3.3 and trunk to cross-compile trunk.  But it now occurs
to me that mips64-linux-gnu is new to 3.4, so I guess you were using 3.3
and trunk to compile the same version of gcc.  Is that right?

When you say you're building a cross compiler, is it a cross-host
or a normal cross-target?  It looks from bugzilla entry like it's
a cross-target, i.e.:

    build: mips-linux-gnu
    host: mips-linux-gnu
    target: mips64-linux-gnu

In other words, the compiler itself is to run on mips-linux-gnu
rather than mips64-linux-gnu.  Is that right?

I tried building an i686-pc-linux-gnu cross mips-linux-gnu compiler
from HEAD but couldn't reproduce the problem.  The checkout I used
was updated yesterday.

Is it still a problem for you on HEAD?  If so, could you tell me what
configure line you used?  Also, could you try both -mexplicit-relocs
and -mno-explicit-relocs?

Richard
Comment 7 agx 2003-08-09 11:04:25 UTC
Subject: Re:  [mips] branch out of range when building fold-const.c

On Sat, Aug 09, 2003 at 09:23:23AM -0000, rsandifo at redhat dot com wrote:
> Ah, sorry about that.  For some reason I'd assumed you were using 3.3 to
> cross-compile 3.3 and trunk to cross-compile trunk.  But it now occurs
> to me that mips64-linux-gnu is new to 3.4, so I guess you were using 3.3
> and trunk to compile the same version of gcc.  Is that right?
Yes, I used 3.3 and a CVS snapshot from 2003-07-22 to build a CVS
checkout from the same date.

>     build: mips-linux-gnu
>     host: mips-linux-gnu
>     target: mips64-linux-gnu
Yes.

> In other words, the compiler itself is to run on mips-linux-gnu
> rather than mips64-linux-gnu.  Is that right?
Yes.

> I tried building an i686-pc-linux-gnu cross mips-linux-gnu compiler
> from HEAD but couldn't reproduce the problem.  The checkout I used
> was updated yesterday.
I don't have any problem on i386 either. Furthermore compiling without
-O2 on mips-linux seems to work around the problem too.

> Is it still a problem for you on HEAD?  If so, could you tell me what
> configure line you used?  Also, could you try both -mexplicit-relocs
> and -mno-explicit-relocs?
Will be some time till I have this all tested. Configure is:
../gcc-cvs/configure --enable-languages=c --disable-shared 	\
 --with-newlib --disable-threads --target=mips64-linux		\
 --prefix=~/toolchain/cross-mips64-linux
Regards,
 -- Guido
Comment 8 Richard Sandiford 2003-08-09 11:44:12 UTC
Subject: Re:  [mips] branch out of range when building fold-const.c

"agx at sigxcpu dot org" <gcc-bugzilla@gcc.gnu.org> writes:
> > In other words, the compiler itself is to run on mips-linux-gnu
> > rather than mips64-linux-gnu.  Is that right?
> Yes.
> 
> > I tried building an i686-pc-linux-gnu cross mips-linux-gnu compiler
> > from HEAD but couldn't reproduce the problem.  The checkout I used
> > was updated yesterday.
> I don't have any problem on i386 either.

Just to confirm: you're saying that you don't see a problem if you
create a i386-x-mips-linux-gnu compiler and then use that compiler
to compile the fold-const.i file you posted?

Richard
Comment 9 agx 2003-08-11 17:05:31 UTC
Subject: Re:  [mips] branch out of range when building fold-const.c

On Sat, Aug 09, 2003 at 11:44:13AM -0000, rsandifo at redhat dot com wrote:
> Just to confirm: you're saying that you don't see a problem if you
> create a i386-x-mips-linux-gnu compiler and then use that compiler
> to compile the fold-const.i file you posted?
Yes, this works:

~$ /usr/local/stow/cross-mips-linux/bin/mips-linux-gcc -c fold-const.i && echo 'Works!'
Works!

This is a slightly different gcc though:
Reading specs from /usr/local/stow/cross-mips-linux/lib/gcc-lib/mips-linux/3.3/specs
Configured with: ../gcc-3.3/configure --prefix=/usr/local/stow/cross-mips-linux --target=mips-linux --disable-shared --enable-languages=c
Thread model: posix
gcc version 3.3

Regards,
 -- Guido
Comment 10 agx 2003-08-19 11:32:09 UTC
The problem doesn't show up anymore with the latest CVS head.
Comment 11 Richard Sandiford 2003-08-22 09:06:21 UTC
OK, thanks for the info. Since the problem is a known limitation with 3.3.x
and earlier, I'll go ahead and close this.  Please do open a new bug if you
get out-of-range problems on head again.

Thanks,
Richard
Comment 12 GCC Commits 2004-03-27 10:35:11 UTC
Subject: Bug 11716

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_3-branch
Changes by:	doko@gcc.gnu.org	2004-03-27 10:35:04

Modified files:
	gcc            : ChangeLog 
	gcc/config/mips: mips.md 

Log message:
	2004-03-27  Matthias Klose  <doko@debian.org>
	
	PR target/11716
	Michael Eager <eager@mvista.com>
	
	* config/mips/mips.md: Limit the maximum length of a short branch to
	64K instead of 128K.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.16114.2.955&r2=1.16114.2.956
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/mips/mips.md.diff?cvsroot=gcc&only_with_tag=gcc-3_3-branch&r1=1.153.2.4&r2=1.153.2.5

Comment 13 Andrew Pinski 2004-03-27 15:40:12 UTC
Fixed also in 3.3.4.