Generatin code for an ARM-LINUX machine

I am using the below configuration:

./configure --with-llvmgccdir=/home/jcmartin78/LLVM/llvm-gcc4.2 --prefix=/home/jcmartin78/local --enable-optimized=1 --enable-debug-runtime --enable-jit --enable-targets=arm --target=arm

When I use LLVMC to compile a simple program I get this:

$ llvmc hello.c
llc: error auto-selecting target for module ‘No available targets are compatible with this module’. Please use the -march option to explicitly pick a target.

Using the -march options, I get this:

$ llvmc -march=arm hello.c
hello.c:1: error: bad value (arm) for -march= switch
hello.c:1: error: bad value (arm) for -mtune= switch

Somebody has an idea what is wrong in my procedure? I am using a x86-linux machine and I want to generate code for an arm-linux machine (also, I am using the binutils 2.19 to build my cross-compiler).

I have not used llvmc to build ARM binaries, but llvm-gcc does work.
There’s a script to build llvm-gcc x86 → ARM cross-compiler in llvm/utils/crosstool/ARM/ .

2009/6/29 Juan Carlos Martinez Santos <juanc.martinez.santos@gmail.com>

Thanks Misha,

However, I could not find the crosstool. Could you please check the name of the script?

Regards,

Juan Carlos

llvm/utils/crosstool/ARM/build-install-linux.sh

Thanks John,

I just realized that I am not working on the same “branch” of LLVM. Looking the latest or the newest version I saw the folder with the script, but I did not see a README file.

I ran the script, and I get:

2009/6/30 Juan Carlos Martinez Santos <juanc.martinez.santos@gmail.com>

Thanks John,

I just realized that I am not working on the same “branch” of LLVM. Looking the latest or the newest version I saw the folder with the script, but I did not see a README file.

I ran the script, and I get:


chown: cannot access `/usr/local/codesourcery’: No such file or directory


You should have an error prior to this one where the script first tried to create the directory “/usr/local/codesourcery”, after which it tries to chown it. Can you post the entire output of the script rather than the last line?

Therefore my question is if the script depends on others folders (or files) that maybe are not in the 2.5 version.

The script does depend on files that are not distributed in LLVM. I just added a README file to describe what needs to be done and how: http://llvm.org/svn/llvm-project/llvm/trunk/utils/crosstool/ARM/README .

Let me know if this helps or if it’s not clear.

Misha

Hello Misha,

I used the snapshots for the latest stable version (70786), and I followed the instructions inside of README file (very clear!!!)

However, when I ran the hello program, I get an unrecognized option message. Bellow are the details.

as -meabi=4 -o /tmp/ccYxnIEs.o /tmp/ccy6iYri.s
as: unrecognized option '-meabi=4'

[snip]

Any idea what could be wrong?

It's probably not finding the right assembler (i.e. using the x86-64
as instead of the arm as).

-Eli

Hello Eli,

It’s probably not finding the right assembler (i.e. using the x86-64
as instead of the arm as).

I found that using LLVM-GCC does not work directly; however, if I split the tasks (file.C → LLVM-GCC → file.BC → LLC → file.S → ARM-NONE-LINUX-GNUEABI-GCC → file.ARM) at the end I get my ARM-executable file (work so good in this way)

However, now I am looking the source code to include my modifications (passes and my own driver), but I don’t know where there are. My question now is how I can include my own modification?

Thanks in advance.

Juan Carlos

2009/7/1 Juan Carlos Martinez Santos <juanc.martinez.santos@gmail.com>

I used the snapshots for the latest stable version (70786), and I followed the instructions inside of README file (very clear!!!)

However, when I ran the hello program, I get an unrecognized option message. Bellow are the details.

============================================
jcmartin78@jcmartin78-laptop:~/LLVM/my-test$ llvmc hello.c
as: unrecognized option ‘-meabi=4’

Sorry, this was my fault. I used the flags --with-gnu-{as,ld} instead of --with-{as,ld} to specify paths to the cross assembler and linker, but it turns out that the former pair of flags are boolean (i.e., telling GCC whether the tools are GNU or not), and the latter are the ones that accept a path.

So, llvm-gcc wasn’t finding the correct cross-tool assembler and was using /usr/bin/as instead, which doesn’t support ARM, and hence doesn’t accept “-meabi=4”. I’ve fixed this in SVN.

The reason I didn’t come across this issue is that I was using llvm-gcc phase-by-phase (as you’ve found it works), instead of generating binaries directly from llvm-gcc.