target arm


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?




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.



Ok, found how to fix it:

sudo apt-get install libc6-dev


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

Thanks a lot!