LLVM-gcc for ARM


Thanks for your tips… But I’m still getting errors.

…/llvm-gcc4.2-2.6.source/configure --prefix=pwd/…/install --program-prefix=llvm- --enable-llvm=/home/LLVM/llvm-2.6/ --enable-languages=c,c++ --with-gnu-ld=/home/arm/bin/arm-elf-ld
–with-gnu-as=/home/arm/bin/arm-elf-as
–with-cpu=cortex-a8
–target=arm-elf

Errors:
>>
checking for g++ that supports -ffunction-sections -fdata-sections… yes
configure: error: No support for this host/target combination.
make[1]: *** [configure-target-libstdc+±v3] Error 1
>>

Thank you for your help,
Corina.

— On Sat, 1/16/10, Anton Korobeynikov anton@korobeynikov.info wrote:


> From: Anton Korobeynikov anton@korobeynikov.info
> Subject: Re: [LLVMdev] LLVM-gcc for ARM
> To: “corina s” corina_fff@yahoo.com
> Cc: llvmdev@cs.uiuc.edu
> Date: Saturday, January 16, 2010, 6:09 PM
>
> Hello
>
> > /tmp/ccm99Neh.s:711: Error: selected processor does not support `sxtb r1,r1’
> > make[3]: *** [libgcc/thumb/unwind-dw2-fde.o] Error 1
> >
> > Any ideas?
> Yes. LLVM defaults to ARMv5 in codegeneration and does not support
> ARMv4. Without any extra option arm-elf-as assumes ARMv4 and thus
> gives you these errors. So:
>
> 1. If your desired target platform is ARMv4 and not newer - then
> you’re out of luck
> 2. Otherwise - add --with-cpu or --with-arch to llvm-gcc configure to
> select the processor / arch desired.
>
> It seems that you’re interested in Cortex CPUs
> ("/tmp/arm-cortex-toolchain"), then your desired arch is armv7,
> configure with --with-arch=armv7 or e.g. --with-cpu=cortex-a8
>
> –
> With best regards, Anton Korobeynikov
> Faculty of Mathematics and Mechanics, Saint Petersburg State University


|

Moreover,

…/llvm-gcc4.2-2.6.source/configure --prefix=pwd/…/install --program-prefix=llvm- --enable-llvm=/home/LLVM/llvm-2.6/ --enable-languages=c,c++
–with-gnu-ld=/home/arm/bin/arm-elf-ld
–with-gnu-as=/home/arm/bin/arm-elf-as
–with-arch=armv7
–target=arm-elf

and then make target=arm-elf gives the following error:

Unknown arch used in --with-arch=armv7

Thanks.

I recompiled the LLVM-gcc with these options:

…/llvm-gcc4.2-2.6.source/configure --prefix=pwd/…/install --program-prefix=llvm- --enable-llvm=/home/LLVM/llvm-2.6/ --enable-languages=c --disable-libssp --with-gnu-ld --with-gnu-as --with-arch=armv7-a --target=arm-elf

It compiles successfuly.

make install.

But when compiling a file :

llvm-gcc a.c
Assembler messages:
Fatal error: Invalid -march= option: `armv7-a’

Any ideas?

Thank you,
Corina

llvm-gcc a.c
Assembler messages:
Fatal error: Invalid -march= option: `armv7-a'

Any ideas?

It is probably trying to use the wrong assembler. Run with -v and check.

Thank you,
Corina

Cheers,

Hello,

Well, I recompiled the LLVM-gcc

…/llvm-gcc4.2-2.6.source/configure --prefix=pwd/…/install --program-prefix=llvm- --enable-llvm=/home/LLVM/llvm-2.6/
–enable-languages=c
–disable-libssp
–with-gnu-ld=/home/LLVM/llvm-gcc4.2-2.6.source/arm-elf-ld --with-gnu-as=/home/LLVM/llvm-gcc4.2-2…6.source/arm-elf-as --with-cpu=cortex-a8
–target=arm-elf

Everything is OK, but when trying to compile a HelloWorld source it gives me the following error:

llvm-gcc a.c
a.c:1:19: error: stdio.h: No such file or directory
a.c: In function ‘main’:
a.c:4: warning: incompatible implicit declaration of built-in function ‘printf’

llvm-gcc -v a.c
Using built-in specs.
Target: arm-elf
Configured with: …/llvm-gcc4.2-2.6.source/configure --prefix=/home/LLVM/obj/…/install --program-prefix=llvm- --enable-llvm=/home/LLVM/llvm-2.6/
–enable-languages=c
–disable-libssp --with-gnu-ld=/home/LLVM/llvm-gcc4.2-2.6.source/arm-elf-ld --with-gnu-as=/home/LLVM/llvm-gcc4.2-2.6.source/arm-elf-as --with-cpu=cortex-a8 --target=arm-elf
Thread model: single
gcc version 4.2.1 (Based on Apple Inc. build 5649) (LLVM build)
/home/LLVM/install/bin/…/libexec/gcc/arm-elf/4.2.1/cc1 -quiet -v -iprefix /home/LLVM/install/bin/…/lib/gcc/arm-elf/4.2.1/ -D__USES_INITFINI__ a.c -quiet -dumpbase a.c -mcpu=cortex-a8 -auxbase a -version -o /tmp/ccEs2CuD.s

ignoring nonexistent directory "/home/LLVM/install/bin/…/lib/gcc/arm-elf/4.2.1/…/…/…/…/arm-elf/sys-include"
ignoring nonexistent directory "/home/LLVM/install/bin/…/lib/gcc/arm-elf/4.2.1/…/…/…/…/arm-elf/include"
ignoring duplicate directory "/home/LLVM/obj/…/install/lib/gcc/arm-elf/4.2.1/include"
ignoring nonexistent directory "/home/LLVM/obj/…/install/lib/gcc/arm-elf/4.2.1/…/…/…/…/arm-elf/sys-include"
ignoring nonexistent directory “/home/LLVM/obj/…/install/lib/gcc/arm-elf/4.2.1/…/…/…/…/arm-elf/include”
#include “…” search starts here:
#include <…> search starts here:
/home/LLVM/install/bin/…/lib/gcc/arm-elf/4.2.1/include
End of search list.
GNU C version 4.2.1 (Based on Apple Inc. build 5649) (LLVM build) (arm-elf)
compiled by GNU C version 4.2.4 (Ubuntu 4.2.4-1ubuntu4).
GGC heuristics: --param ggc-min-expand=98 --param ggc-min-heapsize=131072
Compiler executable checksum: 2099b8949ecdc7b9705c423e43d0f9c7
a.c:1:19: error: stdio.h: No such file or directory
a.c: In function ‘main’:
a.c:4: warning: incompatible implicit declaration of built-in function ‘printf’

Why those directories doesn’t exist?

Thanks for your help,
Corina.

P.S. I will recompile and run -v to see which version of assembler is called.


— On Sun, 1/17/10, Rafael Espindola espindola@google.com wrote:


> From: Rafael Espindola espindola@google.com
> Subject: Re: [LLVMdev] LLVM-gcc for ARM
> To: “corina s” corina_fff@yahoo.com
> Cc: llvmdev@cs.uiuc.edu, anton@korobeynikov.info
> Date: Sunday, January 17, 2010, 8:23 AM
>
> > llvm-gcc a.c
> > Assembler messages:
> > Fatal error: Invalid -march= option: `armv7-a’
> >
> > Any ideas?
>
> It is probably trying to use the wrong assembler… Run with -v and check.
>
> >
> > Thank you,
> > Corina
> >
>
> Cheers,
> –
> Rafael Ávila de Espíndola

|

llvm-gcc a.c
a.c:1:19: error: stdio.h: No such file or directory
a.c: In function ‘main’:
a.c:4: warning: incompatible implicit declaration of built-in function ‘printf’

This is provided by libc. Do you have an ARM libc? You should
configure llvm-gcc with --with-sysroot pointing to the libc install
directory. If you are building from scratch, you have to

*) Build binutils
*) Build llvm-gcc
*) Use that to build a libc (newlib, glibc, etc)
*) Build a new llvm-gcc that can use that libc

Cheers,

OK, thank you.

Are there some pre-built X86 binaries for LLVM-gcc for ARM? It yes, where can I download from?

Thank you,
Corina

— On Sun, 1/17/10, Rafael Espindola espindola@google.com wrote:


> From: Rafael Espindola espindola@google.com
> Subject: Re: [LLVMdev] LLVM-gcc for ARM
> To: “corina s” corina_fff@yahoo.com
> Cc: llvmdev@cs.uiuc.edu, anton@korobeynikov.info
> Date: Sunday, January 17, 2010, 9:35 AM
>
> > llvm-gcc a.c
> > a.c:1:19: error: stdio.h: No such file or directory
> > a.c: In function ‘main’:
> > a.c:4: warning: incompatible implicit declaration of built-in function ‘printf’
>
> This is provided by libc. Do you have an ARM libc? You should
> configure llvm-gcc with --with-sysroot pointing to the libc install
> directory. If you are building from scratch, you have to
>
> *) Build binutils
> *) Build llvm-gcc
> *) Use that to build a libc (newlib, glibc, etc)
> *) Build a new llvm-gcc that can use that libc
>
> Cheers,
> –
> Rafael Ávila de Espíndola

|

Hello,

I recompiled binutils, llvm-gcc, libc, and again llvm-gcc and now it gives me the following error:

llvm-gcc --v
Using built-in specs.
Target: arm-elf
Configured with:

…/ (reconfigured) …/llvm-gcc4.2-2.6.source/configure --target=arm-elf --enable-llvm=/home/LLVM/llvm-2.6/ --with-arch=armv7-a --enable-languages=c --prefix=/home/LLVM/install --enable-multilib --with-newlib --without-headers --disable-shared --with-gnu-as --with-gnu-ld --program-prefix=llvm- --disable-libssp --with-sysroot=/home/LLVM/build/arm-elf/newlib/

llvm-gcc HelloWorld.c
/home/LLVM/install/lib/gcc/arm-elf/4.2.1/…/…/…/…/arm-elf/bin/ld: this linker was not configured to use sysroots
collect2: ld returned 1 exit status

I would appreciate some help from you.

Corina

llvm-gcc HelloWorld.c
/home/LLVM/install/lib/gcc/arm-elf/4.2.1/../../../../arm-elf/bin/ld: this linker was not configured to use sysroots
collect2: ld returned 1 exit status

I would appreciate some help from you.

You have to pass --with-sysroot when building binutils too.

Corina

Cheers,

llvm-gcc HelloWorld.c
/home/LLVM/install/lib/gcc/arm-elf/4.2.1/../../../../arm-elf/bin/ld: this linker was not configured to use sysroots
collect2: ld returned 1 exit status

I would appreciate some help from you.

You have to pass --with-sysroot when building binutils too.

It might be easier just to build newlib during the build of llvm-gcc.
Also, I don't think libc is usable /exists for bare-metal target
(arm-elf/arm-eabi).

hi all

I read LLVM manual, and have a question in the LLVM IR.
The IR is low-level SSA based instruction set.

I want to know what the difference between the LLVM IR and SSA form?
They are same, similar to tree-ssa of GCC convertion GIMPLE tree to SSA and convert back when optimizations finish?
or just attach the SSA info in the LLVM IR?

Thanks for your feedback.

-Joey

Hi Joey,

  I read LLVM manual, and have a question in the LLVM IR.
The IR is low-level SSA based instruction set.

I want to know what the difference between the LLVM IR and SSA form?
They are same, similar to tree-ssa of GCC convertion GIMPLE tree to SSA
and convert back when optimizations finish?
or just attach the SSA info in the LLVM IR?

LLVM IR is always in SSA form - there is no conversion between a non-SSA
version and an SSA-version, there is only the SSA version. Consider an
LLVM load instruction:
  %tmp = load i32* %addr
Here %addr is the pointer being loaded from, and %tmp is the loaded value.
Since LLVM IR is in SSA form, %tmp cannot be defined differently later, so
%tmp is *equivalent* to the instruction "load i32* %addr". Thus (unlike in
GIMPLE) there is no actual assignment going on in "%tmp = ...", this textual
form is just for the benefit of human readers, and means that %tmp is the name
of the instruction on the right-hand side. This is why you will search in vain
for an assignment instruction in the IR definition: there isn't one. In order
to get the effect of assigning multiple times to a variable, you either need
to generate explicit phi nodes, or generate explicit stores to memory (unlike
registers like %tmp, memory is not in SSA form; this is the same as in GIMPLE).

Ciao,

Duncan.