Subject: Re: More GCC problems

From: Ian Chilton <[email-masked]>
Date: Fri, 3 Nov 2000 14:37:25 +0000

Hello,

> /tmp/cca08866.s: Assembler messages:
> /tmp/cca08866.s:27593: Error: Branch out of range
> /tmp/cca08866.s:27632: Error: Branch out of range
> /tmp/cca08866.s:27637: Error: Branch out of range

I get this same thing, when doing this:

- use make-cross.sh to build a cross compiling envronment using the current cvs stuff - 001103
- cross compile gcc-001017 using this:

CC="mips-linux-gcc -I/scratch/crossdev/mips-linux/mips-linux/include" CC_FOR_BUILD=cc GCC_FOR_TARGET="mips-linux-gcc -I/s/crossdev/mips-linux/include" AR=mips-linux-ar RANLIB=mips-linux-ranlib LD=mips-linux-ld ../configure --prefix=/usr --enable-threads --enable-languages=c --host=mips-linux --target=mips-linux --build=`../config.guess` && make

PLEASE someone help me out here.... I have spent the last 2 days trying to compile GCC. I have tried every version I can find, from 07072000 to 1707200 which suposidly work, to the lastest CVS version. I have tried native and cross compiling....

The only gcc builds I have had work is egcs-1.0.3a, and a 2.97 cross compile. 

I need a 2.97 native build, static, to compile glibc 2.2, then build a 2.97 dynamic.

HEEEELLLP!

Thanks!

Bye for Now,

Ian

                     \|||/ 
                     (o o)
 /----------------ooO-(_)-Ooo----------------\
 |  Ian Chilton                              |
 |  E-Mail : [email-masked]              |
 \-------------------------------------------/

---

From: Keith M Wesolowski <[email-masked]>
Date: Fri, 3 Nov 2000 10:07:28 -0800

> I get this same thing, when doing this:

Don't blame the compiler. This is a gas problem. You should be able to
get around it by using optimization; -O2 is sufficient I believe. If
not, you may have to use -Os.

> PLEASE someone help me out here.... I have spent the last 2 days
> trying to compile GCC. I have tried every version I can find, from
> 07072000 to 1707200 which suposidly work, to the lastest CVS
> version. I have tried native and cross compiling....  I need a 2.97
> native build, static, to compile glibc 2.2, then build a 2.97
> dynamic.

I have no idea how to build a static compiler. The approach I took to
get my working native 1019 compiler was to cross-build it with the
same version. Since it was built against glibc 2.2, I simply installed
both glibc 2.2 and the new native compiler on my system.

-- 
Keith M Wesolowski			[email-masked]
University of Nevada			http://www.chem.unr.edu
Chemistry Department Systems and Network Administrator

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Fri, 3 Nov 2000 19:27:01 +0100 (MET)

> I have no idea how to build a static compiler. The approach I took to

 Just add "-static" to CFLAGS in the usual way.

> both glibc 2.2 and the new native compiler on my system.

 But check the "cross_compile" statement in the gcc's specs file. 
Depending on the way of installing a cross-compiled native compiler on the
host machine you may get it right or not -- it should be "0".  I had to
tweak it manually when making an RPM package of gcc-2.95.3 (packages
available from ftp://ftp.ds2.pg.gda.pl/pub/macro).

-- 
+  Maciej W. Rozycki, Technical University of Gdansk, Poland   +
+--------------------------------------------------------------+
+        e-mail: [email-masked], PGP key available        +

---

From: Ian Chilton <[email-masked]>
Date: Fri, 3 Nov 2000 20:04:32 +0000

> not, you may have to use -Os.

-Os?

> I have no idea how to build a static compiler.

make -LDFLAGS=-static
but just make didn't work either..

> The approach I took t
> same versiona

The problem is, I can't cross-compile either  :(

Bye for Now,

Ian

                     \|||/ 
                     (o o)

---

From: Ralf Baechle <[email-masked]>
Date: Fri, 3 Nov 2000 17:18:05 +0100

> > /tmp/cca08866.s:27637: Error: Branch out of range

This is a bug in all MIPS versions of gas I've ever examined, including the
vendors of GNU based development systems like Algorithmics.  The problem is
that gcc is producing code that results in loops of over 128kb size, so the
range of a normal branch is exceeded.  Gas should then convert assembler
code such as

loop:
	# > 128kb loop body
	bnez	reg, loop

into:

loop:
	# > 128kb loop body
	beq	reg, endloop
	jump	loop
endloop:

That's a non-trivial gas modification.

This is becoming an increasing problem with today's codesize.  Right now
only few applications are affected but Moore's law is mercyless ...

In this particular case I'll simply optimizing the code with -O1 or higher
will help by getting the loop body's size below 128kb size.  This may also
help with other affected packages.  It's however only a temporary solution;
we'll see code in the not to far future where the optimizer is no longer
able to get the code size below the critical size of 128kb.

  Ralf

---

From: "Maciej W. Rozycki" <[email-masked]>
Date: Fri, 3 Nov 2000 22:41:40 +0100 (MET)

> but just make didn't work either..

$ CFLAGS='-static' ./configure
$ make

That's the usual way.  You need to specify necessary options to configure
as well.  You may also put other options in CFLAGS.  You may also specify
other variables -- CC, CXX, CXXFLAGS and LDFLAGS are likely to work.  For
others you need to study configure scripts yourself.

 For example I use more or less the following commands to build an
i386-linux hosted cross-compiler for mipsel-linux on an i386-linux build
system: 

$ mkdir -p obj && cd obj
$ CC="i386-linux-gcc" CXX="i386-linux-g++" \
	CFLAGS="-pipe -O2 -fomit-frame-pointer" \
	CXXFLAGS="-pipe -O2 -fomit-frame-pointer" \
	../configure --prefix=/usr \
	--with-local-prefix=/usr/mipsel-linux/local \
	--enable-shared --enable-haifa --enable-threads \
	--cache-file=config.cache \
	--build=i386-linux --host=i386-linux --target=mipsel-linux
$ make all

and the following lines to build a mipsel-linux native compiler on an
i386-linux build system:

$ mkdir -p obj && cd obj
$ CC="i386-linux-gcc" CXX="i386-linux-g++" \
	CC_FOR_BUILD="i386-linux-gcc" \
	CXX_FOR_BUILD="i386-linux-g++" \
	CC_FOR_TARGET="mipsel-linux-gcc" \
	CXX_FOR_TARGET="mipsel-linux-g++" \
	CFLAGS="-pipe -O2 -fomit-frame-pointer" \
	CXXFLAGS="-pipe -O2 -fomit-frame-pointer" \
	../configure --prefix=/usr \
	--enable-shared --enable-haifa --enable-threads \
	--cache-file=config.cache \
	--build=i386-linux --host=mipsel-linux --target=mipsel-linux
$ make all
	
Note also you need to have glibc headers for the target system installed
on your build system before performing either builds.  I believe gcc
expects them to be found in ${prefix}/${target_alias}/sys-include (that
would be /usr/mipsel-linux/sys-include for the above examples).  It will
copy them to ${prefix}/${target_alias}/include upon build.

 If you do not fear of deep RPM magic, you may try to bootstrap a compiler
toolchain using packages I made available at
ftp://ftp.ds2.pg.gda.pl/pub/macro.  You'll need .rpm* files available
there -- as you are building for mips-linux and I use mipsel-linux, you'll
have to tweak all the files with `sed s/mipsel/mips/g'.  Then you may
start building binary packages from source ones.  You will have to modify
mipsel-linux-* packages slightly -- basically `sed s/mipsel/mips/g' again. 
You need to build packages in a specific order and install every built
package before proceeding to the following one.

 The order is:

1. mips-linux-binutils, mips-linux-boot-glibc-headers (in any order),

2. mips-linux-boot-gcc,

3. mips-linux-glibc,

4. mips-linux-gcc,

5. binutils, gcc (native, for mips-linux; basically any mips-linux
software).

Spec files include appropriate "BuildRequires" statements to remind you
(and rpm) which packages have be installed to build a given package.  The
packages reflect the way I bootstrapped a mipsel-linux system from scratch
on an i386-linux build system.  Gcc is 2.95.3 (or 2.95.2 plus a
few patches, actually), which is sufficient to build glibc 2.2.  You may
build a current gcc snapshot with it if you need to.

 Please note there is a compatibility breakage as of Oct 28th (see the
README file available at the site; it's also explained in change logs for
binutils and glibc).  You may want to fetch earlier binutils and glibc
packages (barring the binary compatibility they work equally well) if you
insist on a compatibility with a current binutils snapshot and binaries
available throughout the Internet.  I'll submit an appropriate change to
the binutils CVS soon; glibc 2.1.97 already has the fix applied.

 I hope this helps,

  Maciej