target arm

Hello,

I’m trying to use clang to compile a file in an x86 machine (running i386 GNU/Linux) to ARM. In the end, all I want is for the bit code (I use –emit-llvm) getArch() result to be Triple::ARM.

I tried to use “–target arm” but I get a “fatal error: ‘bits/predefs.h’ file not found”.

Is there any easy way to make the target architecture “ARM” without running into such trouble?

Thanks!

Alon

Hi,

As I understand it, the issue is that (at least in principle) the information in any of the C/C++ system headers can be different between different architectures (and even major versions of the standard library on a given architecture). As such, clang/clang++ attempts to find the system header file for the target architecture rather than the host, and for general code there’s no way to get things to work without the headers for the target, which implies having a gcc cross compiler installed (since clang uses it’s directory to figure out where to look for headers).

You might possibly be able to get away with not having a cross compiler if you don’t actually need, and hence remove the includes for, anything which imports system headers.

Regards,

David

Ok, found how to fix it:

sudo apt-get install libc6-dev

J

Also, instead of “clang –target arm”, the full triple should be given, such as: “clang -target arm-linux-eabi”

Thanks a lot!

Alon