Changes between Version 2 and Version 3 of Commentary/PlatformNaming


Ignore:
Timestamp:
Aug 3, 2011 11:56:32 PM (4 years ago)
Author:
dterei
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/PlatformNaming

    v2 v3  
    1  = Platforms = 
     1= Platforms = 
    22 
    3 There are three platforms of interest to GHC:  
    4   * '''The Build platform''': This is the platform on which we are building GHC.  
    5   * '''The Host platform''': This is the platform on which we are going to run this GHC binary, and associated tools.  
    6   * '''The Target platform''': This is the platform for which this GHC binary will generate code. 
    7  
    8 (I believe this convention is inherited from GNU {{{autoconf}}}) 
     3Please read [wiki:CrossCompilation this wiki page] on cross compilation for a better understanding of the situation here. There are three platforms of interest to GHC when compiling and running: 
     4  
     5 * The '''Build''' platform. This is the platform on which we are building GHC. 
     6 * The '''Host''' platform. This is the platform on which we are going to run this GHC binary, and associated tools. 
     7 * The '''Target''' platform. This is the platform for which this GHC binary will generate code. 
    98 
    109== Limitations == 
    1110 
    12 At the moment, there is very limited support for having different values for build, host, and target. In particular: 
     11At the moment, there is limited support for having different values for build, host, and target. Please refer to the [wiki:CrossCompilation cross compilation] page for more details. In particular: 
    1312 
    1413The 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.  
     
    2019In the compiler's source code, you may make use of the following CPP symbols: 
    2120 
    22 {{{ 
    23 xxx_TARGET_ARCH  
    24 xxx_TARGET_VENDOR  
    25 xxx_TARGET_OS  
    26 xxx_HOST_ARCH  
    27 xxx_HOST_VENDOR  
    28 xxx_HOST_OS  
    29 }}} 
     21 * ''xxx''`_TARGET_ARCH` 
     22 * ''xxx''`_TARGET_VENDOR` 
     23 * ''xxx''`_TARGET_OS` 
     24 * ''xxx''`_HOST_ARCH` 
     25 * ''xxx''`_HOST_VENDOR` 
     26 * ''xxx''`_HOST_OS` 
    3027 
    31 where xxx is the appropriate value: eg. i386_TARGET_ARCH.  
     28where ''xxx'' is the appropriate value: eg. `i386_TARGET_ARCH`. However '''GHC is moving away from using CPP for this purpose''' in many cases due to the problems it creates with supporting cross compilation. 
     29 
     30So instead it the new plan is to always build GHC as a cross compiler and select the appropriate values and backend code generator to run and runtime. For this purpose there is the Platform module ([[GhcFile(compiler/utils/Platform.hs)]]). That contains various methods for querying the !DynFlags ([[GhcFile(compiler/main/DynFlags.hs)]]) value for what platform GHC is currently compiling for. You should use these when appropriate over the CPP methods.