wiki:Commentary/PlatformNaming

Version 1 (modified by megacz, 3 years ago) (diff)

add explanation of build/host/target, formerly in CodingStyle

Platforms

There are three platforms of interest to GHC:

  • The Build platform: This is the platform on which we are building GHC.
  • The Host platform: This is the platform on which we are going to run this GHC binary, and associated tools.
  • The Target platform: This is the platform for which this GHC binary will generate code.

(I believe this convention is inherited from GNU autoconf)

Limitations

At the moment, there is very limited support for having different values for build, host, and target. In particular:

The build platform is currently always the same as the host platform. The build process needs to use some of the tools in the source tree, for example ghc-pkg and hsc2hs.

If the target platform differs from the host platform, then this is generally for the purpose of building .hc files from Haskell source for porting GHC to the target platform. Full cross-compilation isn't supported (yet).

Macros

In the compiler's source code, you may make use of the following CPP symbols:

xxx_TARGET_ARCH 
xxx_TARGET_VENDOR 
xxx_TARGET_OS 
xxx_HOST_ARCH 
xxx_HOST_VENDOR 
xxx_HOST_OS 

where xxx is the appropriate value: eg. i386_TARGET_ARCH.