Compile code for arm

Hi,

I’ve installed clang version 3.3 on ubuntu.
I want to cross-compile a C code into ARM (preferably) ARMv7. I want to get both assembly code and binary. Can anyone help me what are the steps which should I take?

Second question, Is there anyway to tell compiler not to use any Thumb/NEON/VFP instructions?

Thanks

Best Regards,
A. Yazdanbakhsh

I can generate LLVM byte code from the Clang.

Hi,

I've installed clang version 3.3 on ubuntu.
I want to cross-compile a C code into ARM (preferably) ARMv7. I want to get
both assembly code and binary. Can anyone help me what are the steps which
should I take?

clang -triple arm-none-eabi (or many other variations including
'armv5', 'armv7a', 'linux', 'gnueabi', etc).

There are other options, like -mcpu, -mfpu, -march, -mthumb that you
can also tune. I'm not sure there is a list of all available options,
but since you have the source, you can look into ToolChain.cpp or
Tools.cpp in Clang/lib/Driver and see for yourself all the available
options.

Second question, Is there anyway to tell compiler not to use any
Thumb/NEON/VFP instructions?

Using the same flags, you can tune at your leisure. The combination of
compiler flags might not be the most straightforward, as this is
somewhat a messy region. I advise you to search the list and try a bit
for yourself, always checking on clang's source what's available.

cheers,
--renato

Thanks for your help. But I got this warning which it seems it doesn’t use -triple

"clang: warning: argument unused during compilation: ‘-triple arm-none-eabi’ "

Ok, These are the three options you should be playing with:

-ccc-host-triple $(CCC_HOST_TRIPLE_ARM) \
--sysroot=$(SYSROOT_ARM) \
-gcc-toolchain $(GCC_TOOLCHAIN)

Where the (sic) host triple defines the "target" triple too.

Sysroot and gcc-toolchain is where you'll find the libraries and
binutils for the ARM targets (you'll need them, since LLVM still can't
cross-compile on its own).

Another alternative is to compile to assembly and assembly/link with
ARM gnu binutils, which is essentially the same thing, for now.

Feel free to search for those three options on the list and you'll
find a plethora or examples and discussions that will guide you
through the process.

cheers,
--renato

OK. Thanks for your help.
My problem is I am playing with the size of registerfile in ARM. I thought I can do it with only modifying the Target in the LLVM directory. But if it is going to use gcc-toolchain, then I need to modify them as well which is a huge work!

clang -triple arm-none-eabi (or many other variations including
'armv5', 'armv7a', 'linux', 'gnueabi', etc).

It's -target, not -triple

Hi Amir,

Thanks Tim.

I just need the assembly file. Anyway, I still have problem with generating assembly for the ARM without having any thumb and other fancy instructions.

As Renato sort of pointed out, you can disable thumb with -mno-thumb. I believe NEON and VFP must be turned ‘on’ and are off by default. This can be done with -mfpu=neon or -mfpu=vfp<version/type>. Are you seeing VFP/NEON instructions without these flags?