Can a front-end use the same IR modules to compile a copy of the object codes for more than one target without having to recreate the module?
Can LLVM IR modules be compiled for more than one target simply by switching their datalayout and triples? Does the target-independency really exist or there are little things in the code that may change depending on the target? (I'm not talking about C macros).
Lots of little things can vary and make them incompatible. Off the top
of my head:
+ Clang knows the size and alignment of types and inserts it
directly in many places (sizeof, for example).
+ Clang emits custom (target-dependent) code for function argument
and return types so that it can follow the C ABI.
+ va_arg is similar on many targets.
+ The underlying type (int, long, ...) gets mangled into C++ names,
so variation in just what int32_t and so on is can break linking.
+ You say you're not talking about C macros, but there are obviously
countless ways they can completely mess up target independence without
even trying.
Obviously these apply mostly to C and C++, if you're designing a
language from scratch and have no need to follow any platform's
specific ABI it can be made to work (you essentially define the ABI by
whatever code gets generated).
Cheers.
Tim.