@@ -1,457 +0,0 @@
{ lib , stdenv
, fetchurl , perl , gcc
, ncurses5
, ncurses6 , gmp , libiconv , numactl
, llvmPackages
, coreutils
, targetPackages
# minimal = true; will remove files that aren't strictly necessary for
# regular builds and GHC bootstrapping.
# This is "useful" for staying within hydra's output limits for at least the
# aarch64-linux architecture.
, minimal ? false
}:
# Prebuilt only does native
assert stdenv . targetPlatform = = stdenv . hostPlatform ;
let
downloadsUrl = " h t t p s : / / d o w n l o a d s . h a s k e l l . o r g / g h c " ;
version = " 8 . 1 0 . 2 " ;
# Information about available bindists that we use in the build.
#
# # Bindist library checking
#
# The field `archSpecificLibraries` also provides a way for us get notified
# early when the upstream bindist changes its dependencies (e.g. because a
# newer Debian version is used that uses a new `ncurses` version).
#
# Usage:
#
# * You can find the `fileToCheckFor` of libraries by running `readelf -d`
# on the compiler binary (`exePathForLibraryCheck`).
# * To skip library checking for an architecture,
# set `exePathForLibraryCheck = null`.
# * To skip file checking for a specific arch specfic library,
# set `fileToCheckFor = null`.
ghcBinDists = {
# Binary distributions for the default libc (e.g. glibc, or libSystem on Darwin)
# nixpkgs uses for the respective system.
defaultLibc = {
i686-linux = {
variantSuffix = " " ;
src = {
url = " ${ downloadsUrl } / ${ version } / g h c - ${ version } - i 3 8 6 - d e b 9 - l i n u x . t a r . x z " ;
sha256 = " 0 b v w i s l 4 w 0 z 5 z 8 z 0 d a 1 0 m 9 s v 0 m h m 9 n a 2 q m 4 3 q x r 8 z l 2 3 m n 3 2 m b l x " ;
} ;
exePathForLibraryCheck = " g h c / s t a g e 2 / b u i l d / t m p / g h c - s t a g e 2 " ;
archSpecificLibraries = [
{ nixPackage = gmp ; fileToCheckFor = null ; }
# The i686-linux bindist provided by GHC HQ is currently built on Debian 9,
# which link it against `libtinfo.so.5` (ncurses 5).
# Other bindists are linked `libtinfo.so.6` (ncurses 6).
{ nixPackage = ncurses5 ; fileToCheckFor = " l i b t i n f o . s o . 5 " ; }
] ;
} ;
x86_64-linux = {
variantSuffix = " " ;
src = {
url = " ${ downloadsUrl } / ${ version } / g h c - ${ version } - x 8 6 _ 6 4 - d e b 1 0 - l i n u x . t a r . x z " ;
sha256 = " 0 c h n z y 9 j 2 3 b 2 w a 8 c l x 5 a r w z 8 w n j f x y j m z 9 q k j 5 4 8 z 1 4 c q f 1 3 s l c l " ;
} ;
exePathForLibraryCheck = " g h c / s t a g e 2 / b u i l d / t m p / g h c - s t a g e 2 " ;
archSpecificLibraries = [
{ nixPackage = gmp ; fileToCheckFor = null ; }
{ nixPackage = ncurses6 ; fileToCheckFor = " l i b t i n f o . s o . 6 " ; }
] ;
} ;
armv7l-linux = {
variantSuffix = " " ;
src = {
url = " ${ downloadsUrl } / ${ version } / g h c - ${ version } - a r m v 7 - d e b 1 0 - l i n u x . t a r . x z " ;
sha256 = " 1 j 4 1 c q 5 d 3 r m l g z 7 h z w 8 f 9 0 8 f s 7 9 g c 5 m n 3 q 5 w z 2 7 7 l k 8 z d f 1 9 g 7 5 v " ;
} ;
exePathForLibraryCheck = " g h c / s t a g e 2 / b u i l d / t m p / g h c - s t a g e 2 " ;
archSpecificLibraries = [
{ nixPackage = gmp ; fileToCheckFor = null ; }
{ nixPackage = ncurses6 ; fileToCheckFor = " l i b t i n f o . s o . 6 " ; }
] ;
} ;
aarch64-linux = {
variantSuffix = " " ;
src = {
url = " ${ downloadsUrl } / ${ version } / g h c - ${ version } - a a r c h 6 4 - d e b 1 0 - l i n u x . t a r . x z " ;
sha256 = " 1 4 s m w l 3 7 4 1 i x n b g i 0 l 5 1 a 7 k h 7 x j k i a n n f q x 1 5 b 7 2 s v k y 0 y 4 l 3 w j w " ;
} ;
exePathForLibraryCheck = " g h c / s t a g e 2 / b u i l d / t m p / g h c - s t a g e 2 " ;
archSpecificLibraries = [
{ nixPackage = gmp ; fileToCheckFor = null ; }
{ nixPackage = ncurses6 ; fileToCheckFor = " l i b t i n f o . s o . 6 " ; }
{ nixPackage = numactl ; fileToCheckFor = null ; }
] ;
} ;
x86_64-darwin = {
variantSuffix = " " ;
src = {
url = " ${ downloadsUrl } / ${ version } / g h c - ${ version } - x 8 6 _ 6 4 - a p p l e - d a r w i n . t a r . x z " ;
sha256 = " 1 h n g y q 1 4 l 4 f 9 5 0 h z h h 2 d 2 0 4 c a 2 g f c 9 8 p c 9 x d a s x i h z q d 1 j q 7 5 d z d " ;
} ;
exePathForLibraryCheck = null ; # we don't have a library check for darwin yet
archSpecificLibraries = [
{ nixPackage = gmp ; fileToCheckFor = null ; }
{ nixPackage = ncurses6 ; fileToCheckFor = null ; }
{ nixPackage = libiconv ; fileToCheckFor = null ; }
] ;
} ;
} ;
# Binary distributions for the musl libc for the respective system.
musl = {
x86_64-linux = {
variantSuffix = " - m u s l " ;
src = {
url = " ${ downloadsUrl } / ${ version } / g h c - ${ version } - x 8 6 _ 6 4 - a l p i n e 3 . 1 0 - l i n u x - i n t e g e r - s i m p l e . t a r . x z " ;
sha256 = " 0 x p c b y a x q y h b l 6 f 0 i 3 s 4 r p 2 j m 6 7 n q p k f h 2 q l b j 3 i 2 f i a i x 8 9 m l 0 l " ;
} ;
exePathForLibraryCheck = " b i n / g h c " ;
archSpecificLibraries = [
{ nixPackage = gmp ; fileToCheckFor = null ; }
# In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*`
# instead of `libtinfo.so.*.`
{ nixPackage = ncurses6 ; fileToCheckFor = " l i b n c u r s e s w . s o . 6 " ; }
] ;
isHadrian = true ;
} ;
} ;
} ;
distSetName = if stdenv . hostPlatform . isMusl then " m u s l " else " d e f a u l t L i b c " ;
binDistUsed = ghcBinDists . ${ distSetName } . ${ stdenv . hostPlatform . system }
or ( throw " c a n n o t b o o t s t r a p G H C o n t h i s p l a t f o r m ( ' ${ stdenv . hostPlatform . system } ' w i t h l i b c ' ${ distSetName } ' ) " ) ;
useLLVM = ! stdenv . targetPlatform . isx86 ;
libPath =
lib . makeLibraryPath (
# Add arch-specific libraries.
map ( { nixPackage , . . . }: nixPackage ) binDistUsed . archSpecificLibraries
) ;
libEnvVar = lib . optionalString stdenv . hostPlatform . isDarwin " D Y "
+ " L D _ L I B R A R Y _ P A T H " ;
runtimeDeps = [
targetPackages . stdenv . cc
targetPackages . stdenv . cc . bintools
coreutils # for cat
]
++ lib . optionals useLLVM [
( lib . getBin llvmPackages . llvm )
]
# On darwin, we need unwrapped bintools as well (for otool)
++ lib . optionals ( stdenv . targetPlatform . linker = = " c c t o o l s " ) [
targetPackages . stdenv . cc . bintools . bintools
] ;
in
stdenv . mkDerivation rec {
inherit version ;
pname = " g h c - b i n a r y ${ binDistUsed . variantSuffix } " ;
src = fetchurl binDistUsed . src ;
# Note that for GHC 8.10 versions <= 8.10.5, the GHC HQ musl bindist
# has a `gmp` dependency:
# https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d
# Related nixpkgs issues:
# * https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922452843
nativeBuildInputs = [ perl ] ;
propagatedBuildInputs =
# Because musl bindists currently provide no way to tell where
# libgmp is (see not [musl bindists have no .buildinfo]), we need
# to propagate `gmp`, otherwise programs built by this ghc will
# fail linking with `cannot find -lgmp` errors.
# Concrete cases are listed in:
# https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922459988
#
# Also, as of writing, the release pages of musl bindists claim
# that they use `integer-simple` and do not require `gmp`; however
# that is incorrect, so `gmp` is required until a release has been
# made that includes https://gitlab.haskell.org/ghc/ghc/-/issues/20059.
# (Note that for packaging the `-binary` compiler, nixpkgs does not care
# about whether or not `gmp` is used; this comment is just here to explain
# why the `gmp` dependency exists despite what the release page says.)
#
# For GHC >= 8.10.6, `gmp` was switched out for `integer-simple`
# (https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d),
# fixing the above-mentioned release issue,
# and for GHC >= 9.* it is not clear as of writing whether that switch
# will be made there too.
lib . optionals stdenv . hostPlatform . isMusl [ gmp ] ; # musl bindist needs this
# Set LD_LIBRARY_PATH or equivalent so that the programs running as part
# of the bindist installer can find the libraries they expect.
# Cannot patchelf beforehand due to relative RPATHs that anticipate
# the final install location.
${ libEnvVar } = libPath ;
postUnpack =
# Verify our assumptions of which `libtinfo.so` (ncurses) version is used,
# so that we know when ghc bindists upgrade that and we need to update the
# version used in `libPath`.
lib . optionalString
( binDistUsed . exePathForLibraryCheck != null )
# Note the `*` glob because some GHCs have a suffix when unpacked, e.g.
# the musl bindist has dir `ghc-VERSION-x86_64-unknown-linux/`.
# As a result, don't shell-quote this glob when splicing the string.
( let buildExeGlob = '' g h c - ${ version } * / " ${ binDistUsed . exePathForLibraryCheck } " '' ; in
lib . concatStringsSep " \n " [
( ''
s h o p t - u n u l l g l o b
e c h o " C h e c k i n g t h a t g h c b i n a r y e x i s t s i n b i n d i s t a t ${ buildExeGlob } "
i f ! t e s t - e ${ buildExeGlob } ; t h e n
e c h o > & 2 " G H C b i n a r y ${ binDistUsed . exePathForLibraryCheck } c o u l d n o t b e f o u n d i n t h e b i n d i s t b u i l d d i r e c t o r y ( a t ${ buildExeGlob } ) f o r a r c h ${ stdenv . hostPlatform . system } , p l e a s e c h e c k t h a t g h c B i n D i s t s c o r r e c t l y r e f l e c t t h e b i n d i s t d e p e n d e n c i e s ! " ; e x i t 1 ;
f i
'' )
( lib . concatMapStringsSep
" \n "
( { fileToCheckFor , nixPackage }:
lib . optionalString ( fileToCheckFor != null ) ''
e c h o " C h e c k i n g b i n d i s t f o r ${ fileToCheckFor } t o e n s u r e t h a t i s s t i l l u s e d "
i f ! r e a d e l f - d ${ buildExeGlob } | g r e p " ${ fileToCheckFor } " ; t h e n
e c h o > & 2 " F i l e ${ fileToCheckFor } c o u l d n o t b e f o u n d i n ${ binDistUsed . exePathForLibraryCheck } f o r a r c h ${ stdenv . hostPlatform . system } , p l e a s e c h e c k t h a t g h c B i n D i s t s c o r r e c t l y r e f l e c t t h e b i n d i s t d e p e n d e n c i e s ! " ; e x i t 1 ;
f i
e c h o " C h e c k i n g t h a t t h e n i x p a c k a g e ${ nixPackage } c o n t a i n s ${ fileToCheckFor } "
i f ! t e s t - e " ${ lib . getLib nixPackage } / l i b / ${ fileToCheckFor } " ; t h e n
e c h o > & 2 " N i x p a c k a g e ${ nixPackage } d i d n o t c o n t a i n ${ fileToCheckFor } f o r a r c h ${ stdenv . hostPlatform . system } , p l e a s e c h e c k t h a t g h c B i n D i s t s c o r r e c t l y r e f l e c t t h e b i n d i s t d e p e n d e n c i e s ! " ; e x i t 1 ;
f i
''
)
binDistUsed . archSpecificLibraries
)
] )
# GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
# during linking
+ lib . optionalString stdenv . isDarwin ''
e x p o r t N I X _ L D F L A G S + = " - n o _ d t r a c e _ d o f "
# n o t e n o u g h r o o m i n t h e o b j e c t f i l e s f o r t h e f u l l p a t h t o l i b i c o n v : (
f o r e x e i n $( f i n d . - t y p e f - e x e c u t a b l e ) ; d o
i s S c r i p t $e x e & & c o n t i n u e
l n - f s ${ libiconv } / l i b / l i b i c o n v . d y l i b $( d i r n a m e $e x e ) / l i b i c o n v . d y l i b
i n s t a l l _ n a m e _ t o o l - c h a n g e / u s r / l i b / l i b i c o n v . 2 . d y l i b @ e x e c u t a b l e _ p a t h / l i b i c o n v . d y l i b - c h a n g e / u s r / l o c a l / l i b / g c c / 6 / l i b g c c _ s . 1 . d y l i b ${ gcc . cc . lib } / l i b / l i b g c c _ s . 1 . d y l i b $e x e
d o n e
'' +
# Some scripts used during the build need to have their shebangs patched
''
p a t c h S h e b a n g s g h c - ${ version } / u t i l s /
p a t c h S h e b a n g s g h c - ${ version } / c o n f i g u r e
t e s t - d g h c - ${ version } / i n p l a c e / b i n & & \
p a t c h S h e b a n g s g h c - ${ version } / i n p l a c e / b i n
'' +
# We have to patch the GMP paths for the integer-gmp package.
# Note [musl bindists have no .buildinfo]
# Note that musl bindists do not contain them; unclear if that's intended;
# see: https://gitlab.haskell.org/ghc/ghc/-/issues/20073#note_363231
''
f i n d . - n a m e i n t e g e r - g m p . b u i l d i n f o \
- e x e c s e d - i " s @ e x t r a - l i b - d i r s : @ e x t r a - l i b - d i r s : ${ gmp . out } / l i b @ " { } \ ;
'' + lib . optionalString stdenv . isDarwin ''
f i n d . - n a m e b a s e . b u i l d i n f o \
- e x e c s e d - i " s @ e x t r a - l i b - d i r s : @ e x t r a - l i b - d i r s : ${ libiconv } / l i b @ " { } \ ;
'' +
# aarch64 does HAVE_NUMA so -lnuma requires it in library-dirs in rts/package.conf.in
# FFI_LIB_DIR is a good indication of places it must be needed.
lib . optionalString stdenv . hostPlatform . isAarch64 ''
f i n d . - n a m e p a c k a g e . c o n f . i n \
- e x e c s e d - i " s @ F F I _ L I B _ D I R @ F F I _ L I B _ D I R ${ numactl . out } / l i b @ g " { } \ ;
'' +
# Rename needed libraries and binaries, fix interpreter
lib . optionalString stdenv . isLinux ''
f i n d . - t y p e f - e x e c u t a b l e - e x e c p a t c h e l f \
- - i n t e r p r e t e r ${ stdenv . cc . bintools . dynamicLinker } { } \ ;
'' +
# The hadrian install Makefile uses 'xxx' as a temporary placeholder in path
# substitution. Which can break the build if the store path / prefix happens
# to contain this string. This will be fixed with 9.4 bindists.
# https://gitlab.haskell.org/ghc/ghc/-/issues/21402
''
# D e t e c t h a d r i a n M a k e f i l e b y c h e c k i n g f o r t h e t a r g e t t h a t h a s t h e p r o b l e m
i f g r e p ' ^ u p d a t e _ p a c k a g e _ d b ' g h c - ${ version } * / M a k e f i l e > / d e v / n u l l ; t h e n
e c h o H a d r i a n b i n d i s t , a p p l y i n g w o r k a r o u n d f o r x x x p a t h s u b s t i t u t i o n .
# b a s e d o n h t t p s : / / g i t l a b . h a s k e l l . o r g / g h c / g h c / - / c o m m i t / d d 5 f e c b 0 e 2 9 9 0 b 1 9 2 d 9 2 f 4 d f d 7 5 1 9 e c b 3 3 1 6 4 f a d . p a t c h
s u b s t i t u t e I n P l a c e g h c - ${ version } * / M a k e f i l e - - r e p l a c e ' x x x ' ' \ 0 x x x \ 0 '
e l s e
e c h o N o t a h a d r i a n b i n d i s t , n o t a p p l y i n g x x x p a t h w o r k a r o u n d .
f i
'' ;
# fix for `configure: error: Your linker is affected by binutils #16177`
preConfigure = lib . optionalString
stdenv . targetPlatform . isAarch32
" L D = l d . g o l d " ;
configurePlatforms = [ ] ;
configureFlags = [
" - - w i t h - g m p - i n c l u d e s = ${ lib . getDev gmp } / i n c l u d e "
# Note `--with-gmp-libraries` does nothing for GHC bindists:
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
] ++ lib . optional stdenv . isDarwin " - - w i t h - g c c = ${ ./gcc-clang-wrapper.sh } "
# From: https://github.com/NixOS/nixpkgs/pull/43369/commits
++ lib . optional stdenv . hostPlatform . isMusl " - - d i s a b l e - l d - o v e r r i d e " ;
# No building is necessary, but calling make without flags ironically
# calls install-strip ...
dontBuild = true ;
# Patch scripts to include runtime dependencies in $PATH.
postInstall = ''
f o r i i n " $o u t / b i n / " * ; d o
t e s t ! - h " $i " | | c o n t i n u e
i s S c r i p t " $i " | | c o n t i n u e
s e d - i - e ' 2 i e x p o r t P A T H = " ${ lib . makeBinPath runtimeDeps } : $P A T H " ' " $i "
d o n e
'' ;
# Apparently necessary for the ghc Alpine (musl) bindist:
# When we strip, and then run the
# patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
# below, running ghc (e.g. during `installCheckPhase)` gives some apparently
# corrupted rpath or whatever makes the loader work on nonsensical strings:
# running install tests
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: : symbol not found
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: ir6zf6c9f86pfx8sr30n2vjy-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: y/lib/ghc-8.10.5/bin/../lib/x86_64-linux-ghc-8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 8.10.5/libHStemplate-haskell-2.16.0.0-ghc8.10.5.so: symbol not found
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: <20> : symbol not found
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: <20> ?: symbol not found
# Error relocating /nix/store/...-ghc-8.10.2-binary/lib/ghc-8.10.5/bin/ghc: 64-linux-ghc-8.10.5/libHSexceptions-0.10.4-ghc8.10.5.so: symbol not found
# This is extremely bogus and should be investigated.
dontStrip = if stdenv . hostPlatform . isMusl then true else false ; # `if` for explicitness
# On Linux, use patchelf to modify the executables so that they can
# find editline/gmp.
postFixup = lib . optionalString stdenv . isLinux
( if stdenv . hostPlatform . isAarch64 then
# Keep rpath as small as possible on aarch64 for patchelf#244. All Elfs
# are 2 directories deep from $out/lib, so pooling symlinks there makes
# a short rpath.
''
( c d $o u t / l i b ; l n - s ${ ncurses6 . out } / l i b / l i b t i n f o . s o . 6 )
( c d $o u t / l i b ; l n - s ${ gmp . out } / l i b / l i b g m p . s o . 1 0 )
( c d $o u t / l i b ; l n - s ${ numactl . out } / l i b / l i b n u m a . s o . 1 )
f o r p i n $( f i n d " $o u t / l i b " - t y p e f - n a m e " * \ . s o * " ) ; d o
( c d $o u t / l i b ; l n - s $p )
d o n e
f o r p i n $( f i n d " $o u t / l i b " - t y p e f - e x e c u t a b l e ) ; d o
i f i s E L F " $p " ; t h e n
e c h o " P a t c h e l f i n g $p "
p a t c h e l f - - s e t - r p a t h " \ $O R I G I N : \ $O R I G I N / . . / . . " $p
f i
d o n e
''
else
''
f o r p i n $( f i n d " $o u t " - t y p e f - e x e c u t a b l e ) ; d o
i f i s E L F " $p " ; t h e n
e c h o " P a t c h e l f i n g $p "
p a t c h e l f - - s e t - r p a t h " ${ libPath } : $( p a t c h e l f - - p r i n t - r p a t h $p ) " $p
f i
d o n e
'' ) + lib . optionalString stdenv . isDarwin ''
# n o t e n o u g h r o o m i n t h e o b j e c t f i l e s f o r t h e f u l l p a t h t o l i b i c o n v : (
f o r e x e i n $( f i n d " $o u t " - t y p e f - e x e c u t a b l e ) ; d o
i s S c r i p t $e x e & & c o n t i n u e
l n - f s ${ libiconv } / l i b / l i b i c o n v . d y l i b $( d i r n a m e $e x e ) / l i b i c o n v . d y l i b
i n s t a l l _ n a m e _ t o o l - c h a n g e / u s r / l i b / l i b i c o n v . 2 . d y l i b @ e x e c u t a b l e _ p a t h / l i b i c o n v . d y l i b - c h a n g e / u s r / l o c a l / l i b / g c c / 6 / l i b g c c _ s . 1 . d y l i b ${ gcc . cc . lib } / l i b / l i b g c c _ s . 1 . d y l i b $e x e
d o n e
f o r f i l e i n $( f i n d " $o u t " - n a m e s e t u p - c o n f i g ) ; d o
s u b s t i t u t e I n P l a c e $f i l e - - r e p l a c e / u s r / b i n / r a n l i b " $( t y p e - P r a n l i b ) "
d o n e
'' +
lib . optionalString minimal ''
# R e m o v e p r o f i l i n g f i l e s
f i n d $o u t - t y p e f - n a m e ' * . p _ o ' - d e l e t e
f i n d $o u t - t y p e f - n a m e ' * . p _ h i ' - d e l e t e
f i n d $o u t - t y p e f - n a m e ' * _ p . a ' - d e l e t e
# ` - f ` b e c a u s e e . g . m u s l b i n d i s t d o e s n o t h a v e t h i s f i l e .
r m - f $o u t / l i b / g h c - * / b i n / g h c - i s e r v - p r o f
# H y d r a w i l l r e d i s t r i b u t e t h i s d e r i v a t i o n , s o w e h a v e t o k e e p t h e d o c s f o r
# l e g a l r e a s o n s ( r e t a i n i n g t h e l e g a l n o t i c e s e t c )
# A s a l a s t r e s o r t w e c o u l d u n p a c k t h e d o c s s e p a r a t e l y a n d s y m l i n k t h e m i n .
# T h e y ' r e i n $o u t / s h a r e / { d o c , m a n } .
'' ;
# In nixpkgs, musl based builds currently enable `pie` hardening by default
# (see `defaultHardeningFlags` in `make-derivation.nix`).
# But GHC cannot currently produce outputs that are ready for `-pie` linking.
# Thus, disable `pie` hardening, otherwise `recompile with -fPIE` errors appear.
# See:
# * https://github.com/NixOS/nixpkgs/issues/129247
# * https://gitlab.haskell.org/ghc/ghc/-/issues/19580
hardeningDisable = lib . optional stdenv . targetPlatform . isMusl " p i e " ;
doInstallCheck = true ;
installCheckPhase = ''
# S a n i t y c h e c k , c a n g h c c r e a t e e x e c u t a b l e s ?
c d $T M P
m k d i r t e s t - g h c ; c d t e s t - g h c
c a t > m a i n . h s < < E O F
{ - # L A N G U A G E T e m p l a t e H a s k e l l # - }
m o d u l e M a i n w h e r e
m a i n = p u t S t r L n \ $( [ | " y e s " | ] )
E O F
# c a n ' t u s e e n v - i h e r e b e c a u s e o t h e r w i s e w e d o n ' t f i n d - l g m p o n m u s l
e n v ${ libEnvVar } = P A T H = \
$o u t / b i n / g h c - - m a k e m a i n . h s | | e x i t 1
e c h o c o m p i l a t i o n o k
[ $( . / m a i n ) = = " y e s " ]
'' ;
passthru = {
targetPrefix = " " ;
enableShared = true ;
inherit llvmPackages ;
# Our Cabal compiler name
haskellCompilerName = " g h c - ${ version } " ;
}
# We duplicate binDistUsed here since we have a sensible default even if no bindist is avaible,
# this makes sure that getting the `meta` attribute doesn't throw even on unsupported platforms.
// lib . optionalAttrs ( ghcBinDists . ${ distSetName } . ${ stdenv . hostPlatform . system } . isHadrian or false ) {
# Normal GHC derivations expose the hadrian derivation used to build them
# here. In the case of bindists we just make sure that the attribute exists,
# as it is used for checking if a GHC derivation has been built with hadrian.
# The isHadrian mechanism will become obsolete with GHCs that use hadrian
# exclusively, i.e. 9.6 (and 9.4?).
hadrian = null ;
} ;
meta = rec {
homepage = " h t t p : / / h a s k e l l . o r g / g h c " ;
description = " T h e G l a s g o w H a s k e l l C o m p i l e r " ;
license = lib . licenses . bsd3 ;
# HACK: since we can't encode the libc / abi in platforms, we need
# to make the platform list dependent on the evaluation platform
# in order to avoid eval errors with musl which supports less
# platforms than the default libcs (i. e. glibc / libSystem).
# This is done for the benefit of Hydra, so `packagePlatforms`
# won't return any platforms that would cause an evaluation
# failure for `pkgsMusl.haskell.compiler.ghc8102Binary`, as
# long as the evaluator runs on a platform that supports
# `pkgsMusl`.
platforms = builtins . attrNames ghcBinDists . ${ distSetName } ;
maintainers = with lib . maintainers ; [
guibou
] ++ lib . teams . haskell . members ;
} ;
}