[commit: ghc] master: Adds aarch64 linker for mach-o files. (e8a2741)
git at git.haskell.org
git at git.haskell.org
Mon Mar 27 03:01:08 UTC 2017
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/e8a27410d0e51062422cb4782913bbbdf9deea74/ghc
>---------------------------------------------------------------
commit e8a27410d0e51062422cb4782913bbbdf9deea74
Author: Moritz Angermann <moritz.angermann at gmail.com>
Date: Tue Mar 21 11:02:20 2017 -0400
Adds aarch64 linker for mach-o files.
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
v
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 \
--with-opt=/path/to/llvm-3.9/bin/opt
# edit mk/build.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 \
--enable-bootstrap-with-devel-snapshot
# edit mk/build.mk to specify quick-cross
ghc $ make && make install
```
- Obtain the iOS wrapper scripts from
https://github.com/angerman/ghc-ios-scripts
and place them in PATH.
- 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 \
-opti5000
```
where 10.0.0.1 is the ip of your iserv-slave.
magic.
Reviewers: rwbarton, bgamari, austin, hvr, erikd, simonmar
Subscribers: thomie, erikd, ryantrinkle
Differential Revision: https://phabricator.haskell.org/D3255
>---------------------------------------------------------------
e8a27410d0e51062422cb4782913bbbdf9deea74
configure.ac | 2 +-
rts/linker/MachO.c | 748 +++++++++++++++++++++++++++++++++++++++++++++++++++--
2 files changed, 722 insertions(+), 28 deletions(-)
Diff suppressed because of size. To see it, use:
git diff-tree --root --patch-with-stat --no-color --find-copies-harder --ignore-space-at-eol --cc e8a27410d0e51062422cb4782913bbbdf9deea74
More information about the ghc-commits
mailing list