Adds aarch64 linker for mach-o files.
Needs ReviewPublic

Authored by angerman on Wed, Mar 1, 7:54 AM.



This is the final commit that ties them all together. Here we
add the aarch64 linker for macho files.

  • In D3238 we started allowing preloading object code with mmap in iOS, where we can't have r+w+x.
  • In D3239 we introduced a richer extension of the object code data type to make working with mach-o files easier.
  • In D3240 we set the stage to allow loading archives (.a) on iOS
  • In D3251 we added init and deinit functions to populate and depopulate the enriched object code data structure for mach-o files.
  • In D3252 we refactored most of the MachO.c file to use the new types and datastructure.

This commit will than finally add the aarch64 (arm64) linker
for mach-o files to ghc, using the improved foundation we
have constructed above.

The dependency structure therefore is as follows

  .- D3240
This <- D3252 <- D3251 <- D3239
  '- D3238

Depends: D3252, D3240, D3238

Test Plan

To test this with iOS, we also need the remote-iserv
diff D3233. With all that in place, proceed as follows:

  • Build ghc for the host
ghc $ ./configure --prefix=/test/opt \
  --disable-large-address-space \
  --with-llc=/path/to/llvm-3.9/bin/llc \
# edit mk/ to specify quick
ghc $ make && make install
  • Build ghc for ios
ghc $ ./configure --target=aarch64-apple-darwin14 \
  --prefix=/test/opt \
  --disable-large-address-space \
  --with-llc=/path/to/llvm-3.9/bin/llc \
  --with-opt=/path/to/llvm-3.9/bin/opt \
  --with-ghc=/test/bin/ghc \
# edit mk/ to specify quick-cross
ghc $ make && make install
  • Build iserv-proxy for the host
ghc/iserv $ cabal install -fproxy -flibrary
  • Build iserv-library for the target
# build cryptonite without integer-gmp
ghc/iserv $ aarch64-apple-darwin14-cabal install cryptonite -f-integer-gmp
ghc/iserv $ aarch64-apple-darwin14-cabal install -flibrary
  • Create an iOS application with the following main.m:
#import <UIKit/UIKit.h>
#include "HsFFI.h"
extern void startSlave(bool, int, const char *);

int main(int argc, char * argv[]) {
  const char * documents_path = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] firstObject].path.UTF8String;
  hs_init(NULL, NULL);

  startSlave(false, 5000, documents_path);
  @autoreleasepool {
      return UIApplicationMain(argc, argv, nil, nil);
and link it with: the iserv archive from `~/.cabal/lib/aarch64-ios-ghc`
as well as all dependent archives.
  • Build, Install and Launch the iserv-slave application on your iphone
  • Compile some Template Haskell code with the aarch64-apple-darwin14-ghc, through the iserv-proxy
app $ aarch64-apple-darwin14-ghc Module.hs \
 -threaded -staticlib \
 -outputdir build/aarch64 -pgmlibtool libtool-quiet -stubdir . \
 -fexternal-interpreter \
 -pgmi=$HOME/.cabal/bin/iserv-proxy \
 -opti10.0.0.1 \
where is the ip of your iserv-slave.


Diff Detail

rGHC Glasgow Haskell Compiler
Lint WarningsExcuse: readability
Warningrts/linker/MachO.c:374TXT3Line Too Long
Warningrts/linker/MachO.c:375TXT3Line Too Long
Warningrts/linker/MachO.c:376TXT3Line Too Long
Warningrts/linker/MachO.c:377TXT3Line Too Long
Warningrts/linker/MachO.c:673TXT3Line Too Long
Warningrts/linker/MachO.c:713TXT3Line Too Long
Warningrts/linker/MachO.c:715TXT3Line Too Long
Warningrts/linker/MachO.c:716TXT3Line Too Long
Warningrts/linker/MachO.c:727TXT3Line Too Long
Warningrts/linker/MachO.c:728TXT3Line Too Long
Warningrts/linker/MachO.c:729TXT3Line Too Long
Warningrts/linker/MachO.c:738TXT3Line Too Long
Warningrts/linker/MachO.c:739TXT3Line Too Long
Warningrts/linker/MachO.c:740TXT3Line Too Long
Warningrts/linker/MachO.c:744TXT3Line Too Long
Warningrts/linker/MachO.c:1424TXT3Line Too Long
Warningrts/linker/MachO.c:1464TXT3Line Too Long
Warningrts/linker/MachO.c:1469TXT3Line Too Long
Warningrts/linker/MachO.c:1477TXT3Line Too Long
Warningrts/linker/MachO.c:1509TXT3Line Too Long
No Unit Test Coverage
Build Status
Buildable 14782
Build 23834: [GHC] Linux/amd64: Patch building
Build 23833: [GHC] OSX/amd64: Continuous Integration
Build 23832: [GHC] Windows/amd64: Continuous Integration (compile only)
Build 23831: arc lint + arc unit
angerman created this revision.Wed, Mar 1, 7:54 AM
angerman edited the test plan for this revision. (Show Details)Wed, Mar 1, 7:57 AM
angerman edited the test plan for this revision. (Show Details)
angerman edited the test plan for this revision. (Show Details)Wed, Mar 1, 8:01 AM
angerman updated this revision to Diff 11482.Thu, Mar 2, 9:46 AM
  • Range Check, Proddable sections.
angerman updated this revision to Diff 11533.Fri, Mar 3, 1:43 AM
  • update to latest consistant state (with object code info structs)
angerman updated this revision to Diff 11782.Thu, Mar 16, 10:51 PM
angerman updated this revision to Diff 11836.Tue, Mar 21, 3:39 AM
  • Always populate the info struct.