1
- { stdenv , buildPackages , ghc
2
- , jailbreak-cabal , hscolour , cpphs , nodejs
3
- , buildPlatform , hostPlatform
1
+ { stdenv , fetchurl , ghc , pkgconfig , glibcLocales , coreutils , gnugrep , gnused
2
+ , jailbreak-cabal , hscolour , cpphs , nodejs , lib , removeReferencesTo
4
3
} :
5
-
6
- let
7
- isCross = buildPlatform != hostPlatform ;
8
- inherit ( buildPackages )
9
- fetchurl removeReferencesTo
10
- pkgconfig binutils coreutils gnugrep gnused glibcLocales ;
11
- in
4
+ let isCross = ( ghc . cross or null ) != null ; in
12
5
13
6
{ pname
14
7
, dontStrip ? ( ghc . isGhcjs or false )
27
20
, enableLibraryProfiling ? false
28
21
, enableExecutableProfiling ? false
29
22
# TODO enable shared libs for cross-compiling
30
- , enableSharedExecutables ? ( ( ghc . isGhcjs or false ) || stdenv . lib . versionOlder "7.7" ghc . version )
31
- , enableSharedLibraries ? ( ( ghc . isGhcjs or false ) || stdenv . lib . versionOlder "7.7" ghc . version )
23
+ , enableSharedExecutables ? ! isCross && ( ( ( ghc . isGhcjs or false ) || stdenv . lib . versionOlder "7.7" ghc . version ) )
24
+ , enableSharedLibraries ? ! isCross && ( ( ( ghc . isGhcjs or false ) || stdenv . lib . versionOlder "7.7" ghc . version ) )
32
25
, enableSplitObjs ? null # OBSOLETE, use enableDeadCodeElimination
33
26
, enableDeadCodeElimination ? ( ! stdenv . isDarwin ) # TODO: use -dead_strip for darwin
34
27
, enableStaticLibraries ? true
60
53
, shellHook ? ""
61
54
, coreSetup ? false # Use only core packages to build Setup.hs.
62
55
, useCpphs ? false
63
- , hardeningDisable ? stdenv . lib . optional ( ghc . isHaLVM or false ) "all"
56
+ , hardeningDisable ? lib . optional ( ghc . isHaLVM or false ) "all"
64
57
, enableSeparateDataOutput ? false
65
58
, enableSeparateDocOutput ? doHaddock
66
59
} @ args :
@@ -109,12 +102,11 @@ let
109
102
enableParallelBuilding = ( versionOlder "7.8" ghc . version && ! hasActiveLibrary ) || versionOlder "8.0.1" ghc . version ;
110
103
111
104
crossCabalFlags = [
112
- "--with-ghc=${ ghc . prefix } ghc"
113
- "--with-ghc-pkg=${ ghc . prefix } ghc-pkg"
114
- "--with-gcc=${ ghc . prefix } cc "
115
- "--with-ld=${ ghc . prefix } ld "
105
+ "--with-ghc=${ ghc . cross . config } - ghc"
106
+ "--with-ghc-pkg=${ ghc . cross . config } - ghc-pkg"
107
+ "--with-gcc=${ ghc . cc } "
108
+ "--with-ld=${ ghc . ld } "
116
109
"--with-hsc2hs=${ nativeGhc } /bin/hsc2hs"
117
- "--with-strip=${ binutils } /bin/${ ghc . prefix } strip"
118
110
] ++ ( if isHaLVM then [ ] else [ "--hsc2hs-options=--cross-compile" ] ) ;
119
111
120
112
crossCabalFlagsString =
143
135
] ++ optionals isGhcjs [
144
136
"--ghcjs"
145
137
] ++ optionals isCross ( [
146
- "--configure-option=--host=${ hostPlatform . config } "
138
+ "--configure-option=--host=${ ghc . cross . config } "
147
139
] ++ crossCabalFlags ) ;
148
140
149
141
setupCompileFlags = [
178
170
setupBuilder = if isCross then "${ nativeGhc } /bin/ghc" else ghcCommand ;
179
171
setupCommand = "./Setup" ;
180
172
ghcCommand' = if isGhcjs then "ghcjs" else "ghc" ;
181
- ghcCommand = "${ ghc . prefix } ${ ghcCommand' } " ;
173
+ crossPrefix = if ( ghc . cross or null ) != null then "${ ghc . cross . config } -" else "" ;
174
+ ghcCommand = "${ crossPrefix } ${ ghcCommand' } " ;
182
175
ghcCommandCaps = toUpper ghcCommand' ;
183
176
184
177
in
@@ -275,8 +268,6 @@ stdenv.mkDerivation ({
275
268
runHook postCompileBuildDriver
276
269
'' ;
277
270
278
- inherit configureFlags ;
279
-
280
271
configurePhase = ''
281
272
runHook preConfigure
282
273
@@ -402,6 +393,7 @@ stdenv.mkDerivation ({
402
393
// optionalAttrs ( postCompileBuildDriver != "" ) { inherit postCompileBuildDriver ; }
403
394
// optionalAttrs ( preUnpack != "" ) { inherit preUnpack ; }
404
395
// optionalAttrs ( postUnpack != "" ) { inherit postUnpack ; }
396
+ // optionalAttrs ( configureFlags != [ ] ) { inherit configureFlags ; }
405
397
// optionalAttrs ( patches != [ ] ) { inherit patches ; }
406
398
// optionalAttrs ( patchPhase != "" ) { inherit patchPhase ; }
407
399
// optionalAttrs ( preConfigure != "" ) { inherit preConfigure ; }
@@ -420,5 +412,5 @@ stdenv.mkDerivation ({
420
412
// optionalAttrs ( postFixup != "" ) { inherit postFixup ; }
421
413
// optionalAttrs ( dontStrip ) { inherit dontStrip ; }
422
414
// optionalAttrs ( hardeningDisable != [ ] ) { inherit hardeningDisable ; }
423
- // optionalAttrs ( buildPlatform . isLinux ) { LOCALE_ARCHIVE = "${ glibcLocales } /lib/locale/locale-archive" ; }
415
+ // optionalAttrs ( stdenv . isLinux ) { LOCALE_ARCHIVE = "${ glibcLocales } /lib/locale/locale-archive" ; }
424
416
)
0 commit comments