building a llvm-arm-elf crosscompiler on OSX 10.5

Dear ML,

I'm trying to understand how to build a llvm (2.6) cross compiler for
arm-elf target using the gcc frontend with newlib. Could you please
indicate, if possible steps I should follow?

I try to configure and build llvm with

../llvm-2.6/configure
--prefix=/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6 --enable-optimized
--disable-threads --enable-targets=cbe,cpp,arm

and LLVM-GCC frontend with

../llvm-gcc4.2-2.6.source/configure
--prefix=/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6
--program-prefix=llvm-
--enable-llvm=/Users/dummy/Develop/llvm/llvm-2.6
--enable-languages=c,c++ --host=i686-apple-darwin9
--build=i686-apple-darwin9 --target=arm-elf
--with-gxx-include-dir=/usr/include/c++/4.0.0 --enable-interwork
--with-newlib --with-header=../newlib-1.18.0/newlib/libc/include

But I got the followings errors:

/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccDFjySd.s:
Assembler messages:
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccDFjySd.s:96:
Error: selected processor does not support `sxtb r5,r5'
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccDFjySd.s:537:
Error: selected processor does not support `sxtb r6,r6'
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccDFjySd.s:705:
Error: selected processor does not support `sxtb r1,r1'
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccDFjySd.s:711:
Error: selected processor does not support `sxtb r1,r1'

Thank you for your help,

pz

Hello

But I got the followings errors:

/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccDFjySd.s:
Assembler messages:
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccDFjySd.s:96:

Correct. You haven't specified any ARM specific stuff during llvm-gcc
conffigure (cpu type, fpu type, floating point abi, etc). This means
that default will be used. LLVM defaults to something like ARMv5,
binutils - to ARMv4. So, you just need to configure llvm-gcc properly.

Keep in mind, that binutils for ARM are known to be buggy, you need to
use binutils CVS snapshot (and even this is buggy - some bugs are not
yet fixed there).

Dear Anton,

Thanks for your help!
I had a look to llvm (2.6) configure options but I couldn't find any
way to specify cpu type, fpu ecc..Could you please give me any
indication and/or example? I want to try llvm with Atmel's
AT91SAM7X256 (core is ARM7TDMI )

Thank you again,

pz

Hello, Pazzo

I had a look to llvm (2.6) configure options but I couldn't find any
way to specify cpu type, fpu ecc..

These are not llvm configure options, but gcc's one. Basically, you
should configure llvm-gcc in the same way you do for gcc for your
platform.

Could you please give me any
indication and/or example? I want to try llvm with Atmel's
AT91SAM7X256 (core is ARM7TDMI )

I think adding --with-cpu=arm7tdmi to llvm-gcc configure should work

Dear Anton,

Thank you again for your help!

I tried with the following options (adding --with-cpu=arm7tdmi and
using binutils from cvs snapshot):

../llvm-gcc4.2-2.6.source/configure
--prefix=/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6
--program-prefix=llvm-
--enable-llvm=/Users/dummy/Develop/llvm/llvm-build
--enable-languages=c,c++ --host=i686-apple-darwin9
--build=i686-apple-darwin9 --target=arm-elf --with-cpu=arm7tdmi
--with-gxx-include-dir=/usr/include/c++/4.0.0 --enable-interwork
--enable-multilib --with-newlib
--with-header=../newlib-1.18.0/newlib/libc/include

...but after a while I got same errors:

/Users/dummy/Develop/llvm/llvm-gcc-build/./gcc/xgcc
-B/Users/dummy/Develop/llvm/llvm-gcc-build/./gcc/
-B/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6/arm-elf/bin/
-B/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6/arm-elf/lib/ -isystem
/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6/arm-elf/include -isystem
/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6/arm-elf/sys-include -O2
-O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition -isystem ./include -fno-inline -g
-DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I. -I.
-I../../llvm-gcc4.2-2.6.source/gcc
-I../../llvm-gcc4.2-2.6.source/gcc/.
-I../../llvm-gcc4.2-2.6.source/gcc/../include -I./../intl
-I../../llvm-gcc4.2-2.6.source/gcc/../libcpp/include
-I../../llvm-gcc4.2-2.6.source/gcc/../libdecnumber -I../libdecnumber
-I/Users/dummy/Develop/llvm/llvm-build/include
-I/Users/dummy/Develop/llvm/llvm-2.6/include -mthumb -fexceptions -c
../../llvm-gcc4.2-2.6.source/gcc/unwind-dw2-fde.c -o
libgcc/thumb/unwind-dw2-fde.o
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccEIiJQ4.s:
Assembler messages:
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccEIiJQ4.s:96:
Error: selected processor does not support `sxtb r5,r5'
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccEIiJQ4.s:537:
Error: selected processor does not support `sxtb r6,r6'
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccEIiJQ4.s:705:
Error: selected processor does not support `sxtb r1,r1'
/var/folders/7f/7fiRIEm-FruFfT7mGbk3uk+++TI/-Tmp-//ccEIiJQ4.s:711:
Error: selected processor does not support `sxtb r1,r1'
make[3]: *** [libgcc/thumb/unwind-dw2-fde.o] Error 1
make[2]: *** [stmp-multilib] Error 2
make[1]: *** [all-gcc] Error 2
make: *** [all] Error 2

Any clue?

Thank in advance for help.

pz

Hello, Pazzo

Any clue?

Yes. Sorry, my fault - next time I should check ARM docs before replying.
ARM7TDMI is ARMv4T and this is not supported by LLVM (LLVM does v5+ codegen).

Dear ML,

Anton, Thank you for your answer and your help.
I had a look at ARM.td of LLVM 2.6 (in lib/Target/ARM..) where I found
following definitions:

// V4T Processors.
def : ProcNoItin<"arm7tdmi", [ArchV4T]>;
def : ProcNoItin<"arm7tdmi-s", [ArchV4T]>;
def : ProcNoItin<"arm710t", [ArchV4T]>;
def : ProcNoItin<"arm720t", [ArchV4T]>;
def : ProcNoItin<"arm9", [ArchV4T]>;
def : ProcNoItin<"arm9tdmi", [ArchV4T]>;
def : ProcNoItin<"arm920", [ArchV4T]>;
def : ProcNoItin<"arm920t", [ArchV4T]>;
def : ProcNoItin<"arm922t", [ArchV4T]>;
def : ProcNoItin<"arm940t", [ArchV4T]>;
def : ProcNoItin<"ep9312", [ArchV4T]>;

I would like to understand if LLVM can be used for ArchV4T or not.
Could you please indicate specific documentation for llvm ARM codegen?

Does anybody use llvm with arm7tdmi ucontroller (e.g. at91sam7xxx)

Thank you again for your help,

pz

Dear ML,
Dear Anton,

I'm writing you again to add more informations I discovered: looking
at the following statement which gives me errors:

/Users/dummy/Develop/llvm/llvm-gcc-build/./gcc/xgcc
-B/Users/dummy/Develop/llvm/llvm-gcc-build/./gcc/
-B/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6/arm-elf/bin/
-B/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6/arm-elf/lib/ -isystem
/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6/arm-elf/include -isystem
/usr/local/cross-llvm-gcc-arm-elf-4.2-2.6/arm-elf/sys-include -O2
-O2 -g -O2 -DIN_GCC -DCROSS_DIRECTORY_STRUCTURE -W -Wall
-Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes
-Wold-style-definition -isystem ./include -fno-inline -g
-DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -Dinhibit_libc -I. -I.
-I../../llvm-gcc4.2-2.6.source/gcc
-I../../llvm-gcc4.2-2.6.source/gcc/.
-I../../llvm-gcc4.2-2.6.source/gcc/../include -I./../intl
-I../../llvm-gcc4.2-2.6.source/gcc/../libcpp/include
-I../../llvm-gcc4.2-2.6.source/gcc/../libdecnumber -I../libdecnumber
-I/Users/dummy/Develop/llvm/llvm-build/include
-I/Users/dummy/Develop/llvm/llvm-2.6/include -mthumb -fexceptions -c
../../llvm-gcc4.2-2.6.source/gcc/unwind-dw2-fde.c -o
libgcc/thumb/unwind-dw2-fde.o

I found that if I change -mthumb in -mthumb-interwork then I have no
errors. How can I instruct configure to use -mthumb-interwork instead
of -mthumb?

Thank you again for your attention,

mp