[llvm-dev] Compiling for more than one target at once

Tim Northover via llvm-dev llvm-dev at lists.llvm.org
Mon Jun 6 16:46:23 PDT 2016


On 6 June 2016 at 15:06, Lorenzo Laneve via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> 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.


More information about the llvm-dev mailing list