[Haskell-iPhone] Progress report: working GHC cross compiler
Stephen Blackheath [to GHC-iPhone]
likeliest.complexions.stephen at blacksapphire.com
Wed Nov 9 21:38:54 CET 2011
All,
It needs work yet, but I've got a GHC "toolchain" cross compiler
working, with an ARM linux target. This is an important step in making a
new GHC-iPhone cross compiler. The patches against GHC HEAD are here:
http://hip-to-be-square.com/~blackh/ghc-cross/
For ARM targets, you need llvm version 3.0 or greater (thanks to me,
Karel Gardas and David Terei). If it hasn't been released yet when you
read this, rc3 (which works for my ARMv5 target) can get got from:
http://llvm.org/pre-releases/3.0/
Incidentally, Ben Gamari is working on ghc linker support, which means
that ghci and runhaskell will work on ARM. Template Haskell might be
trickier, though, so it isn't supported for now in cross compilers.
"Cross compiling" with reference to GHC now means two things:
1. Porting GHC: If you want to port local-compiling GHC to a new
platform, do ./configure --host=arm-ldu-linux-gnueabi
2. My meaning - building a toolchain: To build a compiler that runs
locally but builds for a foreign platform, do ./configure
--target=arm-ldu-linux-gnueabi
I'll make sure I document this somewhere.
NOTES:
This patch assumes that the GNU convention is followed, that all the
cross-compiling tools are prefixed with the target name, e.g.
arm-ldu-linux-gnueabi-ld. iPhone doesn't follow this but I propose to
fix this with a directory full of symlinks.
'alien' is a script you have to provide to allow foreign code to be run
locally. This is required for a couple of things now, but (as Duncan
Coutts pointed out) this could probably ultimately be eliminated, using
the autotools AC_COMPUTE_INT technique (which interrogates the compiler
directly).
Following the convention of the Linux kernel, in these patches, Cabal
uses an environment variable called CROSS_COMPILE to supply a prefix for
all compile tools at runtime. The idea is that ghc and ghc-pkg's
executable names will also be prefixed with the target name. You would
use that in combination with PATH to switch between Cabal working for a
local compiler or for cross-compiling.
Steve
ON PC:
blackh at amentet:~/src/ghc$ inplace/bin/ghc-stage1 --version
The Glorious Glasgow Haskell Compilation System, version 7.3.20111107
blackh at amentet:~/src/ghc$ inplace/bin/ghc-stage1 pidigits.hs
[1 of 1] Compiling Main ( pidigits.hs, pidigits.o )
Linking pidigits ...
blackh at amentet:~/src/ghc$ scp pidigits root at 192.168.1.129:
root at 192.168.1.129's password:
pidigits 100% 9664KB 2.4MB/s 00:04
blackh at amentet:~/src/ghc$
ON TARGET MACHINE (QEMU)
root at ldu:~# uname -a
Linux ldu 2.6.37-versatile #2 Tue Oct 18 12:00:46 NZDT 2011 armv5tejl
GNU/Linux
root at ldu:~# ./pidigits 1000
3141592653 :10
5897932384 :20
6264338327 :30
9502884197 :40
1693993751 :50
0582097494 :60
4592307816 :70
4062862089 :80
9862803482 :90
5342117067 :100
9821480865 :110
1328230664 :120
7093844609 :130
5505822317 :140
2535940812 :150
8481117450 :160
2841027019 :170
3852110555 :180
9644622948 :190
9549303819 :200
6442881097 :210
5665933446 :220
1284756482 :230
3378678316 :240
5271201909 :250
1456485669 :260
2346034861 :270
0454326648 :280
2133936072 :290
6024914127 :300
3724587006 :310
6063155881 :320
7488152092 :330
0962829254 :340
0917153643 :350
6789259036 :360
0011330530 :370
5488204665 :380
2138414695 :390
1941511609 :400
4330572703 :410
6575959195 :420
3092186117 :430
3819326117 :440
9310511854 :450
8074462379 :460
9627495673 :470
5188575272 :480
4891227938 :490
1830119491 :500
2983367336 :510
2440656643 :520
0860213949 :530
4639522473 :540
7190702179 :550
8609437027 :560
7053921717 :570
6293176752 :580
3846748184 :590
6766940513 :600
2000568127 :610
1452635608 :620
2778577134 :630
2757789609 :640
1736371787 :650
2146844090 :660
1224953430 :670
1465495853 :680
7105079227 :690
9689258923 :700
5420199561 :710
1212902196 :720
0864034418 :730
1598136297 :740
7477130996 :750
0518707211 :760
3499999983 :770
7297804995 :780
1059731732 :790
8160963185 :800
9502445945 :810
5346908302 :820
6425223082 :830
5334468503 :840
5261931188 :850
1710100031 :860
3783875288 :870
6587533208 :880
3814206171 :890
7766914730 :900
3598253490 :910
4287554687 :920
3115956286 :930
3882353787 :940
5937519577 :950
8185778053 :960
2171226806 :970
6130019278 :980
7661119590 :990
9216420198 :1000
root at ldu:~#
More information about the iPhone
mailing list