Merge pull request #40996 from obsidiansystems/cross-ghc

ghc, haskell-infra: #40929 take 2
This commit is contained in:
John Ericson 2018-05-25 11:09:07 -04:00 committed by GitHub
commit ce0180dfd5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 155 additions and 58 deletions

View File

@ -24,6 +24,10 @@
, # Whether to build dynamic libs for the standard library (on the target , # Whether to build dynamic libs for the standard library (on the target
# platform). Static libs are always built. # platform). Static libs are always built.
enableShared ? true enableShared ? true
, # What flavour to build. An empty string indicates no
# specific flavour and falls back to ghc default values.
ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
}: }:
assert !enableIntegerSimple -> gmp != null; assert !enableIntegerSimple -> gmp != null;
@ -42,11 +46,14 @@ let
}; };
buildMK = '' buildMK = ''
BuildFlavour = ${ghcFlavour}
ifneq \"\$(BuildFlavour)\" \"\"
include mk/flavours/\$(BuildFlavour).mk
endif
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
'' + stdenv.lib.optionalString enableIntegerSimple '' '' + stdenv.lib.optionalString enableIntegerSimple ''
INTEGER_LIBRARY = integer-simple INTEGER_LIBRARY = integer-simple
'' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
BuildFlavour = perf-cross
Stage1Only = YES Stage1Only = YES
HADDOCK_DOCS = NO HADDOCK_DOCS = NO
'' + stdenv.lib.optionalString enableRelocatedStaticLibs '' '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
@ -68,7 +75,6 @@ let
targetCC = builtins.head toolsForTarget; targetCC = builtins.head toolsForTarget;
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
version = "7.10.3"; version = "7.10.3";
name = "${targetPrefix}ghc-${version}"; name = "${targetPrefix}ghc-${version}";
@ -87,6 +93,8 @@ stdenv.mkDerivation rec {
./relocation.patch ./relocation.patch
]; ];
postPatch = "patchShebangs .";
# GHC is a bit confused on its cross terminology. # GHC is a bit confused on its cross terminology.
preConfigure = '' preConfigure = ''
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
@ -103,6 +111,7 @@ stdenv.mkDerivation rec {
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
echo -n "${buildMK}" > mk/build.mk echo -n "${buildMK}" > mk/build.mk
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
'' + stdenv.lib.optionalString (!stdenv.isDarwin) '' '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
@ -135,7 +144,8 @@ stdenv.mkDerivation rec {
crossConfig = true; crossConfig = true;
nativeBuildInputs = [ nativeBuildInputs = [
ghc perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42 hscolour perl libxml2 libxslt docbook_xsl docbook_xml_dtd_45 docbook_xml_dtd_42
ghc hscolour
]; ];
# For building runtime libs # For building runtime libs

View File

@ -23,6 +23,10 @@
, # Whether to build dynamic libs for the standard library (on the target , # Whether to build dynamic libs for the standard library (on the target
# platform). Static libs are always built. # platform). Static libs are always built.
enableShared ? true enableShared ? true
, # What flavour to build. An empty string indicates no
# specific flavour and falls back to ghc default values.
ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
}: }:
assert !enableIntegerSimple -> gmp != null; assert !enableIntegerSimple -> gmp != null;
@ -36,11 +40,14 @@ let
"${targetPlatform.config}-"; "${targetPlatform.config}-";
buildMK = '' buildMK = ''
BuildFlavour = ${ghcFlavour}
ifneq \"\$(BuildFlavour)\" \"\"
include mk/flavours/\$(BuildFlavour).mk
endif
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
'' + stdenv.lib.optionalString enableIntegerSimple '' '' + stdenv.lib.optionalString enableIntegerSimple ''
INTEGER_LIBRARY = integer-simple INTEGER_LIBRARY = integer-simple
'' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
BuildFlavour = perf-cross
Stage1Only = YES Stage1Only = YES
HADDOCK_DOCS = NO HADDOCK_DOCS = NO
'' + stdenv.lib.optionalString enableRelocatedStaticLibs '' '' + stdenv.lib.optionalString enableRelocatedStaticLibs ''
@ -87,6 +94,8 @@ stdenv.mkDerivation rec {
++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch ++ stdenv.lib.optional stdenv.isDarwin ./ghc-8.0.2-no-cpp-warnings.patch
++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch; ++ stdenv.lib.optional stdenv.isDarwin ./backport-dylib-command-size-limit.patch;
postPatch = "patchShebangs .";
# GHC is a bit confused on its cross terminology. # GHC is a bit confused on its cross terminology.
preConfigure = '' preConfigure = ''
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
@ -103,6 +112,7 @@ stdenv.mkDerivation rec {
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib" export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf" export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip" export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
echo -n "${buildMK}" > mk/build.mk echo -n "${buildMK}" > mk/build.mk
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
'' + stdenv.lib.optionalString (!stdenv.isDarwin) '' '' + stdenv.lib.optionalString (!stdenv.isDarwin) ''
@ -134,7 +144,10 @@ stdenv.mkDerivation rec {
# masss-rebuild. # masss-rebuild.
crossConfig = true; crossConfig = true;
nativeBuildInputs = [ ghc perl hscolour sphinx ]; nativeBuildInputs = [
perl sphinx
ghc hscolour
];
# For building runtime libs # For building runtime libs
depsBuildTarget = toolsForTarget; depsBuildTarget = toolsForTarget;
@ -151,10 +164,11 @@ stdenv.mkDerivation rec {
# that in turn causes GHCi to abort # that in turn causes GHCi to abort
stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols"; stripDebugFlags = [ "-S" ] ++ stdenv.lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
# zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't
# treat that as a unary `{x,y,z,..}` repetition.
postInstall = '' postInstall = ''
paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} for bin in "$out"/lib/${name}/bin/*; do
isELF "$bin" || continue
paxmark m "$bin"
done
# Install the bash completion file. # Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc

View File

@ -23,10 +23,11 @@
, # Whether to build dynamic libs for the standard library (on the target , # Whether to build dynamic libs for the standard library (on the target
# platform). Static libs are always built. # platform). Static libs are always built.
enableShared ? enableShared ? true
!(targetPlatform.isDarwin
# On iOS, dynamic linking is not supported , # What flavour to build. An empty string indicates no
&& (targetPlatform.isAarch64 || targetPlatform.isAarch32)) # specific flavour and falls back to ghc default values.
ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
, # Whether to backport https://phabricator.haskell.org/D4388 for , # Whether to backport https://phabricator.haskell.org/D4388 for
# deterministic profiling symbol names, at the cost of a slightly # deterministic profiling symbol names, at the cost of a slightly
# non-standard GHC API # non-standard GHC API
@ -44,11 +45,14 @@ let
"${targetPlatform.config}-"; "${targetPlatform.config}-";
buildMK = '' buildMK = ''
BuildFlavour = ${ghcFlavour}
ifneq \"\$(BuildFlavour)\" \"\"
include mk/flavours/\$(BuildFlavour).mk
endif
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
'' + stdenv.lib.optionalString enableIntegerSimple '' '' + stdenv.lib.optionalString enableIntegerSimple ''
INTEGER_LIBRARY = integer-simple INTEGER_LIBRARY = integer-simple
'' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
BuildFlavour = perf-cross
Stage1Only = YES Stage1Only = YES
HADDOCK_DOCS = NO HADDOCK_DOCS = NO
BUILD_SPHINX_HTML = NO BUILD_SPHINX_HTML = NO
@ -153,7 +157,10 @@ stdenv.mkDerivation rec {
# masss-rebuild. # masss-rebuild.
crossConfig = true; crossConfig = true;
nativeBuildInputs = [ alex autoconf autoreconfHook automake ghc happy hscolour perl python3 sphinx ]; nativeBuildInputs = [
autoconf autoreconfHook automake perl python3 sphinx
ghc alex happy hscolour
];
# For building runtime libs # For building runtime libs
depsBuildTarget = toolsForTarget; depsBuildTarget = toolsForTarget;
@ -172,10 +179,11 @@ stdenv.mkDerivation rec {
checkTarget = "test"; checkTarget = "test";
# zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't
# treat that as a unary `{x,y,z,..}` repetition.
postInstall = '' postInstall = ''
paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} for bin in "$out"/lib/${name}/bin/*; do
isELF "$bin" || continue
paxmark m "$bin"
done
# Install the bash completion file. # Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc

View File

@ -3,7 +3,7 @@
# build-tools # build-tools
, bootPkgs, alex, happy , bootPkgs, alex, happy
, autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3 , autoconf, automake, coreutils, fetchurl, fetchpatch, perl, python3, m4
, libffi, libiconv ? null, ncurses , libffi, libiconv ? null, ncurses
@ -15,16 +15,21 @@
, # If enabled, GHC will be built with the GPL-free but slower integer-simple , # If enabled, GHC will be built with the GPL-free but slower integer-simple
# library instead of the faster but GPLed integer-gmp library. # library instead of the faster but GPLed integer-gmp library.
enableIntegerSimple ? false, gmp ? null, m4 enableIntegerSimple ? false, gmp ? null
, # If enabled, use -fPIC when compiling static libs. , # If enabled, use -fPIC when compiling static libs.
enableRelocatedStaticLibs ? targetPlatform != hostPlatform enableRelocatedStaticLibs ? targetPlatform != hostPlatform
, # Whether to build dynamic libs for the standard library (on the target , # Whether to build dynamic libs for the standard library (on the target
# platform). Static libs are always built. # platform). Static libs are always built.
enableShared ? !targetPlatform.useAndroidPrebuilt enableShared ? !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt
, version ? "8.4.2" , # Whetherto build terminfo.
enableTerminfo ? !targetPlatform.isWindows
, # What flavour to build. An empty string indicates no
# specific flavour and falls back to ghc default values.
ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
}: }:
assert !enableIntegerSimple -> gmp != null; assert !enableIntegerSimple -> gmp != null;
@ -38,11 +43,14 @@ let
"${targetPlatform.config}-"; "${targetPlatform.config}-";
buildMK = '' buildMK = ''
BuildFlavour = ${ghcFlavour}
ifneq \"\$(BuildFlavour)\" \"\"
include mk/flavours/\$(BuildFlavour).mk
endif
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
'' + stdenv.lib.optionalString enableIntegerSimple '' '' + stdenv.lib.optionalString enableIntegerSimple ''
INTEGER_LIBRARY = integer-simple INTEGER_LIBRARY = integer-simple
'' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
BuildFlavour = perf-cross
Stage1Only = YES Stage1Only = YES
HADDOCK_DOCS = NO HADDOCK_DOCS = NO
BUILD_SPHINX_HTML = NO BUILD_SPHINX_HTML = NO
@ -55,9 +63,9 @@ let
''; '';
# Splicer will pull out correct variations # Splicer will pull out correct variations
libDeps = platform: [ ncurses ] libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
++ stdenv.lib.optional (!enableIntegerSimple) gmp ++ stdenv.lib.optional (!enableIntegerSimple) gmp
++ stdenv.lib.optional (platform.libc != "glibc") libiconv; ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
toolsForTarget = toolsForTarget =
if hostPlatform == buildPlatform then if hostPlatform == buildPlatform then
@ -69,7 +77,7 @@ let
in in
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
inherit version; version = "8.4.2";
name = "${targetPrefix}ghc-${version}"; name = "${targetPrefix}ghc-${version}";
src = fetchurl { src = fetchurl {
@ -126,7 +134,7 @@ stdenv.mkDerivation rec {
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
"--enable-bootstrap-with-devel-snapshot" "--enable-bootstrap-with-devel-snapshot"
@ -144,7 +152,10 @@ stdenv.mkDerivation rec {
# masss-rebuild. # masss-rebuild.
crossConfig = true; crossConfig = true;
nativeBuildInputs = [ ghc perl autoconf automake m4 happy alex python3 ]; nativeBuildInputs = [
perl autoconf automake m4 python3
ghc alex happy
];
# For building runtime libs # For building runtime libs
depsBuildTarget = toolsForTarget; depsBuildTarget = toolsForTarget;
@ -163,10 +174,11 @@ stdenv.mkDerivation rec {
checkTarget = "test"; checkTarget = "test";
# zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't
# treat that as a unary `{x,y,z,..}` repetition.
postInstall = '' postInstall = ''
paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} for bin in "$out"/lib/${name}/bin/*; do
isELF "$bin" || continue
paxmark m "$bin"
done
# Install the bash completion file. # Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc

View File

@ -3,7 +3,7 @@
# build-tools # build-tools
, bootPkgs, alex, happy , bootPkgs, alex, happy
, autoconf, automake, coreutils, fetchgit, perl, python3 , autoconf, automake, coreutils, fetchgit, perl, python3, m4
, libffi, libiconv ? null, ncurses , libffi, libiconv ? null, ncurses
@ -22,9 +22,15 @@
, # Whether to build dynamic libs for the standard library (on the target , # Whether to build dynamic libs for the standard library (on the target
# platform). Static libs are always built. # platform). Static libs are always built.
enableShared ? !targetPlatform.useAndroidPrebuilt enableShared ? !targetPlatform.isWindows && !targetPlatform.useAndroidPrebuilt
, # Whetherto build terminfo.
enableTerminfo ? !targetPlatform.isWindows
, version ? "8.5.20180118" , version ? "8.5.20180118"
, # What flavour to build. An empty string indicates no
# specific flavour and falls back to ghc default values.
ghcFlavour ? stdenv.lib.optionalString (targetPlatform != hostPlatform) "perf-cross"
}: }:
assert !enableIntegerSimple -> gmp != null; assert !enableIntegerSimple -> gmp != null;
@ -38,11 +44,14 @@ let
"${targetPlatform.config}-"; "${targetPlatform.config}-";
buildMK = '' buildMK = ''
BuildFlavour = ${ghcFlavour}
ifneq \"\$(BuildFlavour)\" \"\"
include mk/flavours/\$(BuildFlavour).mk
endif
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"} DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
'' + stdenv.lib.optionalString enableIntegerSimple '' '' + stdenv.lib.optionalString enableIntegerSimple ''
INTEGER_LIBRARY = integer-simple INTEGER_LIBRARY = integer-simple
'' + stdenv.lib.optionalString (targetPlatform != hostPlatform) '' '' + stdenv.lib.optionalString (targetPlatform != hostPlatform) ''
BuildFlavour = perf-cross
Stage1Only = YES Stage1Only = YES
HADDOCK_DOCS = NO HADDOCK_DOCS = NO
BUILD_SPHINX_HTML = NO BUILD_SPHINX_HTML = NO
@ -55,9 +64,9 @@ let
''; '';
# Splicer will pull out correct variations # Splicer will pull out correct variations
libDeps = platform: [ ncurses ] libDeps = platform: stdenv.lib.optional enableTerminfo [ ncurses ]
++ stdenv.lib.optional (!enableIntegerSimple) gmp ++ stdenv.lib.optional (!enableIntegerSimple) gmp
++ stdenv.lib.optional (platform.libc != "glibc") libiconv; ++ stdenv.lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
toolsForTarget = toolsForTarget =
if hostPlatform == buildPlatform then if hostPlatform == buildPlatform then
@ -123,7 +132,7 @@ stdenv.mkDerivation rec {
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib" "--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [ ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && ! enableIntegerSimple) [
"--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib" "--with-gmp-includes=${gmp.dev}/include" "--with-gmp-libraries=${gmp.out}/lib"
] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc") [ ] ++ stdenv.lib.optional (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
"--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib" "--with-iconv-includes=${libiconv}/include" "--with-iconv-libraries=${libiconv}/lib"
] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [ ] ++ stdenv.lib.optionals (targetPlatform != hostPlatform) [
"--enable-bootstrap-with-devel-snapshot" "--enable-bootstrap-with-devel-snapshot"
@ -141,7 +150,10 @@ stdenv.mkDerivation rec {
# masss-rebuild. # masss-rebuild.
crossConfig = true; crossConfig = true;
nativeBuildInputs = [ ghc perl autoconf automake happy alex python3 ]; nativeBuildInputs = [
perl autoconf automake m4 python3
ghc alex happy
];
# For building runtime libs # For building runtime libs
depsBuildTarget = toolsForTarget; depsBuildTarget = toolsForTarget;
@ -160,10 +172,11 @@ stdenv.mkDerivation rec {
checkTarget = "test"; checkTarget = "test";
# zsh and other shells are smart about `{ghc}` but bash isn't, and doesn't
# treat that as a unary `{x,y,z,..}` repetition.
postInstall = '' postInstall = ''
paxmark m $out/lib/${name}/bin/${if targetPlatform != hostPlatform then "ghc" else "{ghc,haddock}"} for bin in "$out"/lib/${name}/bin/*; do
isELF "$bin" || continue
paxmark m "$bin"
done
# Install the bash completion file. # Install the bash completion file.
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc

View File

@ -128,7 +128,7 @@ self: super: builtins.intersectAttrs super {
# Prevents needing to add security_tool as a build tool to all of x509-system's # Prevents needing to add security_tool as a build tool to all of x509-system's
# dependencies. # dependencies.
x509-system = if pkgs.stdenv.isDarwin && !pkgs.stdenv.cc.nativeLibc x509-system = if pkgs.stdenv.targetPlatform.isDarwin && !pkgs.stdenv.cc.nativeLibc
then let inherit (pkgs.darwin) security_tool; then let inherit (pkgs.darwin) security_tool;
in pkgs.lib.overrideDerivation (addBuildDepend super.x509-system security_tool) (drv: { in pkgs.lib.overrideDerivation (addBuildDepend super.x509-system security_tool) (drv: {
postPatch = (drv.postPatch or "") + '' postPatch = (drv.postPatch or "") + ''

View File

@ -19,6 +19,7 @@ in
, buildTarget ? "" , buildTarget ? ""
, buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? [] , buildTools ? [], libraryToolDepends ? [], executableToolDepends ? [], testToolDepends ? [], benchmarkToolDepends ? []
, configureFlags ? [] , configureFlags ? []
, buildFlags ? []
, description ? "" , description ? ""
, doCheck ? !isCross && stdenv.lib.versionOlder "7.4" ghc.version , doCheck ? !isCross && stdenv.lib.versionOlder "7.4" ghc.version
, doBenchmark ? false , doBenchmark ? false
@ -31,7 +32,7 @@ in
, enableSharedExecutables ? false , enableSharedExecutables ? false
, enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version) , enableSharedLibraries ? ((ghc.isGhcjs or false) || stdenv.lib.versionOlder "7.7" ghc.version)
, enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin , enableDeadCodeElimination ? (!stdenv.isDarwin) # TODO: use -dead_strip for darwin
, enableStaticLibraries ? true , enableStaticLibraries ? !hostPlatform.isWindows
, enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4" , enableHsc2hsViaAsm ? hostPlatform.isWindows && stdenv.lib.versionAtLeast ghc.version "8.4"
, extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? [] , extraLibraries ? [], librarySystemDepends ? [], executableSystemDepends ? []
, homepage ? "http://hackage.haskell.org/package/${pname}" , homepage ? "http://hackage.haskell.org/package/${pname}"
@ -68,6 +69,10 @@ in
assert editedCabalFile != null -> revision != null; assert editedCabalFile != null -> revision != null;
# --enable-static does not work on windows. This is a bug in GHC.
# --enable-static will pass -staticlib to ghc, which only works for mach-o and elf.
assert hostPlatform.isWindows -> enableStaticLibraries == false;
let let
inherit (stdenv.lib) optional optionals optionalString versionOlder versionAtLeast inherit (stdenv.lib) optional optionals optionalString versionOlder versionAtLeast
@ -126,6 +131,8 @@ let
crossCabalFlagsString = crossCabalFlagsString =
stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags); stdenv.lib.optionalString isCross (" " + stdenv.lib.concatStringsSep " " crossCabalFlags);
buildFlagsString = optionalString (buildFlags != []) (" " + concatStringsSep " " buildFlags);
defaultConfigureFlags = [ defaultConfigureFlags = [
"--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid" "--verbose" "--prefix=$out" "--libdir=\\$prefix/lib/\\$compiler" "--libsubdir=\\$pkgid"
(optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}") (optionalString enableSeparateDataOutput "--datadir=$data/share/${ghc.name}")
@ -169,18 +176,22 @@ let
optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends; optionals doCheck testPkgconfigDepends ++ optionals doBenchmark benchmarkPkgconfigDepends;
nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++ nativeBuildInputs = [ ghc nativeGhc removeReferencesTo ] ++ optional (allPkgconfigDepends != []) pkgconfig ++
setupHaskellDepends ++
buildTools ++ libraryToolDepends ++ executableToolDepends; buildTools ++ libraryToolDepends ++ executableToolDepends;
propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends; propagatedBuildInputs = buildDepends ++ libraryHaskellDepends ++ executableHaskellDepends;
otherBuildInputs = setupHaskellDepends ++ extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++ otherBuildInputs = extraLibraries ++ librarySystemDepends ++ executableSystemDepends ++
allPkgconfigDepends ++ allPkgconfigDepends ++
optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++ optionals doCheck (testDepends ++ testHaskellDepends ++ testSystemDepends ++ testToolDepends) ++
optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends); optionals doBenchmark (benchmarkDepends ++ benchmarkHaskellDepends ++ benchmarkSystemDepends ++ benchmarkToolDepends);
allBuildInputs = propagatedBuildInputs ++ otherBuildInputs; allBuildInputs = propagatedBuildInputs ++ otherBuildInputs;
haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs; haskellBuildInputs = stdenv.lib.filter isHaskellPkg allBuildInputs;
systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs; systemBuildInputs = stdenv.lib.filter isSystemPkg allBuildInputs;
ghcEnv = ghc.withPackages (p: haskellBuildInputs); # When not cross compiling, also include Setup.hs dependencies.
ghcEnv = ghc.withPackages (p:
haskellBuildInputs ++ stdenv.lib.optional (!isCross) setupHaskellDepends);
setupCommand = "./Setup"; setupCommand = "./Setup";
@ -190,6 +201,22 @@ let
nativeGhcCommand = "${nativeGhc.targetPrefix}ghc"; nativeGhcCommand = "${nativeGhc.targetPrefix}ghc";
buildPkgDb = ghcName: ''
if [ -d "$p/lib/${ghcName}/package.conf.d" ]; then
cp -f "$p/lib/${ghcName}/package.conf.d/"*.conf $packageConfDir/
continue
fi
if [ -d "$p/include" ]; then
configureFlags+=" --extra-include-dirs=$p/include"
fi
if [ -d "$p/lib" ]; then
configureFlags+=" --extra-lib-dirs=$p/lib"
fi
if [[ -d "$p/Library/Frameworks" ]]; then
configureFlags+=" --extra-framework-dirs=$p/Library/Frameworks"
fi
'';
in in
assert allPkgconfigDepends != [] -> pkgconfig != null; assert allPkgconfigDepends != [] -> pkgconfig != null;
@ -230,30 +257,37 @@ stdenv.mkDerivation ({
echo "Build with ${ghc}." echo "Build with ${ghc}."
${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"} ${optionalString (hasActiveLibrary && hyperlinkSource) "export PATH=${hscolour}/bin:$PATH"}
'' + (optionalString (setupHaskellDepends != []) ''
setupPackageConfDir="$TMPDIR/setup-package.conf.d"
mkdir -p $setupPackageConfDir
'') + ''
packageConfDir="$TMPDIR/package.conf.d" packageConfDir="$TMPDIR/package.conf.d"
mkdir -p $packageConfDir mkdir -p $packageConfDir
setupCompileFlags="${concatStringsSep " " setupCompileFlags}" setupCompileFlags="${concatStringsSep " " setupCompileFlags}"
configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags" configureFlags="${concatStringsSep " " defaultConfigureFlags} $configureFlags"
''
# We build the Setup.hs on the *build* machine, and as such should only add
# dependencies for the build machine.
#
# pkgs* arrays defined in stdenv/setup.hs
+ (optionalString (setupHaskellDepends != []) ''
for p in "''${pkgsBuildBuild[@]}" "''${pkgsBuildHost[@]}" "''${pkgsBuildTarget[@]}"; do
${buildPkgDb nativeGhc.name}
done
${nativeGhcCommand}-pkg --${nativePackageDbFlag}="$setupPackageConfDir" recache
'')
# host.*Pkgs defined in stdenv/setup.hs # For normal components
+ ''
for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do for p in "''${pkgsHostHost[@]}" "''${pkgsHostTarget[@]}"; do
if [ -d "$p/lib/${ghc.name}/package.conf.d" ]; then ${buildPkgDb ghc.name}
cp -f "$p/lib/${ghc.name}/package.conf.d/"*.conf $packageConfDir/
continue
fi
if [ -d "$p/include" ]; then
configureFlags+=" --extra-include-dirs=$p/include"
fi
if [ -d "$p/lib" ]; then
configureFlags+=" --extra-lib-dirs=$p/lib"
fi
done done
'' ''
# only use the links hack if we're actually building dylibs. otherwise, the # only use the links hack if we're actually building dylibs. otherwise, the
# "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes # "dynamic-library-dirs" point to nonexistent paths, and the ln command becomes
# "ln -s $out/lib/links", which tries to recreate the links dir and fails # "ln -s $out/lib/links", which tries to recreate the links dir and fails
+ (optionalString (stdenv.isDarwin && enableSharedLibraries) '' + (optionalString (stdenv.isDarwin && (enableSharedLibraries || enableSharedExecutables)) ''
# Work around a limit in the macOS Sierra linker on the number of paths # Work around a limit in the macOS Sierra linker on the number of paths
# referenced by any one dynamic library: # referenced by any one dynamic library:
# #
@ -282,7 +316,11 @@ stdenv.mkDerivation ({
done done
echo setupCompileFlags: $setupCompileFlags echo setupCompileFlags: $setupCompileFlags
${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i ${optionalString (setupHaskellDepends != [])
''
echo GHC_PACKAGE_PATH="$setupPackageConfDir:"
GHC_PACKAGE_PATH="$setupPackageConfDir:" ''
}${nativeGhcCommand} $setupCompileFlags --make -o Setup -odir $TMPDIR -hidir $TMPDIR $i
runHook postCompileBuildDriver runHook postCompileBuildDriver
''; '';
@ -310,7 +348,7 @@ stdenv.mkDerivation ({
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
${setupCommand} build ${buildTarget}${crossCabalFlagsString} ${setupCommand} build ${buildTarget}${crossCabalFlagsString}${buildFlagsString}
runHook postBuild runHook postBuild
''; '';

View File

@ -131,6 +131,8 @@ rec {
*/ */
appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; }); appendConfigureFlag = drv: x: overrideCabal drv (drv: { configureFlags = (drv.configureFlags or []) ++ [x]; });
appendBuildFlag = drv: x: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ [x]; });
appendBuildFlags = drv: xs: overrideCabal drv (drv: { buildFlags = (drv.buildFlags or []) ++ xs; });
/* removeConfigureFlag drv x is a Haskell package like drv, but with /* removeConfigureFlag drv x is a Haskell package like drv, but with
all cabal configure arguments that are equal to x removed. all cabal configure arguments that are equal to x removed.