Changes between Version 14 and Version 15 of Commentary/Compiler/Backends/LLVM/Installing


Ignore:
Timestamp:
Jun 18, 2010 9:52:00 AM (4 years ago)
Author:
dterei
Comment:

Update now that llvm is in ghc head and supports tntc

Legend:

Unmodified
Added
Removed
Modified
  • Commentary/Compiler/Backends/LLVM/Installing

    v14 v15  
    22= Installing & Using the LLVM Back-end = 
    33 
    4 The patch needed for GHC can be found at: 
     4The LLVM backend is now included in GHC HEAD. Just grab the darcs HEAD version of GHC and build it. The backend now also supports all modes that GHC can be built in, except perhaps -dynamic which hasn't been tested yet, so you shouldn't need to change your build.mk file either (you used to have disabled an optimisation called tables-next-to-code, but the LLVM backend supports that now). 
    55 
    6  * GHC Patch: http://www.cse.unsw.edu.au/~davidt/downloads/ghc-llvmbackend-full.dpatch 
    7  
    8 == Installing == 
    9  
    10 Apply the darcs patch linked above to GHC head. This will make some changes across GHC, with the bulk of the new code ending up in 'compiler/llvmGen'. 
    11  
    12 To build GHC you need to add one flags to build.mk, it is: 
    13  
    14 {{{ 
    15 GhcEnableTablesNextToCode = NO 
    16 }}} 
    17  
    18 The LLVM code generator doesn't support at this time the [wiki:Commentary/Rts/Storage/HeapObjects?redirectedfrom=Commentary/Rts/HeapObjects#TABLES_NEXT_TO_CODE TABLES_NEXT_TO_CODE] optimisation due to limitations with LLVM. As long as its disabled the build system will detect this an automatically add in the LLVM backend. 
    19  
    20 === LLVM === 
    21  
    22 You will also need LLVM installed on your computer to use the back-end. If you wish to simply use an unregistered build of GHC, then the back-end should work with any standard LLVM version. If you wish to use a registered build of GHC however, then you may need to apply a patch to LLVM and build it yourself: 
    23  
    24  * '''Version 2.7''': (or later) natively support GHC, no patch is needed. 
    25  * ~~'''Version 2.6''': Apply this [http://www.cse.unsw.edu.au/~davidt/downloads/llvm-ghc-callconv-2.6.patch patch] to the source code.~~ 
    26  * ~~'''Version 2.5''': Apply this [http://www.cse.unsw.edu.au/~davidt/downloads/llvm-ghc-callconv-2.5.patch patch] to the source code.~~ 
    27  
    28 '''Just use LLVM 2.7. While the above patches do work the LLVM backend now uses the features of 2.7 and higher.''' 
    29  
    30 The patches can be applied with: 
    31 {{{ 
    32 $ cd llvm 
    33 $ patch -p0 -i <patch file> 
    34 }}} 
    35  
    36 LLVM is very easy to build and install. It can be done as follows: 
    37  
    38 {{{ 
    39 $ svn co http://llvm.org/svn/llvm-project/llvm/trunk llvm 
    40 $ cd llvm 
    41 $ ./configure --enable-optimized # probably also want to set --prefix 
    42 $ make 
    43 $ make install 
    44 }}} 
    45  
    46  
    47 == Using == 
    48  
    49 Once GHC is built, you can trigger GHC to use the LLVM back-end with the {{{-fllvm}}} flag. There is also a new {{{-ddump-llvm}}} which will dump out the LLVM IR code generated (must be used in combination with the {{{-fllvm}}} flag. (or use the {{{-keep-tmp-files}}} flag). 
    50  
    51 {{{ghc --info}}} should also now report that it includes the llvm code generator. 
    52  
    53 The [http://hackage.haskell.org/package/ghc-core ghc-core] tool also supports the llvm backend, and will display the generated assembly code for your platform. 
    54  
     6For instructions on building GHC go [http://hackage.haskell.org/trac/ghc/wiki/Building here] 
    557 
    568== Supported Platforms & Correctness ==