Changes between Version 17 and Version 18 of Building/CrossCompiling/iOS


Ignore:
Timestamp:
Aug 21, 2013 10:13:46 PM (19 months ago)
Author:
StephenBlackheath
Comment:

How to build iOS simulator

Legend:

Unmodified
Added
Removed
Modified
  • Building/CrossCompiling/iOS

    v17 v18  
    33Take a look at #7724 for the status of iOS cross compiling. Any any time, you should be able to take GHC HEAD and apply any patches for bugs that are open (not crossed out) in "Blocked by". 
    44 
     5Note: If you use ghc-7.6.3 on Mac OS/X as your bootstrap compiler and you are using Xcode version 5 or higher, there are problems. The problem is that 1. GHC tries to run a C pre-processor over Haskell code, and 2. Xcode versions >= 5 use clang instead of gcc, and 3. clang doesn't like Haskell code. 
     6 
     7The workaround for this is to pass certain options to clang. A wrapper for this, written in Haskell, can be found at [https://github.com/ghc-ios/ghc-ios-scripts] 
     8 
    59== Steps == 
    610 
     
    1014 
    1115=== 2. Scripts === 
     16 
     17The following scripts are maintained at [https://github.com/ghc-ios/ghc-ios-scripts] 
    1218 
    1319Place these scripts somewhere in your path: 
     
    7379exec cabal --with-ghc=arm-apple-darwin10-ghc --with-ghc-pkg=arm-apple-darwin10-ghc-pkg --with-ld=arm-apple-darwin10-ld \ 
    7480--configure-option=--host=arm-apple-darwin10 --host-arch=arm --host-os=ios \ 
     81"$@" 
     82}}} 
     83 
     84'''i386-apple-darwin11-gcc''' 
     85{{{ 
     86#!/bin/sh 
     87 
     88TARGET_PLATFORM=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/ 
     89TARGET_BIN="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin" 
     90 
     91TARGET_GCC=$TARGET_BIN/i686-apple-darwin11-llvm-gcc-4.2 
     92TARGET_CFLAGS="-isysroot $TARGET_PLATFORM -march=i386" 
     93 
     94exec $TARGET_GCC $TARGET_CFLAGS "$@" 
     95}}} 
     96 
     97'''i386-apple-darwin11-ld''' 
     98{{{ 
     99#!/bin/sh 
     100 
     101TARGET_PLATFORM=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator6.1.sdk/ 
     102TARGET_BIN="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin" 
     103 
     104TARGET_LD=$TARGET_BIN/ld 
     105TARGET_LDFLAGS="-L$TARGET_PLATFORM/usr/lib/ -arch i386" 
     106 
     107exec $TARGET_LD $TARGET_LDFLAGS "$@" 
     108}}} 
     109 
     110'''i386-apple-darwin11-nm''' 
     111{{{ 
     112#!/bin/sh 
     113 
     114TARGET_BIN="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin" 
     115 
     116TARGET_NM=$TARGET_BIN/nm 
     117exec $TARGET_NM "$@" 
     118}}} 
     119 
     120'''i386-apple-darwin11-cabal''' (not needed during the build, but useful afterwards) 
     121{{{ 
     122#!/bin/sh 
     123exec cabal --with-ghc=i386-apple-darwin11-ghc --with-ghc-pkg=i386-apple-darwin11-ghc-pkg --with-ld=i386-apple-darwin11-ld \ 
     124--configure-option=--host=i386-apple-darwin11 \ 
    75125"$@" 
    76126}}} 
     
    105155=== 5. Configure & build === 
    106156 
     157For iOS: 
     158 
    107159{{{ 
    108160./configure --target=arm-apple-darwin10 --prefix=/usr/local/ghc-ios/ 
     
    112164}}} 
    113165 
     166For the iOS simulator: 
     167 
     168{{{ 
     169./configure --target=i386-apple-darwin11 --prefix=/usr/local/ghc-ios-sim/ 
     170make 
     171sudo mkdir -p /usr/local/ghc-ios-sim/ 
     172sudo make install 
     173}}} 
     174 
    114175=== 6. Create an Xcode project === 
    115176 
     
    118179=== 7. Compile your Haskell code === 
    119180 
    120 Open a terminal and add {{{/usr/local/ghc-ios/bin}}} to your {{{PATH}}} environment variable. 
     181Open a terminal and add {{{/usr/local/ghc-ios/bin:/usr/local/ghc-ios-sim/bin}}} to your {{{PATH}}} environment variable. 
    121182 
    122183Here's a skeleton '''haskell.hs''' to get you started: 
     
    182243 
    183244 * Fat binaries (done by lukexi) 
    184  * Cross-compiler for the iOS simulator 
     245 * Cross-compiler for the iOS simulator (done by lukexi) 
    185246 * Template Haskell for cross compilers! 
    186247 * Packaging with the wrapper scripts and perhaps release of binaries of official ghc releases