forked from wavewave/nix-build-ghc-android
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ghc-android.nix
97 lines (82 loc) · 3.01 KB
/
ghc-android.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{ stdenv, fetchurl, makeWrapper, perl, m4, autoconf, automake
, llvm_35, haskell, ncurses
, androidndk
, ghc
}:
let ndkWrapper = import ./ndk-wrapper.nix { inherit stdenv makeWrapper androidndk; };
ncurses_ndk = import ./ncurses.nix { inherit stdenv fetchurl ncurses ndkWrapper androidndk; };
libiconv_ndk = import ./libiconv.nix { inherit stdenv fetchurl ndkWrapper androidndk; };
in stdenv.mkDerivation {
name = "ghc-android";
version = "7.10.2";
src = fetchurl {
url = "https://downloads.haskell.org/~ghc/7.10.2/ghc-7.10.2-src.tar.xz";
sha256 = "1x8m4rp2v7ydnrz6z9g8x7z3x3d3pxhv2pixy7i7hkbqbdsp7kal";
};
buildInputs = [ ghc
perl
llvm_35
ndkWrapper
androidndk
m4 autoconf automake
ncurses_ndk libiconv_ndk
ncurses
];
patches = [ ./unix-posix_vdisable.patch
./unix-posix-files-imports.patch
./enable-fPIC.patch
./no-pthread-android.patch
./force_CC_SUPPORTS_TLS_equal_zero.patch
./undefine_MYTASK_USE_TLV_for_CC_SUPPORTS_TLS_zero.patch
./force-relocation-equal-pic.patch
./rts_android_log_write.patch
];
preConfigure = ''
cat > mk/build.mk <<EOF
BuildFlavour = quick-cross
SRC_HC_OPTS = -H64m -O0
GhcStage1HcOpts = -O -fPIC
GhcStage2HcOpts = -O0 -fPIC -fllvm
SplitObjs = NO
Stage1Only = YES
DYNAMIC_BY_DEFAULT = NO
DYNAMIC_GHC_PROGRAMS = NO
HADDOCK_DOCS = NO
BUILD_DOCBOOK_HTML = NO
BUILD_DOCBOOK_PS = NO
BUILD_DOCBOOK_PDF = NO
INTEGER_LIBRARY = integer-simple
GhcHcOpts = -Rghc-timing
GhcLibWays = v thr p
libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-includes=${libiconv_ndk}/include
libraries/base_CONFIGURE_OPTS += --configure-option=--with-iconv-libraries=${libiconv_ndk}/lib
libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-includes=${ncurses_ndk}/include
libraries/terminfo_CONFIGURE_OPTS += --configure-option=--with-curses-libraries=${ncurses_ndk}/lib
#utils/ghc-pkg_HC_OPTS += -optl-llog
#utils/hsc2hs_HC_OPTS += -optl-llog
#utils/ghc-pkg_CONFIGURE_OPTS += --configure-option=--ld-options=-llog
#utils/hsc2hs_CONFIGURE_OPTS += --configure-option=--ld-options=-llog
EOF
perl boot
'';
#CONF_LD_LINKER_OPTS_STAGE2="-llog";
#TargetElf = NO
configureFlags = [
"--target=arm-linux-androideabi"
"--host=x86_64-unknown-linux-gnu"
"--build=x86_64-unknown-linux-gnu"
"--with-gcc=${ndkWrapper}/bin/arm-linux-androideabi-gcc"
];
phases = [ "unpackPhase" "patchPhase" "configurePhase" "buildPhase" "installPhase" ];
#buildPhase = ''
# make phase_1_builds
#'';
enableParallelBuilding = true;
passthru = {
isGhcAndroid = true;
nativeGhc = haskell.compiler.ghc7102;
androidndk = ndkWrapper;
};
meta.license = stdenv.lib.licenses.bsd3;
meta.platforms = ["x86_64-linux"];
}