Building an ARM-GCC toolchain

Hi all,

I am trying to build an ARM-GCC toochain. I followed the instructions from the gcc.gnu.org site but end up with errors during assembly of lib1funcs.asm. Already the first line produces an error caused by the comment character '@'. So I suspect the wrong assembler is called during the build process. Any clues how to solve this?

My native GCC version on the Linux box is 3.4.6 and I'm trying to build a cross compiler from the 3.2.1 sources.

Meindert

Reply to
Meindert Sprang
Loading thread data ...

The syntax of assembler file are dependent of the assembler. For example, in the GNU assembler comments begin by a ';' and not a '@'

--
Guillaume Chevillot
Reply to
Guillaume Chevillot

Although cross-compiling is getting more common with all the embedded platforms available these days, building cross compilers is still a hairy task. Consider using crosstool to do the job for you, hiding all the gory details:

formatting link

Crosstool is a collection of makefiles and patches that will do all the necassery work to build the crosscompiler of choice: downloading the original source packages, applying patches and building the toolchain. There's no black magic involved that you couldn't do yourself, but it might save you some headaches.

--
:wq
^X^Cy^K^X^C^C^C^C
Reply to
Ico

A couple of questions to satisfy my own curiosity:

1) Why not use a pre-build tool chain? 2) Why not use the latest version of GCC (V4.2.1) - I think the V3.2.1 version is not good for ARM.
--
Regards,
Richard.

+ http://www.FreeRTOS.org
13 official architecture ports, 1000 downloads per week.

+ http://www.SafeRTOS.com
Certified by TÜV as meeting the requirements for safety related systems.
Reply to
FreeRTOS.org

Because I cannot find a pre-built 3.2.1 toolchain.

Because I "inherited" the sourcecode of this project and added my own extensions. This code was originally compiled with an older version of GCC and it works with 3.2.1. When I compile it with a more recent version (tried

3.4.3), unexpected things occur. Apparently, there are differences between compiler versions that result in this kind of unexpected behaviour but I don't have the time and budget to go over the existing code and make it work with the most recent version of GCC, although I'd like to.

Meindert

Reply to
Meindert Sprang

Can you summarize what where your steps? It is hard to answer without knowing what you did. I suspect one step is missing

Reply to
Adrian

"Adrian" wrote in message news: snipped-for-privacy@k79g2000hse.googlegroups.com...

The following script is used, which I got from someone who uses this to rebuild his toolchain and is known to work:

#!/bin/sh # Tauno Voipio, 16.1.2003, 3.2.2003, 11.3.2003 # Adapted from: # Jean Tabel 02/14/2001 # snipped-for-privacy@videotron.ca # Adapted from the cross gcc FAQ and other sources # in order to get a working script. # See

formatting link
for # credits. # Jean Tabel 2001/04/22 arm-elf version # Jean Tabel 2001/10/01 one-pass script # Jean Tabel 2002/01/07 gcc 3.0.3, gdb + insight # Jean Tabel 2002/03/31 insight 5.1.1 # Jean Tabel 2002/05/16 insight 5.2, gdb 5.2, gcc 3.1 # newlib 1.10 # Jean Tabel 2002/08/15 gcc 3.2, binutils 2.13 # Jean Tabel 2002/12/24 gcc 3.2.1, binutils 2.13.1 # gdb 5.3, insight 5.3

# Defining target

#TARGET=powerpc-unknown-eabisim TARGET=arm-elf #TARGET=arm-unknown-elf #TARGET=sparc-unknown-coff #TARGET=mips-unknown-elf #TARGET=m68k-unknown-coff #TARGET=i386-unknown-elf #TARGET=mcore-unknown-elf #TARGET=m68hc11-unknown-elf

# Defining prefix - final toolchain location

PREFIX=/usr/local #PREFIX=/usr/local/powerpc #PREFIX=/usr/local/arm #PREFIX=/usr/local/sparc-coff #PREFIX=/usr/local/mips-unknown-elf #PREFIX=/usr/local/m68k-coff #PREFIX=/usr/local/i386-unknown-elf #PREFIX=/usr/local/mcore #PREFIX=/usr/local/m68hc11

# PATH must updated PATH=$PREFIX/bin:$PATH

# Configuring packages versions GCC_VER=3.3.3 BINUTILS_VER=2.14 NEWLIB_VER=1.12.0 GDB_VER=5.3 INSIGHT_VER=5.3

# binutils rm -rf binutils-$BINUTILS_VER binutils tar zxvf binutils-$BINUTILS_VER.tar.gz mkdir binutils cd binutils ../binutils-$BINUTILS_VER/configure --target=$TARGET --prefix=$PREFIX make all checkinstall cd ..

# gcc/g++ rm -rf gcc-$GCC_VER gcc # testing for full gcc archive if [ -f gcc-$GCC_VER.tar.gz ] then tar zxvf gcc-$GCC_VER.tar.gz elif [ -f gcc-$GCC_VER.tar.bz2 then tar xjvf gcc-$GCC_VER.tar.bz2 else tar zxvf gcc-core-$GCC_VER.tar.gz # tar zxvf gcc-g++-$GCC_VER.tar.gz fi

# extracting newlib - needed for gcc rm -rf newlib-$NEWLIB_VER newlib tar zxvf newlib-$NEWLIB_VER.tar.gz

cd gcc-$GCC_VER ln -s ../newlib-$NEWLIB_VER/newlib newlib ln -s ../newlib-$NEWLIB_VER/libgloss libgloss cd ..

mkdir gcc

cd gcc ../gcc-$GCC_VER/configure --target=$TARGET --enable-languages=c --with-newli b --prefix=$PREFIX --with-gnu-as --with-gnu-ld make all checkinstall cd ..

# newlib mkdir newlib cd newlib ../newlib-$NEWLIB_VER/configure --target=$TARGET --prefix=$PREFIX --nfp make all checkinstall cd ..

I have used the exact same versions of the sources, the only possible difference could be the Linux system where I try to run this on, which has a native RetHat 3.4.6-8 version of GCC installed. I keep getting messages like:

../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm: Assembler messages: ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:1: Error: junk at end of line, first unrecognized character is `@' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:2: Error: junk at end of line, first unrecognized character is `@' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:153: Error: no such instruction: `work .req r4@XXXX is this safe?' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:445: Error: no such instruction: `orrhs result,result,curbit,lsr' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:445: Error: expecting operand after ','; got nothing ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:445: Error: no such instruction: `movnes curbit,curbit,lsr' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:445: Error: no such instruction: `movne divisor,divisor,lsr' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:445: Error: no such instruction: `bne Loop3' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:447: Error: too many memory references for `mov' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:448: Error: too many memory references for `mov' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:452: Error: invalid char '[' beginning operand 2 `[sp' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:452: Error: no such instruction: `bl __div0 (PLT)' ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:452: Error: expecting operand after ','; got nothing ../../gcc-3.3.3/gcc/config/arm/lib1funcs.asm:452: Error: no such instruction: `ldmia sp!,{pc}' make[2]: *** [libgcc/./_udivsi3.o] Error 1 make[2]: Leaving directory `/root/gnu-arm/gcc/gcc' make[1]: *** [stmp-multilib] Error 2 make[1]: Leaving directory `/root/gnu-arm/gcc/gcc' make: *** [all-gcc] Error 2 [root@serv-1 gnu-arm]#

Meindert

Reply to
Meindert Sprang

from

the

According to the binutils docs, an @ means a comment that extends to the end of the current line.

Meindert

Reply to
Meindert Sprang

Meindert

This looks like you aren't actually invoking the ARM assembler since the assembler that you are using complains about perfectly valid ARM opcodes. Are you sure that you have installed the assembler that you've just built in binutils?

Andrew

Reply to
Andrew Jackson

For binutils: try "make all install" instead of "make all"

------------------------------------------------------------- You should initially build a bootstrap gcc: ../gcc-$GCC_VER/configure --target=$TARGET --enable-languages=c --with- newlib \

--prefix=$PREFIX --with-gnu-as --with-gnu-ld --disable-shared -- without-headers \

--with-local-prefix=${PREFIX}/${TARGET}

make all-gcc install-gcc

------------------------------------------------------------- Newlib: again "make all install", configure is OK

------------------------------------------------------------- Then build gcc again: ../gcc-$GCC_VER/configure --target=$TARGET --enable-languages=c --with- newlib \

--prefix=$PREFIX --with-gnu-as --with-gnu-ld --disable-shared \

--with-local-prefix=${PREFIX}/${TARGET}

make all install

-------------------------------------------------------------- I would recommend to comment the current PREFIX and uncomment PREFIX=/usr/local/arm for clarity

Reply to
Adrian

I thought about that too. But I am not sure. The specified target directory (/usr/local/arm) remained empty so I just ran "make install" in the binutils directory and now I get some files in /usr/local/asm. I'll try and build the compiler again now.

thanks for that tip.

Meindert

Reply to
Meindert Sprang

directory

binutils

the

Great. Now the error messages are gone, but the process stops with an "internal compiler error"... These are the moments I really start hating free software for commercial jobs...This whole excersise has already cost me more time and money that scheduled for this job.

Meindert

Reply to
Meindert Sprang

And the above ends with an error message: arm-elf-ar: Command not found.

Meindert

Reply to
Meindert Sprang

That should be easy! Do you have the arm-elf-ar file in ${PREFIX}/bin? Do a "ls ${PREFIX}/bin" Does your PATH include ${PREFIX}/bin? (echo ${PATH})

Reply to
Adrian

Look at

formatting link
for a very nice script to build arm-elf-gcc. You can also download the particular version and patches for which the script was written from this site. I have used this script to compile gcc 4.2.0 on FC5.

Regards Anton Erasmus

Reply to
Anton Erasmus

No ";" means end of command.

This is valid sequenz with three commands: nop; nop; add r0,r0,r1

BTW: "@" is not always the start of the comment, it depends highly on target cpu.

--
42Bastian
Do not email to bastian42@yahoo.com, it's a spam-only account :-)
Use @monlynx.de instead !
Reply to
42Bastian Schick

Why don't you use one of the pre-compiled GCC for ARM ? (Or tell whoever made you into this that the commercial compilers produce better (tighter) code for ARM.)

--
42Bastian
Do not email to bastian42@yahoo.com, it's a spam-only account :-)
Use @monlynx.de instead !
Reply to
42Bastian Schick

Because for some obscure reason, when I compile the code with a more recent version of GCC (3.4.3 for instance), the application behaves strange and when it is compiled with 3.2.1, everything runs ok. But I cannot find a precompiled 3.2.1 version.

I'm afraid it is not an option to switch compiler now. Too much work, too little time.

Meindert

Reply to
Meindert Sprang

Since you are looking for older versions, you might find a matching binary on the CodeSourcery website - they have been producing ready-to-run binaries for gcc for ARM and ColdFire for years (they are the official maintainers). Their versions don't necessarily match directly with the official FSF gcc tree, however - for any given version the front and middle ends will pretty much match those of the official gcc tree, while the back end will be significantly ahead (since they are the people improving on the back end, and it takes time for those changes to get fully integrated into the FSF tree).

formatting link

Otherwise, make sure your steps are:

0) Unpack and configure the tarballs 1) Build and install binutils (and make sure it is on your path!) 2) Build the bootstrap compiler 3) Build the library 4) Build the main compiler

(The bootstrap step is apparently not needed for newer gcc versions, but it is certainly part of a 3.2 build.)

My guess is that you haven't got binutils installed properly, or it is not on your path.

mvh.,

David

Reply to
David Brown

Sounds as if you should be looking at the source you are compiling, rather than the compiler. Later gccs are more likely to expose errors.

--
 Chuck F (cbfalconer at maineline dot net)
   Available for consulting/temporary embedded and systems.
Reply to
CBFalconer

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.