uboot: (firmwareOdroidC2/C4) don't invoke patch tool, use patches = [] instead
https://github.com/NixOS/nixpkgs/blob/master/pkgs/stdenv/generic/setup.sh#L948 this can do it nicely. Signed-off-by: Anton Arapov <anton@deadbeef.mx>
This commit is contained in:
commit
56de2bcd43
30691 changed files with 3076956 additions and 0 deletions
444
pkgs/development/compilers/ghc/8.10.2-binary.nix
Normal file
444
pkgs/development/compilers/ghc/8.10.2-binary.nix
Normal file
|
|
@ -0,0 +1,444 @@
|
|||
{ 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 = "https://downloads.haskell.org/ghc";
|
||||
|
||||
version = "8.10.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}/ghc-${version}-i386-deb9-linux.tar.xz";
|
||||
sha256 = "0bvwisl4w0z5z8z0da10m9sv0mhm9na2qm43qxr8zl23mn32mblx";
|
||||
};
|
||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
||||
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 = "libtinfo.so.5"; }
|
||||
];
|
||||
};
|
||||
x86_64-linux = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
|
||||
sha256 = "0chnzy9j23b2wa8clx5arwz8wnjfxyjmz9qkj548z14cqf13slcl";
|
||||
};
|
||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
||||
archSpecificLibraries = [
|
||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
||||
];
|
||||
};
|
||||
armv7l-linux = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
|
||||
sha256 = "1j41cq5d3rmlgz7hzw8f908fs79gc5mn3q5wz277lk8zdf19g75v";
|
||||
};
|
||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
||||
archSpecificLibraries = [
|
||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
||||
];
|
||||
};
|
||||
aarch64-linux = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
|
||||
sha256 = "14smwl3741ixnbgi0l51a7kh7xjkiannfqx15b72svky0y4l3wjw";
|
||||
};
|
||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
||||
archSpecificLibraries = [
|
||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
||||
{ nixPackage = numactl; fileToCheckFor = null; }
|
||||
];
|
||||
};
|
||||
x86_64-darwin = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
|
||||
sha256 = "1hngyq14l4f950hzhh2d204ca2gfc98pc9xdasxihzqd1jq75dzd";
|
||||
};
|
||||
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 = "-musl";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz";
|
||||
sha256 = "0xpcbyaxqyhbl6f0i3s4rp2jm67nqpkfh2qlbj3i2fiaix89ml0l";
|
||||
};
|
||||
exePathForLibraryCheck = "bin/ghc";
|
||||
archSpecificLibraries = [
|
||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
||||
# In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*`
|
||||
# instead of `libtinfo.so.*.`
|
||||
{ nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
|
||||
|
||||
binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
|
||||
or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
|
||||
|
||||
useLLVM = !stdenv.targetPlatform.isx86;
|
||||
|
||||
libPath =
|
||||
lib.makeLibraryPath (
|
||||
# Add arch-specific libraries.
|
||||
map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
|
||||
);
|
||||
|
||||
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
|
||||
+ "LD_LIBRARY_PATH";
|
||||
|
||||
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 == "cctools") [
|
||||
targetPackages.stdenv.cc.bintools.bintools
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
inherit version;
|
||||
pname = "ghc-binary${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 = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in
|
||||
lib.concatStringsSep "\n" [
|
||||
(''
|
||||
echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
|
||||
if ! test -e ${buildExeGlob}; then
|
||||
echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
||||
fi
|
||||
'')
|
||||
(lib.concatMapStringsSep
|
||||
"\n"
|
||||
({ fileToCheckFor, nixPackage }:
|
||||
lib.optionalString (fileToCheckFor != null) ''
|
||||
echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
|
||||
if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
|
||||
echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
||||
fi
|
||||
|
||||
echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
|
||||
if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
|
||||
echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
||||
fi
|
||||
''
|
||||
)
|
||||
binDistUsed.archSpecificLibraries
|
||||
)
|
||||
])
|
||||
# GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
|
||||
# during linking
|
||||
+ lib.optionalString stdenv.isDarwin ''
|
||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
||||
# not enough room in the object files for the full path to libiconv :(
|
||||
for exe in $(find . -type f -executable); do
|
||||
isScript $exe && continue
|
||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
||||
done
|
||||
'' +
|
||||
|
||||
# Some scripts used during the build need to have their shebangs patched
|
||||
''
|
||||
patchShebangs ghc-${version}/utils/
|
||||
patchShebangs ghc-${version}/configure
|
||||
'' +
|
||||
# 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
|
||||
''
|
||||
find . -name integer-gmp.buildinfo \
|
||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
find . -name base.buildinfo \
|
||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
|
||||
'' +
|
||||
# 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 ''
|
||||
find . -name package.conf.in \
|
||||
-exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
|
||||
'' +
|
||||
# Rename needed libraries and binaries, fix interpreter
|
||||
lib.optionalString stdenv.isLinux ''
|
||||
find . -type f -executable -exec patchelf \
|
||||
--interpreter ${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
|
||||
''
|
||||
# Detect hadrian Makefile by checking for the target that has the problem
|
||||
if grep '^update_package_db' ghc-${version}*/Makefile > /dev/null; then
|
||||
echo Hadrian bindist, applying workaround for xxx path substitution.
|
||||
# based on https://gitlab.haskell.org/ghc/ghc/-/commit/dd5fecb0e2990b192d92f4dfd7519ecb33164fad.patch
|
||||
substituteInPlace ghc-${version}*/Makefile --replace 'xxx' '\0xxx\0'
|
||||
else
|
||||
echo Not a hadrian bindist, not applying xxx path workaround.
|
||||
fi
|
||||
'';
|
||||
|
||||
# fix for `configure: error: Your linker is affected by binutils #16177`
|
||||
preConfigure = lib.optionalString
|
||||
stdenv.targetPlatform.isAarch32
|
||||
"LD=ld.gold";
|
||||
|
||||
configurePlatforms = [ ];
|
||||
configureFlags = [
|
||||
"--with-gmp-includes=${lib.getDev gmp}/include"
|
||||
# Note `--with-gmp-libraries` does nothing for GHC bindists:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
|
||||
] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
|
||||
# From: https://github.com/NixOS/nixpkgs/pull/43369/commits
|
||||
++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
|
||||
|
||||
# No building is necessary, but calling make without flags ironically
|
||||
# calls install-strip ...
|
||||
dontBuild = true;
|
||||
|
||||
# Patch scripts to include runtime dependencies in $PATH.
|
||||
postInstall = ''
|
||||
for i in "$out/bin/"*; do
|
||||
test ! -h "$i" || continue
|
||||
isScript "$i" || continue
|
||||
sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
|
||||
done
|
||||
'';
|
||||
|
||||
# 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.
|
||||
''
|
||||
(cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
|
||||
(cd $out/lib; ln -s ${gmp.out}/lib/libgmp.so.10)
|
||||
(cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
|
||||
for p in $(find "$out/lib" -type f -name "*\.so*"); do
|
||||
(cd $out/lib; ln -s $p)
|
||||
done
|
||||
|
||||
for p in $(find "$out/lib" -type f -executable); do
|
||||
if isELF "$p"; then
|
||||
echo "Patchelfing $p"
|
||||
patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
|
||||
fi
|
||||
done
|
||||
''
|
||||
else
|
||||
''
|
||||
for p in $(find "$out" -type f -executable); do
|
||||
if isELF "$p"; then
|
||||
echo "Patchelfing $p"
|
||||
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
||||
fi
|
||||
done
|
||||
'') + lib.optionalString stdenv.isDarwin ''
|
||||
# not enough room in the object files for the full path to libiconv :(
|
||||
for exe in $(find "$out" -type f -executable); do
|
||||
isScript $exe && continue
|
||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
||||
done
|
||||
|
||||
for file in $(find "$out" -name setup-config); do
|
||||
substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
|
||||
done
|
||||
'' +
|
||||
lib.optionalString minimal ''
|
||||
# Remove profiling files
|
||||
find $out -type f -name '*.p_o' -delete
|
||||
find $out -type f -name '*.p_hi' -delete
|
||||
find $out -type f -name '*_p.a' -delete
|
||||
# `-f` because e.g. musl bindist does not have this file.
|
||||
rm -f $out/lib/ghc-*/bin/ghc-iserv-prof
|
||||
# Hydra will redistribute this derivation, so we have to keep the docs for
|
||||
# legal reasons (retaining the legal notices etc)
|
||||
# As a last resort we could unpack the docs separately and symlink them in.
|
||||
# They're in $out/share/{doc,man}.
|
||||
'';
|
||||
|
||||
# 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 "pie";
|
||||
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
# Sanity check, can ghc create executables?
|
||||
cd $TMP
|
||||
mkdir test-ghc; cd test-ghc
|
||||
cat > main.hs << EOF
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Main where
|
||||
main = putStrLn \$([|"yes"|])
|
||||
EOF
|
||||
# can't use env -i here because otherwise we don't find -lgmp on musl
|
||||
env ${libEnvVar}= PATH= \
|
||||
$out/bin/ghc --make main.hs || exit 1
|
||||
echo compilation ok
|
||||
[ $(./main) == "yes" ]
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
targetPrefix = "";
|
||||
enableShared = true;
|
||||
|
||||
inherit llvmPackages;
|
||||
|
||||
# Our Cabal compiler name
|
||||
haskellCompilerName = "ghc-${version}";
|
||||
};
|
||||
|
||||
meta = rec {
|
||||
homepage = "http://haskell.org/ghc";
|
||||
description = "The Glasgow Haskell Compiler";
|
||||
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};
|
||||
hydraPlatforms = builtins.filter (p: minimal || p != "aarch64-linux") platforms;
|
||||
maintainers = with lib.maintainers; [
|
||||
guibou
|
||||
] ++ lib.teams.haskell.members;
|
||||
};
|
||||
}
|
||||
440
pkgs/development/compilers/ghc/8.10.7-binary.nix
Normal file
440
pkgs/development/compilers/ghc/8.10.7-binary.nix
Normal file
|
|
@ -0,0 +1,440 @@
|
|||
{ 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 = "https://downloads.haskell.org/ghc";
|
||||
|
||||
# Copy sha256 from https://downloads.haskell.org/~ghc/8.10.7/SHA256SUMS
|
||||
version = "8.10.7";
|
||||
|
||||
# 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}/ghc-${version}-i386-deb9-linux.tar.xz";
|
||||
sha256 = "fbfc1ef194f4e7a4c0da8c11cc69b17458a4b928b609b3622c97acc4acd5c5ab";
|
||||
};
|
||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
||||
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 = "libtinfo.so.5"; }
|
||||
];
|
||||
};
|
||||
x86_64-linux = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-deb10-linux.tar.xz";
|
||||
sha256 = "a13719bca87a0d3ac0c7d4157a4e60887009a7f1a8dbe95c4759ec413e086d30";
|
||||
};
|
||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
||||
archSpecificLibraries = [
|
||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
||||
];
|
||||
};
|
||||
armv7l-linux = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-armv7-deb10-linux.tar.xz";
|
||||
sha256 = "3949c31bdf7d3b4afb765ea8246bca4ca9707c5d988d9961a244f0da100956a2";
|
||||
};
|
||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
||||
archSpecificLibraries = [
|
||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
||||
];
|
||||
};
|
||||
aarch64-linux = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-deb10-linux.tar.xz";
|
||||
sha256 = "fad2417f9b295233bf8ade79c0e6140896359e87be46cb61cd1d35863d9d0e55";
|
||||
};
|
||||
exePathForLibraryCheck = "ghc/stage2/build/tmp/ghc-stage2";
|
||||
archSpecificLibraries = [
|
||||
{ nixPackage = gmp; fileToCheckFor = null; }
|
||||
{ nixPackage = ncurses6; fileToCheckFor = "libtinfo.so.6"; }
|
||||
{ nixPackage = numactl; fileToCheckFor = null; }
|
||||
];
|
||||
};
|
||||
x86_64-darwin = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
|
||||
sha256 = "287db0f9c338c9f53123bfa8731b0996803ee50f6ee847fe388092e5e5132047";
|
||||
};
|
||||
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; }
|
||||
];
|
||||
};
|
||||
aarch64-darwin = {
|
||||
variantSuffix = "";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-apple-darwin.tar.xz";
|
||||
sha256 = "dc469fc3c35fd2a33a5a575ffce87f13de7b98c2d349a41002e200a56d9bba1c";
|
||||
};
|
||||
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 = "-musl-integer-simple";
|
||||
src = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-alpine3.10-linux-integer-simple.tar.xz";
|
||||
sha256 = "16903df850ef73d5246f2ff169cbf57ecab76c2ac5acfa9928934282cfad575c";
|
||||
};
|
||||
exePathForLibraryCheck = "bin/ghc";
|
||||
archSpecificLibraries = [
|
||||
# No `gmp` here, since this is an `integer-simple` bindist.
|
||||
|
||||
# In contrast to glibc builds, the musl-bindist uses `libncursesw.so.*`
|
||||
# instead of `libtinfo.so.*.`
|
||||
{ nixPackage = ncurses6; fileToCheckFor = "libncursesw.so.6"; }
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
distSetName = if stdenv.hostPlatform.isMusl then "musl" else "defaultLibc";
|
||||
|
||||
binDistUsed = ghcBinDists.${distSetName}.${stdenv.hostPlatform.system}
|
||||
or (throw "cannot bootstrap GHC on this platform ('${stdenv.hostPlatform.system}' with libc '${distSetName}')");
|
||||
|
||||
useLLVM = !stdenv.targetPlatform.isx86;
|
||||
|
||||
libPath =
|
||||
lib.makeLibraryPath (
|
||||
# Add arch-specific libraries.
|
||||
map ({ nixPackage, ... }: nixPackage) binDistUsed.archSpecificLibraries
|
||||
);
|
||||
|
||||
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
|
||||
+ "LD_LIBRARY_PATH";
|
||||
|
||||
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 == "cctools") [
|
||||
targetPackages.stdenv.cc.bintools.bintools
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
inherit version;
|
||||
pname = "ghc-binary${binDistUsed.variantSuffix}";
|
||||
|
||||
src = fetchurl binDistUsed.src;
|
||||
|
||||
# Note that for GHC 8.10 versions >= 8.10.6, the GHC HQ musl bindist
|
||||
# uses `integer-simple` and has no `gmp` dependency:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/commit/8306501020cd66f683ad9c215fa8e16c2d62357d
|
||||
# Related nixpkgs issues:
|
||||
# * https://github.com/NixOS/nixpkgs/pull/130441#issuecomment-922452843
|
||||
# TODO: When this file is copied to `ghc-9.*-binary.nix`, determine whether
|
||||
# the GHC 9 branch also switched from `gmp` to `integer-simple` via the
|
||||
# currently-open issue:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20059
|
||||
# and update this comment accordingly.
|
||||
|
||||
nativeBuildInputs = [ perl ];
|
||||
|
||||
# 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 = ''ghc-${version}*/"${binDistUsed.exePathForLibraryCheck}"''; in
|
||||
lib.concatStringsSep "\n" [
|
||||
(''
|
||||
echo "Checking that ghc binary exists in bindist at ${buildExeGlob}"
|
||||
if ! test -e ${buildExeGlob}; then
|
||||
echo >&2 "GHC binary ${binDistUsed.exePathForLibraryCheck} could not be found in the bindist build directory (at ${buildExeGlob}) for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
||||
fi
|
||||
'')
|
||||
(lib.concatMapStringsSep
|
||||
"\n"
|
||||
({ fileToCheckFor, nixPackage }:
|
||||
lib.optionalString (fileToCheckFor != null) ''
|
||||
echo "Checking bindist for ${fileToCheckFor} to ensure that is still used"
|
||||
if ! readelf -d ${buildExeGlob} | grep "${fileToCheckFor}"; then
|
||||
echo >&2 "File ${fileToCheckFor} could not be found in ${binDistUsed.exePathForLibraryCheck} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
||||
fi
|
||||
|
||||
echo "Checking that the nix package ${nixPackage} contains ${fileToCheckFor}"
|
||||
if ! test -e "${lib.getLib nixPackage}/lib/${fileToCheckFor}"; then
|
||||
echo >&2 "Nix package ${nixPackage} did not contain ${fileToCheckFor} for arch ${stdenv.hostPlatform.system}, please check that ghcBinDists correctly reflect the bindist dependencies!"; exit 1;
|
||||
fi
|
||||
''
|
||||
)
|
||||
binDistUsed.archSpecificLibraries
|
||||
)
|
||||
])
|
||||
# GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
|
||||
# during linking
|
||||
+ lib.optionalString stdenv.isDarwin ''
|
||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
||||
# not enough room in the object files for the full path to libiconv :(
|
||||
for exe in $(find . -type f -executable); do
|
||||
isScript $exe && continue
|
||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
||||
done
|
||||
'' +
|
||||
|
||||
# Some scripts used during the build need to have their shebangs patched
|
||||
''
|
||||
patchShebangs ghc-${version}/utils/
|
||||
patchShebangs ghc-${version}/configure
|
||||
'' +
|
||||
# We have to patch the GMP paths for the integer-gmp package.
|
||||
# Note that musl bindists do not contain them,
|
||||
# see: https://gitlab.haskell.org/ghc/ghc/-/issues/20073#note_363231
|
||||
# However, musl bindists >= 8.10.6 use `integer-simple`, not `gmp`.
|
||||
''
|
||||
find . -name integer-gmp.buildinfo \
|
||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
find . -name base.buildinfo \
|
||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
|
||||
'' +
|
||||
# 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.isLinux && stdenv.hostPlatform.isAarch64) ''
|
||||
find . -name package.conf.in \
|
||||
-exec sed -i "s@FFI_LIB_DIR@FFI_LIB_DIR ${numactl.out}/lib@g" {} \;
|
||||
'' +
|
||||
# Rename needed libraries and binaries, fix interpreter
|
||||
lib.optionalString stdenv.isLinux ''
|
||||
find . -type f -executable -exec patchelf \
|
||||
--interpreter ${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
|
||||
''
|
||||
# Detect hadrian Makefile by checking for the target that has the problem
|
||||
if grep '^update_package_db' ghc-${version}*/Makefile > /dev/null; then
|
||||
echo Hadrian bindist, applying workaround for xxx path substitution.
|
||||
# based on https://gitlab.haskell.org/ghc/ghc/-/commit/dd5fecb0e2990b192d92f4dfd7519ecb33164fad.patch
|
||||
substituteInPlace ghc-${version}*/Makefile --replace 'xxx' '\0xxx\0'
|
||||
else
|
||||
echo Not a hadrian bindist, not applying xxx path workaround.
|
||||
fi
|
||||
'';
|
||||
|
||||
# fix for `configure: error: Your linker is affected by binutils #16177`
|
||||
preConfigure = lib.optionalString
|
||||
stdenv.targetPlatform.isAarch32
|
||||
"LD=ld.gold";
|
||||
|
||||
configurePlatforms = [ ];
|
||||
configureFlags = [
|
||||
"--with-gmp-includes=${lib.getDev gmp}/include"
|
||||
# Note `--with-gmp-libraries` does nothing for GHC bindists:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
|
||||
] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
|
||||
# From: https://github.com/NixOS/nixpkgs/pull/43369/commits
|
||||
++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
|
||||
|
||||
# No building is necessary, but calling make without flags ironically
|
||||
# calls install-strip ...
|
||||
dontBuild = true;
|
||||
|
||||
# Patch scripts to include runtime dependencies in $PATH.
|
||||
postInstall = ''
|
||||
for i in "$out/bin/"*; do
|
||||
test ! -h "$i" || continue
|
||||
isScript "$i" || continue
|
||||
sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
|
||||
done
|
||||
'';
|
||||
|
||||
# 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.
|
||||
''
|
||||
(cd $out/lib; ln -s ${ncurses6.out}/lib/libtinfo.so.6)
|
||||
(cd $out/lib; ln -s ${gmp.out}/lib/libgmp.so.10)
|
||||
(cd $out/lib; ln -s ${numactl.out}/lib/libnuma.so.1)
|
||||
for p in $(find "$out/lib" -type f -name "*\.so*"); do
|
||||
(cd $out/lib; ln -s $p)
|
||||
done
|
||||
|
||||
for p in $(find "$out/lib" -type f -executable); do
|
||||
if isELF "$p"; then
|
||||
echo "Patchelfing $p"
|
||||
patchelf --set-rpath "\$ORIGIN:\$ORIGIN/../.." $p
|
||||
fi
|
||||
done
|
||||
''
|
||||
else
|
||||
''
|
||||
for p in $(find "$out" -type f -executable); do
|
||||
if isELF "$p"; then
|
||||
echo "Patchelfing $p"
|
||||
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
||||
fi
|
||||
done
|
||||
'') + lib.optionalString stdenv.isDarwin ''
|
||||
# not enough room in the object files for the full path to libiconv :(
|
||||
for exe in $(find "$out" -type f -executable); do
|
||||
isScript $exe && continue
|
||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
||||
done
|
||||
|
||||
for file in $(find "$out" -name setup-config); do
|
||||
substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
|
||||
done
|
||||
'' +
|
||||
lib.optionalString minimal ''
|
||||
# Remove profiling files
|
||||
find $out -type f -name '*.p_o' -delete
|
||||
find $out -type f -name '*.p_hi' -delete
|
||||
find $out -type f -name '*_p.a' -delete
|
||||
# `-f` because e.g. musl bindist does not have this file.
|
||||
rm -f $out/lib/ghc-*/bin/ghc-iserv-prof
|
||||
# Hydra will redistribute this derivation, so we have to keep the docs for
|
||||
# legal reasons (retaining the legal notices etc)
|
||||
# As a last resort we could unpack the docs separately and symlink them in.
|
||||
# They're in $out/share/{doc,man}.
|
||||
'';
|
||||
|
||||
# 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 "pie";
|
||||
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
# Sanity check, can ghc create executables?
|
||||
cd $TMP
|
||||
mkdir test-ghc; cd test-ghc
|
||||
cat > main.hs << EOF
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Main where
|
||||
main = putStrLn \$([|"yes"|])
|
||||
EOF
|
||||
env -i $out/bin/ghc --make main.hs || exit 1
|
||||
echo compilation ok
|
||||
[ $(./main) == "yes" ]
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
targetPrefix = "";
|
||||
enableShared = true;
|
||||
|
||||
inherit llvmPackages;
|
||||
|
||||
# Our Cabal compiler name
|
||||
haskellCompilerName = "ghc-${version}";
|
||||
};
|
||||
|
||||
meta = rec {
|
||||
homepage = "http://haskell.org/ghc";
|
||||
description = "The Glasgow Haskell Compiler";
|
||||
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; [
|
||||
prusnak
|
||||
domenkozar
|
||||
] ++ lib.teams.haskell.members;
|
||||
};
|
||||
}
|
||||
391
pkgs/development/compilers/ghc/8.10.7.nix
Normal file
391
pkgs/development/compilers/ghc/8.10.7.nix
Normal file
|
|
@ -0,0 +1,391 @@
|
|||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
||||
|
||||
# build-tools
|
||||
, bootPkgs
|
||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
||||
, xattr, autoSignDarwinBinariesHook
|
||||
, bash
|
||||
|
||||
, libiconv ? null, ncurses
|
||||
|
||||
, # GHC can be built with system libffi or a bundled one.
|
||||
libffi ? null
|
||||
|
||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
||||
|| stdenv.targetPlatform.isPower
|
||||
|| stdenv.targetPlatform.isSparc)
|
||||
, # LLVM is conceptually a run-time-only depedendency, but for
|
||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
||||
# build-time dependency too.
|
||||
buildTargetLlvmPackages, llvmPackages
|
||||
|
||||
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
||||
# library instead of the faster but GPLed integer-gmp library.
|
||||
enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp), gmp
|
||||
|
||||
, # If enabled, use -fPIC when compiling static libs.
|
||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
||||
|
||||
# aarch64 outputs otherwise exceed 2GB limit
|
||||
, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
|
||||
|
||||
, # Whether to build dynamic libs for the standard library (on the target
|
||||
# platform). Static libs are always built.
|
||||
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
|
||||
|
||||
, # Whether to build terminfo.
|
||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
||||
|
||||
, # What flavour to build. An empty string indicates no
|
||||
# specific flavour and falls back to ghc default values.
|
||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
||||
|
||||
, # Whether to build sphinx documentation.
|
||||
enableDocs ? (
|
||||
# Docs disabled for musl and cross because it's a large task to keep
|
||||
# all `sphinx` dependencies building in those environments.
|
||||
# `sphinx` pulls in among others:
|
||||
# Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
&& !stdenv.hostPlatform.isMusl
|
||||
)
|
||||
|
||||
, enableHaddockProgram ?
|
||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
|
||||
, # Whether to disable the large address space allocator
|
||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
||||
}:
|
||||
|
||||
assert !enableIntegerSimple -> gmp != null;
|
||||
|
||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
||||
# see note [HADDOCK_DOCS].
|
||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
||||
|
||||
let
|
||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
||||
|
||||
inherit (bootPkgs) ghc;
|
||||
|
||||
# TODO(@Ericson2314) Make unconditional
|
||||
targetPrefix = lib.optionalString
|
||||
(targetPlatform != hostPlatform)
|
||||
"${targetPlatform.config}-";
|
||||
|
||||
buildMK = ''
|
||||
BuildFlavour = ${ghcFlavour}
|
||||
ifneq \"\$(BuildFlavour)\" \"\"
|
||||
include mk/flavours/\$(BuildFlavour).mk
|
||||
endif
|
||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
||||
BUILD_SPHINX_PDF = NO
|
||||
'' +
|
||||
# Note [HADDOCK_DOCS]:
|
||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
||||
# program is built (which we generally always want to have a complete GHC install)
|
||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
||||
# (which is impossible for cross-compilation); see:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
||||
# program, so it can never generate haddocks for any packages.
|
||||
# If this is solved in the future, we'd like to unconditionally
|
||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
||||
''
|
||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
||||
INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
|
||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
||||
CrossCompilePrefix = ${targetPrefix}
|
||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
||||
GhcLibWays = "v dyn"
|
||||
'' + lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC
|
||||
GhcRtsHcOpts += -fPIC
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
EXTRA_CC_OPTS += -std=gnu99
|
||||
''
|
||||
# While split sections are now enabled by default in ghc 8.8 for windows,
|
||||
# they seem to lead to `too many sections` errors when building base for
|
||||
# profiling.
|
||||
+ lib.optionalString targetPlatform.isWindows ''
|
||||
SplitSections = NO
|
||||
'';
|
||||
|
||||
# Splicer will pull out correct variations
|
||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
||||
++ [libffi]
|
||||
++ lib.optional (!enableIntegerSimple) gmp
|
||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
||||
|
||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
||||
toolsForTarget = [
|
||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
||||
|
||||
targetCC = builtins.head toolsForTarget;
|
||||
|
||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
||||
# derivation for certain tools depending on the platform.
|
||||
bintoolsFor = {
|
||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
||||
# x86_64-darwin.
|
||||
install_name_tool =
|
||||
if stdenv.targetPlatform.isAarch64
|
||||
then targetCC.bintools
|
||||
else targetCC.bintools.bintools;
|
||||
# Same goes for strip.
|
||||
strip =
|
||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
||||
then targetCC.bintools
|
||||
else targetCC.bintools.bintools;
|
||||
};
|
||||
|
||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
||||
# see #84670 and #49071 for more background.
|
||||
useLdGold = targetPlatform.linker == "gold" ||
|
||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
||||
|
||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
||||
variantSuffix = lib.concatStrings [
|
||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
||||
(lib.optionalString enableIntegerSimple "-integer-simple")
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
||||
|
||||
stdenv.mkDerivation (rec {
|
||||
version = "8.10.7";
|
||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
||||
sha256 = "e3eef6229ce9908dfe1ea41436befb0455fefb1932559e860ad4c606b0d03c9d";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
outputs = [ "out" "doc" ];
|
||||
|
||||
patches = [
|
||||
# See upstream patch at
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build
|
||||
# from source distributions, the auto-generated configure script needs to be
|
||||
# patched as well, therefore we use an in-tree patch instead of pulling the
|
||||
# upstream patch. Don't forget to check backport status of the upstream patch
|
||||
# when adding new GHC releases in nixpkgs.
|
||||
./respect-ar-path.patch
|
||||
|
||||
# cabal passes incorrect --host= when cross-compiling
|
||||
# https://github.com/haskell/cabal/issues/5887
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/122bd81150386867da07fdc9ad5096db6719545a/overlays/patches/ghc/cabal-host.patch";
|
||||
sha256 = "sha256:0yd0sajgi24sc1w5m55lkg2lp6kfkgpp3lgija2c8y3cmkwfpdc1";
|
||||
})
|
||||
|
||||
# In order to build ghcjs packages, the Cabal of the ghc used for the ghcjs
|
||||
# needs to be patched. Ref https://github.com/haskell/cabal/pull/7575
|
||||
(fetchpatch {
|
||||
url = "https://github.com/haskell/cabal/commit/369c4a0a54ad08a9e6b0d3bd303fedd7b5e5a336.patch";
|
||||
sha256 = "120f11hwyaqa0pq9g5l1300crqij49jg0rh83hnp9sa49zfdwx1n";
|
||||
stripLen = 3;
|
||||
extraPrefix = "libraries/Cabal/Cabal/";
|
||||
})
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
# Make Block.h compile with c++ compilers. Remove with the next release
|
||||
(fetchpatch {
|
||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
|
||||
sha256 = "0r4zjj0bv1x1m2dgxp3adsf2xkr94fjnyj1igsivd9ilbs5ja0b5";
|
||||
})
|
||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
||||
|
||||
# Prevent the paths module from emitting symbols that we don't use
|
||||
# when building with separate outputs.
|
||||
#
|
||||
# These cause problems as they're not eliminated by GHC's dead code
|
||||
# elimination on aarch64-darwin. (see
|
||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
||||
./cabal-paths.patch
|
||||
];
|
||||
|
||||
postPatch = "patchShebangs .";
|
||||
|
||||
# GHC is a bit confused on its cross terminology.
|
||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
||||
preConfigure = ''
|
||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
||||
export "''${env#TARGET_}=''${!env}"
|
||||
done
|
||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
||||
# the *host* tools.
|
||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
||||
'' + lib.optionalString useLLVM ''
|
||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
||||
'' + ''
|
||||
|
||||
echo -n "${buildMK}" > mk/build.mk
|
||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
||||
|
||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
||||
'' + lib.optionalString targetPlatform.isMusl ''
|
||||
echo "patching llvm-targets for musl targets..."
|
||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
||||
echo "(go go gadget sed)"
|
||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
||||
|
||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
||||
for x in configure aclocal.m4; do
|
||||
substituteInPlace $x \
|
||||
--replace '*-android*|*-gnueabi*)' \
|
||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
||||
done
|
||||
'';
|
||||
|
||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
||||
configurePlatforms = [ "build" "host" ]
|
||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
||||
|
||||
# `--with` flags for libraries needed for RTS linker
|
||||
configureFlags = [
|
||||
"--datadir=$doc/share/doc/ghc"
|
||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
||||
] ++ lib.optionals (libffi != null) [
|
||||
"--with-system-libffi"
|
||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
|
||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
||||
"--with-iconv-includes=${libiconv}/include"
|
||||
"--with-iconv-libraries=${libiconv}/lib"
|
||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
||||
"--enable-bootstrap-with-devel-snapshot"
|
||||
] ++ lib.optionals useLdGold [
|
||||
"CFLAGS=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
||||
"--disable-large-address-space"
|
||||
];
|
||||
|
||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
||||
strictDeps = true;
|
||||
|
||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
||||
dontAddExtraLibs = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
perl autoconf automake m4 python3
|
||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
||||
autoSignDarwinBinariesHook
|
||||
] ++ lib.optionals enableDocs [
|
||||
sphinx
|
||||
];
|
||||
|
||||
# For building runtime libs
|
||||
depsBuildTarget = toolsForTarget;
|
||||
|
||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
||||
|
||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
||||
|
||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
||||
# that in turn causes GHCi to abort
|
||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
||||
|
||||
checkTarget = "test";
|
||||
|
||||
hardeningDisable =
|
||||
[ "format" ]
|
||||
# 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
|
||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
||||
|
||||
# big-parallel allows us to build with more than 2 cores on
|
||||
# Hydra which already warrants a significant speedup
|
||||
requiredSystemFeatures = [ "big-parallel" ];
|
||||
|
||||
postInstall = ''
|
||||
# Install the bash completion file.
|
||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit bootPkgs targetPrefix;
|
||||
|
||||
inherit llvmPackages;
|
||||
inherit enableShared;
|
||||
|
||||
# This is used by the haskell builder to query
|
||||
# the presence of the haddock program.
|
||||
hasHaddock = enableHaddockProgram;
|
||||
|
||||
# Our Cabal compiler name
|
||||
haskellCompilerName = "ghc-${version}";
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "http://haskell.org/ghc";
|
||||
description = "The Glasgow Haskell Compiler";
|
||||
maintainers = with lib.maintainers; [
|
||||
guibou
|
||||
] ++ lib.teams.haskell.members;
|
||||
timeout = 24 * 3600;
|
||||
inherit (ghc.meta) license platforms;
|
||||
};
|
||||
|
||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
noAuditTmpdir = true;
|
||||
})
|
||||
221
pkgs/development/compilers/ghc/8.6.5-binary.nix
Normal file
221
pkgs/development/compilers/ghc/8.6.5-binary.nix
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
{ lib, stdenv
|
||||
, fetchurl, perl, gcc
|
||||
, ncurses5, ncurses6, gmp, glibc, libiconv
|
||||
, llvmPackages
|
||||
, coreutils
|
||||
, targetPackages
|
||||
}:
|
||||
|
||||
# Prebuilt only does native
|
||||
assert stdenv.targetPlatform == stdenv.hostPlatform;
|
||||
|
||||
let
|
||||
useLLVM = !stdenv.targetPlatform.isx86;
|
||||
|
||||
useNcurses6 = stdenv.hostPlatform.system == "x86_64-linux";
|
||||
|
||||
ourNcurses = if useNcurses6 then ncurses6 else ncurses5;
|
||||
|
||||
libPath = lib.makeLibraryPath ([
|
||||
ourNcurses gmp
|
||||
] ++ lib.optional (stdenv.hostPlatform.isDarwin) libiconv);
|
||||
|
||||
libEnvVar = lib.optionalString stdenv.hostPlatform.isDarwin "DY"
|
||||
+ "LD_LIBRARY_PATH";
|
||||
|
||||
glibcDynLinker = assert stdenv.isLinux;
|
||||
if stdenv.hostPlatform.libc == "glibc" then
|
||||
# Could be stdenv.cc.bintools.dynamicLinker, keeping as-is to avoid rebuild.
|
||||
''"$(cat $NIX_CC/nix-support/dynamic-linker)"''
|
||||
else
|
||||
"${lib.getLib glibc}/lib/ld-linux*";
|
||||
|
||||
downloadsUrl = "https://downloads.haskell.org/ghc";
|
||||
|
||||
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 == "cctools") [
|
||||
targetPackages.stdenv.cc.bintools.bintools
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
version = "8.6.5";
|
||||
pname = "ghc-binary";
|
||||
|
||||
# https://downloads.haskell.org/~ghc/8.6.5/
|
||||
src = fetchurl ({
|
||||
i686-linux = {
|
||||
# Don't use the Fedora27 build (as below) because there isn't one!
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-i386-deb9-linux.tar.xz";
|
||||
sha256 = "1p2h29qghql19ajk755xa0yxkn85slbds8m9n5196ris743vkp8w";
|
||||
};
|
||||
x86_64-linux = {
|
||||
# This is the Fedora build because it links against ncurses6 where the
|
||||
# deb9 one links against ncurses5, see here
|
||||
# https://github.com/NixOS/nixpkgs/issues/85924 for a discussion
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-fedora27-linux.tar.xz";
|
||||
sha256 = "18dlqm5d028fqh6ghzn7pgjspr5smw030jjzl3kq6q1kmwzbay6g";
|
||||
};
|
||||
aarch64-linux = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-aarch64-ubuntu18.04-linux.tar.xz";
|
||||
sha256 = "11n7l2a36i5vxzzp85la2555q4m34l747g0pnmd81cp46y85hlhq";
|
||||
};
|
||||
x86_64-darwin = {
|
||||
url = "${downloadsUrl}/${version}/ghc-${version}-x86_64-apple-darwin.tar.xz";
|
||||
sha256 = "0s9188vhhgf23q3rjarwhbr524z6h2qga5xaaa2pma03sfqvvhfz";
|
||||
};
|
||||
}.${stdenv.hostPlatform.system}
|
||||
or (throw "cannot bootstrap GHC on this platform"));
|
||||
|
||||
nativeBuildInputs = [ perl ];
|
||||
|
||||
# Cannot patchelf beforehand due to relative RPATHs that anticipate
|
||||
# the final install location/
|
||||
${libEnvVar} = libPath;
|
||||
|
||||
postUnpack =
|
||||
# GHC has dtrace probes, which causes ld to try to open /usr/lib/libdtrace.dylib
|
||||
# during linking
|
||||
lib.optionalString stdenv.isDarwin ''
|
||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
||||
# not enough room in the object files for the full path to libiconv :(
|
||||
for exe in $(find . -type f -executable); do
|
||||
isScript $exe && continue
|
||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
||||
done
|
||||
'' +
|
||||
|
||||
# Some scripts used during the build need to have their shebangs patched
|
||||
''
|
||||
patchShebangs ghc-${version}/utils/
|
||||
patchShebangs ghc-${version}/configure
|
||||
'' +
|
||||
|
||||
# We have to patch the GMP paths for the integer-gmp package.
|
||||
''
|
||||
find . -name integer-gmp.buildinfo \
|
||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${gmp.out}/lib@" {} \;
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
find . -name base.buildinfo \
|
||||
-exec sed -i "s@extra-lib-dirs: @extra-lib-dirs: ${libiconv}/lib@" {} \;
|
||||
'' +
|
||||
# Rename needed libraries and binaries, fix interpreter
|
||||
lib.optionalString stdenv.isLinux ''
|
||||
find . -type f -perm -0100 \
|
||||
-exec patchelf \
|
||||
--replace-needed libncurses${lib.optionalString stdenv.is64bit "w"}.so.5 libncurses.so \
|
||||
${ # This isn't required for x86_64-linux where we use ncurses6
|
||||
lib.optionalString (!useNcurses6) "--replace-needed libtinfo.so libtinfo.so.5"
|
||||
} \
|
||||
--interpreter ${glibcDynLinker} {} \;
|
||||
|
||||
sed -i "s|/usr/bin/perl|perl\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
|
||||
sed -i "s|/usr/bin/gcc|gcc\x00 |" ghc-${version}/ghc/stage2/build/tmp/ghc-stage2
|
||||
'' +
|
||||
# We're kludging a glibc bindist into working with non-glibc...
|
||||
# Here we patch up the use of `__strdup` (part of glibc binary ABI)
|
||||
# to instead use `strdup` since musl doesn't provide __strdup
|
||||
# (`__strdup` is defined to be an alias of `strdup` anyway[1]).
|
||||
# [1] http://refspecs.linuxbase.org/LSB_4.0.0/LSB-Core-generic/LSB-Core-generic/baselib---strdup-1.html
|
||||
# Use objcopy magic to make the change:
|
||||
lib.optionalString stdenv.hostPlatform.isMusl ''
|
||||
find ./ghc-${version}/rts -name "libHSrts*.a" -exec ''${OBJCOPY:-objcopy} --redefine-sym __strdup=strdup {} \;
|
||||
'';
|
||||
|
||||
configurePlatforms = [ ];
|
||||
configureFlags = [
|
||||
"--with-gmp-includes=${lib.getDev gmp}/include"
|
||||
# Note `--with-gmp-libraries` does nothing for GHC bindists:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6124
|
||||
] ++ lib.optional stdenv.isDarwin "--with-gcc=${./gcc-clang-wrapper.sh}"
|
||||
++ lib.optional stdenv.hostPlatform.isMusl "--disable-ld-override";
|
||||
|
||||
# No building is necessary, but calling make without flags ironically
|
||||
# calls install-strip ...
|
||||
dontBuild = true;
|
||||
|
||||
# Patch scripts to include runtime dependencies in $PATH.
|
||||
postInstall = ''
|
||||
for i in "$out/bin/"*; do
|
||||
test ! -h "$i" || continue
|
||||
isScript "$i" || continue
|
||||
sed -i -e '2i export PATH="${lib.makeBinPath runtimeDeps}:$PATH"' "$i"
|
||||
done
|
||||
'';
|
||||
|
||||
# On Linux, use patchelf to modify the executables so that they can
|
||||
# find editline/gmp.
|
||||
postFixup = lib.optionalString stdenv.isLinux ''
|
||||
for p in $(find "$out" -type f -executable); do
|
||||
if isELF "$p"; then
|
||||
echo "Patchelfing $p"
|
||||
patchelf --set-rpath "${libPath}:$(patchelf --print-rpath $p)" $p
|
||||
fi
|
||||
done
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
# not enough room in the object files for the full path to libiconv :(
|
||||
for exe in $(find "$out" -type f -executable); do
|
||||
isScript $exe && continue
|
||||
ln -fs ${libiconv}/lib/libiconv.dylib $(dirname $exe)/libiconv.dylib
|
||||
install_name_tool -change /usr/lib/libiconv.2.dylib @executable_path/libiconv.dylib -change /usr/local/lib/gcc/6/libgcc_s.1.dylib ${gcc.cc.lib}/lib/libgcc_s.1.dylib $exe
|
||||
done
|
||||
|
||||
for file in $(find "$out" -name setup-config); do
|
||||
substituteInPlace $file --replace /usr/bin/ranlib "$(type -P ranlib)"
|
||||
done
|
||||
'';
|
||||
|
||||
# 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 "pie";
|
||||
|
||||
doInstallCheck = true;
|
||||
installCheckPhase = ''
|
||||
# Sanity check, can ghc create executables?
|
||||
cd $TMP
|
||||
mkdir test-ghc; cd test-ghc
|
||||
cat > main.hs << EOF
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
module Main where
|
||||
main = putStrLn \$([|"yes"|])
|
||||
EOF
|
||||
env -i $out/bin/ghc --make main.hs || exit 1
|
||||
echo compilation ok
|
||||
[ $(./main) == "yes" ]
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
targetPrefix = "";
|
||||
enableShared = true;
|
||||
|
||||
inherit llvmPackages;
|
||||
|
||||
# Our Cabal compiler name
|
||||
haskellCompilerName = "ghc-${version}";
|
||||
};
|
||||
|
||||
meta = rec {
|
||||
license = lib.licenses.bsd3;
|
||||
platforms = ["x86_64-linux" "i686-linux" "x86_64-darwin"];
|
||||
# build segfaults, use ghc8102Binary which has proper musl support instead
|
||||
broken = stdenv.hostPlatform.isMusl;
|
||||
maintainers = with lib.maintainers; [
|
||||
guibou
|
||||
] ++ lib.teams.haskell.members;
|
||||
};
|
||||
}
|
||||
376
pkgs/development/compilers/ghc/8.8.4.nix
Normal file
376
pkgs/development/compilers/ghc/8.8.4.nix
Normal file
|
|
@ -0,0 +1,376 @@
|
|||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
||||
|
||||
# build-tools
|
||||
, bootPkgs
|
||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
||||
, bash
|
||||
|
||||
, libiconv ? null, ncurses
|
||||
|
||||
, # GHC can be built with system libffi or a bundled one.
|
||||
libffi ? null
|
||||
|
||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
||||
|| stdenv.targetPlatform.isPower
|
||||
|| stdenv.targetPlatform.isSparc)
|
||||
, # LLVM is conceptually a run-time-only depedendency, but for
|
||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
||||
# build-time dependency too.
|
||||
buildTargetLlvmPackages, llvmPackages
|
||||
|
||||
, # If enabled, GHC will be built with the GPL-free but slower integer-simple
|
||||
# library instead of the faster but GPLed integer-gmp library.
|
||||
enableIntegerSimple ? !(lib.meta.availableOn stdenv.hostPlatform gmp), gmp
|
||||
|
||||
, # If enabled, use -fPIC when compiling static libs.
|
||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
||||
|
||||
# aarch64 outputs otherwise exceed 2GB limit
|
||||
, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
|
||||
|
||||
, # Whether to build dynamic libs for the standard library (on the target
|
||||
# platform). Static libs are always built.
|
||||
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
|
||||
|
||||
, # Whether to build terminfo.
|
||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
||||
|
||||
, # What flavour to build. An empty string indicates no
|
||||
# specific flavour and falls back to ghc default values.
|
||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
||||
|
||||
, # Whether to build sphinx documentation.
|
||||
enableDocs ? (
|
||||
# Docs disabled for musl and cross because it's a large task to keep
|
||||
# all `sphinx` dependencies building in those environments.
|
||||
# `sphinx` pullls in among others:
|
||||
# Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
&& !stdenv.hostPlatform.isMusl
|
||||
)
|
||||
|
||||
, enableHaddockProgram ?
|
||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
|
||||
, # Whether to disable the large address space allocator
|
||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
||||
}:
|
||||
|
||||
assert !enableIntegerSimple -> gmp != null;
|
||||
|
||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
||||
# see note [HADDOCK_DOCS].
|
||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
||||
|
||||
let
|
||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
||||
|
||||
inherit (bootPkgs) ghc;
|
||||
|
||||
# TODO(@Ericson2314) Make unconditional
|
||||
targetPrefix = lib.optionalString
|
||||
(targetPlatform != hostPlatform)
|
||||
"${targetPlatform.config}-";
|
||||
|
||||
buildMK = dontStrip: ''
|
||||
BuildFlavour = ${ghcFlavour}
|
||||
ifneq \"\$(BuildFlavour)\" \"\"
|
||||
include mk/flavours/\$(BuildFlavour).mk
|
||||
endif
|
||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
||||
BUILD_SPHINX_PDF = NO
|
||||
'' +
|
||||
# Note [HADDOCK_DOCS]:
|
||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
||||
# program is built (which we generally always want to have a complete GHC install)
|
||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
||||
# (which is impossible for cross-compilation); see:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
||||
# program, so it can never generate haddocks for any packages.
|
||||
# If this is solved in the future, we'd like to unconditionally
|
||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
||||
''
|
||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
||||
INTEGER_LIBRARY = ${if enableIntegerSimple then "integer-simple" else "integer-gmp"}
|
||||
''
|
||||
# We only need to build stage1 on most cross-compilation because
|
||||
# we will be running the compiler on the native system. In some
|
||||
# situations, like native Musl compilation, we need the compiler
|
||||
# to actually link to our new Libc. The iOS simulator is a special
|
||||
# exception because we can’t actually run simulators binaries
|
||||
# ourselves.
|
||||
+ lib.optionalString (targetPlatform != hostPlatform) ''
|
||||
Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
|
||||
CrossCompilePrefix = ${targetPrefix}
|
||||
'' + lib.optionalString dontStrip ''
|
||||
STRIP_CMD = :
|
||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
||||
GhcLibWays = "v dyn"
|
||||
'' + lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC
|
||||
GhcRtsHcOpts += -fPIC
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
EXTRA_CC_OPTS += -std=gnu99
|
||||
''
|
||||
# While split sections are now enabled by default in ghc 8.8 for windows,
|
||||
# they seem to lead to `too many sections` errors when building base for
|
||||
# profiling.
|
||||
+ lib.optionalString targetPlatform.isWindows ''
|
||||
SplitSections = NO
|
||||
'';
|
||||
|
||||
# Splicer will pull out correct variations
|
||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
||||
++ [libffi]
|
||||
++ lib.optional (!enableIntegerSimple) gmp
|
||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
||||
|
||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
||||
toolsForTarget = [
|
||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
||||
|
||||
targetCC = builtins.head toolsForTarget;
|
||||
|
||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
||||
# see #84670 and #49071 for more background.
|
||||
useLdGold = targetPlatform.linker == "gold" ||
|
||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
||||
|
||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
||||
variantSuffix = lib.concatStrings [
|
||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
||||
(lib.optionalString enableIntegerSimple "-integer-simple")
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
||||
|
||||
stdenv.mkDerivation (rec {
|
||||
version = "8.8.4";
|
||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
||||
sha256 = "0bgwbxxvdn56l91bp9p5d083gzcfdi6z8l8b17qzjpr3n8w5wl7h";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
outputs = [ "out" "doc" ];
|
||||
|
||||
patches = [
|
||||
# See upstream patch at
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/4885. Since we build
|
||||
# from source distributions, the auto-generated configure script needs to be
|
||||
# patched as well, therefore we use an in-tree patch instead of pulling the
|
||||
# upstream patch. Don't forget to check backport status of the upstream patch
|
||||
# when adding new GHC releases in nixpkgs.
|
||||
./respect-ar-path.patch
|
||||
# Fix documentation configuration which causes a syntax error with sphinx 4.*
|
||||
# See also https://gitlab.haskell.org/ghc/ghc/-/issues/19962
|
||||
./sphinx-4-configuration.patch
|
||||
# cabal passes incorrect --host= when cross-compiling
|
||||
# https://github.com/haskell/cabal/issues/5887
|
||||
(fetchpatch {
|
||||
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/122bd81150386867da07fdc9ad5096db6719545a/overlays/patches/ghc/cabal-host.patch";
|
||||
sha256 = "sha256:0yd0sajgi24sc1w5m55lkg2lp6kfkgpp3lgija2c8y3cmkwfpdc1";
|
||||
})
|
||||
|
||||
# error: 'VirtualAllocExNuma' redeclared as different kind of symbol
|
||||
# name conflict between rts/win32/OSMem.c and winbase.h from the mingw-w64 runtime package
|
||||
# Renamed to match ghc8.8:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/commit/4b431f334018eaef2cf36de3316025c68c922915#20d64c0bdc272817149d1d5cf20a73a8b5fd637f
|
||||
./rename-numa-api-call.patch
|
||||
];
|
||||
|
||||
postPatch = "patchShebangs .";
|
||||
|
||||
# GHC is a bit confused on its cross terminology.
|
||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
||||
preConfigure =
|
||||
# Aarch64 allow backward bootstrapping since earlier versions are unstable.
|
||||
# Same for musl, as earlier versions do not provide a musl bindist for bootstrapping.
|
||||
lib.optionalString (stdenv.isAarch64 || stdenv.hostPlatform.isMusl) ''
|
||||
find . -name \*\.cabal\* -exec sed -i -e 's/\(base.*\)4.14/\14.16/' {} \; \
|
||||
-exec sed -i -e 's/\(prim.*\)0.6/\10.8/' {} \;
|
||||
''
|
||||
+ ''
|
||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
||||
export "''${env#TARGET_}=''${!env}"
|
||||
done
|
||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
||||
# the *host* tools.
|
||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
||||
export STRIP="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}strip"
|
||||
'' + lib.optionalString useLLVM ''
|
||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
||||
'' + ''
|
||||
|
||||
echo -n "${buildMK dontStrip}" > mk/build.mk
|
||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
||||
'' + lib.optionalString targetPlatform.isMusl ''
|
||||
echo "patching llvm-targets for musl targets..."
|
||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
||||
echo "(go go gadget sed)"
|
||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
||||
|
||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
||||
for x in configure aclocal.m4; do
|
||||
substituteInPlace $x \
|
||||
--replace '*-android*|*-gnueabi*)' \
|
||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
||||
done
|
||||
'';
|
||||
|
||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
||||
configurePlatforms = [ "build" "host" ]
|
||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
||||
|
||||
# `--with` flags for libraries needed for RTS linker
|
||||
configureFlags = [
|
||||
"--datadir=$doc/share/doc/ghc"
|
||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
||||
] ++ lib.optionals (libffi != null) [
|
||||
"--with-system-libffi"
|
||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableIntegerSimple) [
|
||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
||||
"--with-iconv-includes=${libiconv}/include"
|
||||
"--with-iconv-libraries=${libiconv}/lib"
|
||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
||||
"--enable-bootstrap-with-devel-snapshot"
|
||||
] ++ lib.optionals useLdGold [
|
||||
"CFLAGS=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
||||
"--disable-large-address-space"
|
||||
];
|
||||
|
||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
||||
strictDeps = true;
|
||||
|
||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
||||
dontAddExtraLibs = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
perl autoconf automake m4 python3
|
||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
||||
] ++ lib.optionals enableDocs [
|
||||
sphinx
|
||||
];
|
||||
|
||||
# For building runtime libs
|
||||
depsBuildTarget = toolsForTarget;
|
||||
|
||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
||||
|
||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
||||
|
||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
||||
# that in turn causes GHCi to abort
|
||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
||||
|
||||
checkTarget = "test";
|
||||
|
||||
hardeningDisable =
|
||||
[ "format" ]
|
||||
# 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
|
||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
||||
|
||||
postInstall = ''
|
||||
# Install the bash completion file.
|
||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit bootPkgs targetPrefix;
|
||||
|
||||
inherit llvmPackages;
|
||||
inherit enableShared;
|
||||
|
||||
# This is used by the haskell builder to query
|
||||
# the presence of the haddock program.
|
||||
hasHaddock = enableHaddockProgram;
|
||||
|
||||
# Our Cabal compiler name
|
||||
haskellCompilerName = "ghc-${version}";
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "http://haskell.org/ghc";
|
||||
description = "The Glasgow Haskell Compiler";
|
||||
maintainers = with lib.maintainers; [
|
||||
guibou
|
||||
] ++ lib.teams.haskell.members;
|
||||
timeout = 24 * 3600;
|
||||
inherit (ghc.meta) license;
|
||||
# hardcode platforms because the bootstrap GHC differs depending on the platform,
|
||||
# with differing platforms available for each of them; See HACK comment in
|
||||
# 8.10.2-binary.nix for an explanation of the musl special casing.
|
||||
platforms = [
|
||||
"x86_64-linux"
|
||||
] ++ lib.optionals (!hostPlatform.isMusl) [
|
||||
"i686-linux"
|
||||
"aarch64-linux"
|
||||
"x86_64-darwin"
|
||||
];
|
||||
# integer-simple builds are broken with musl when bootstrapping using
|
||||
# GHC 8.10.2 and below, however it is not possible to reverse bootstrap
|
||||
# GHC 8.8.4 with GHC 8.10.7.
|
||||
# See https://github.com/NixOS/nixpkgs/pull/138523#issuecomment-927339953
|
||||
broken = hostPlatform.isMusl && enableIntegerSimple;
|
||||
};
|
||||
|
||||
dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
|
||||
|
||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
|
||||
dontPatchELF = true;
|
||||
noAuditTmpdir = true;
|
||||
})
|
||||
377
pkgs/development/compilers/ghc/9.0.2.nix
Normal file
377
pkgs/development/compilers/ghc/9.0.2.nix
Normal file
|
|
@ -0,0 +1,377 @@
|
|||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
||||
|
||||
# build-tools
|
||||
, bootPkgs
|
||||
, autoconf, automake, coreutils, fetchurl, perl, python3, m4, sphinx, xattr
|
||||
, autoSignDarwinBinariesHook
|
||||
, bash
|
||||
, fetchpatch
|
||||
|
||||
, libiconv ? null, ncurses
|
||||
, glibcLocales ? null
|
||||
|
||||
, # GHC can be built with system libffi or a bundled one.
|
||||
libffi ? null
|
||||
|
||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
||||
|| stdenv.targetPlatform.isPower
|
||||
|| stdenv.targetPlatform.isSparc)
|
||||
, # LLVM is conceptually a run-time-only depedendency, but for
|
||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
||||
# build-time dependency too.
|
||||
buildTargetLlvmPackages, llvmPackages
|
||||
|
||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
||||
# bignum backend instead of the faster but GPLed gmp backend.
|
||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
|
||||
, gmp
|
||||
|
||||
, # If enabled, use -fPIC when compiling static libs.
|
||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
||||
|
||||
# aarch64 outputs otherwise exceed 2GB limit
|
||||
, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
|
||||
|
||||
, # Whether to build dynamic libs for the standard library (on the target
|
||||
# platform). Static libs are always built.
|
||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
||||
|
||||
, # Whether to build terminfo.
|
||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
||||
|
||||
, # What flavour to build. An empty string indicates no
|
||||
# specific flavour and falls back to ghc default values.
|
||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
||||
|
||||
, # Whether to build sphinx documentation.
|
||||
enableDocs ? (
|
||||
# Docs disabled for musl and cross because it's a large task to keep
|
||||
# all `sphinx` dependencies building in those environments.
|
||||
# `sphinx` pullls in among others:
|
||||
# Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
&& !stdenv.hostPlatform.isMusl
|
||||
)
|
||||
|
||||
, enableHaddockProgram ?
|
||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
|
||||
, # Whether to disable the large address space allocator
|
||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
||||
}:
|
||||
|
||||
assert !enableNativeBignum -> gmp != null;
|
||||
|
||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
||||
# see note [HADDOCK_DOCS].
|
||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
||||
|
||||
let
|
||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
||||
|
||||
inherit (bootPkgs) ghc;
|
||||
|
||||
# TODO(@Ericson2314) Make unconditional
|
||||
targetPrefix = lib.optionalString
|
||||
(targetPlatform != hostPlatform)
|
||||
"${targetPlatform.config}-";
|
||||
|
||||
buildMK = ''
|
||||
BuildFlavour = ${ghcFlavour}
|
||||
ifneq \"\$(BuildFlavour)\" \"\"
|
||||
include mk/flavours/\$(BuildFlavour).mk
|
||||
endif
|
||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
||||
BUILD_SPHINX_PDF = NO
|
||||
'' +
|
||||
# Note [HADDOCK_DOCS]:
|
||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
||||
# program is built (which we generally always want to have a complete GHC install)
|
||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
||||
# (which is impossible for cross-compilation); see:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
||||
# program, so it can never generate haddocks for any packages.
|
||||
# If this is solved in the future, we'd like to unconditionally
|
||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
||||
''
|
||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
||||
CrossCompilePrefix = ${targetPrefix}
|
||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
||||
GhcLibWays = "v dyn"
|
||||
'' +
|
||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
||||
lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
EXTRA_CC_OPTS += -std=gnu99
|
||||
'';
|
||||
|
||||
# Splicer will pull out correct variations
|
||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
||||
++ [libffi]
|
||||
++ lib.optional (!enableNativeBignum) gmp
|
||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
||||
|
||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
||||
toolsForTarget = [
|
||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
||||
|
||||
targetCC = builtins.head toolsForTarget;
|
||||
|
||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
||||
# derivation for certain tools depending on the platform.
|
||||
bintoolsFor = {
|
||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
||||
# x86_64-darwin.
|
||||
install_name_tool =
|
||||
if stdenv.targetPlatform.isAarch64
|
||||
then targetCC.bintools
|
||||
else targetCC.bintools.bintools;
|
||||
# Same goes for strip.
|
||||
strip =
|
||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
||||
then targetCC.bintools
|
||||
else targetCC.bintools.bintools;
|
||||
};
|
||||
|
||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
||||
# see #84670 and #49071 for more background.
|
||||
useLdGold = targetPlatform.linker == "gold" ||
|
||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
||||
|
||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
||||
variantSuffix = lib.concatStrings [
|
||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
||||
|
||||
stdenv.mkDerivation (rec {
|
||||
version = "9.0.2";
|
||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
||||
sha256 = "140e42b96346322d1a39eb17602bcdc76e292028ad4a69286b230bab188a9197";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
outputs = [ "out" "doc" ];
|
||||
|
||||
patches = [
|
||||
# Add flag that fixes C++ exception handling; opt-in. Merged in 9.4 and 9.2.2.
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/7423
|
||||
(fetchpatch {
|
||||
name = "ghc-9.0.2-fcompact-unwind.patch";
|
||||
# Note that the test suite is not packaged.
|
||||
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/c6132c782d974a7701e7f6447bdcd2bf6db4299a.patch?merge_request_iid=7423";
|
||||
sha256 = "sha256-b4feGZIaKDj/UKjWTNY6/jH4s2iate0wAgMxG3rAbZI=";
|
||||
})
|
||||
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
|
||||
|
||||
# Prevent the paths module from emitting symbols that we don't use
|
||||
# when building with separate outputs.
|
||||
#
|
||||
# These cause problems as they're not eliminated by GHC's dead code
|
||||
# elimination on aarch64-darwin. (see
|
||||
# https://github.com/NixOS/nixpkgs/issues/140774 for details).
|
||||
./cabal-paths.patch
|
||||
];
|
||||
|
||||
postPatch = "patchShebangs .";
|
||||
|
||||
# GHC needs the locale configured during the Haddock phase.
|
||||
LANG = "en_US.UTF-8";
|
||||
|
||||
# GHC is a bit confused on its cross terminology.
|
||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
||||
preConfigure = ''
|
||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
||||
export "''${env#TARGET_}=''${!env}"
|
||||
done
|
||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
||||
# the *host* tools.
|
||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
||||
'' + lib.optionalString useLLVM ''
|
||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
||||
'' + ''
|
||||
|
||||
echo -n "${buildMK}" > mk/build.mk
|
||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
||||
'' + lib.optionalString targetPlatform.isMusl ''
|
||||
echo "patching llvm-targets for musl targets..."
|
||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
||||
echo "(go go gadget sed)"
|
||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
||||
|
||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
||||
for x in configure aclocal.m4; do
|
||||
substituteInPlace $x \
|
||||
--replace '*-android*|*-gnueabi*)' \
|
||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
||||
done
|
||||
'';
|
||||
|
||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
||||
configurePlatforms = [ "build" "host" ]
|
||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
||||
|
||||
# `--with` flags for libraries needed for RTS linker
|
||||
configureFlags = [
|
||||
"--datadir=$doc/share/doc/ghc"
|
||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
||||
] ++ lib.optionals (libffi != null) [
|
||||
"--with-system-libffi"
|
||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
||||
"--with-iconv-includes=${libiconv}/include"
|
||||
"--with-iconv-libraries=${libiconv}/lib"
|
||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
||||
"--enable-bootstrap-with-devel-snapshot"
|
||||
] ++ lib.optionals useLdGold [
|
||||
"CFLAGS=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
||||
"--disable-large-address-space"
|
||||
];
|
||||
|
||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
||||
strictDeps = true;
|
||||
|
||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
||||
dontAddExtraLibs = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
perl autoconf automake m4 python3
|
||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
||||
autoSignDarwinBinariesHook
|
||||
] ++ lib.optionals enableDocs [
|
||||
sphinx
|
||||
] ++ lib.optionals stdenv.isDarwin [
|
||||
# TODO(@sternenseemann): backport addition of XATTR env var like
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/merge_requests/6447
|
||||
xattr
|
||||
];
|
||||
|
||||
# For building runtime libs
|
||||
depsBuildTarget = toolsForTarget;
|
||||
|
||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
||||
|
||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
||||
|
||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
||||
# that in turn causes GHCi to abort
|
||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
||||
|
||||
checkTarget = "test";
|
||||
|
||||
hardeningDisable =
|
||||
[ "format" ]
|
||||
# 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
|
||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
||||
|
||||
# big-parallel allows us to build with more than 2 cores on
|
||||
# Hydra which already warrants a significant speedup
|
||||
requiredSystemFeatures = [ "big-parallel" ];
|
||||
|
||||
postInstall = ''
|
||||
# Install the bash completion file.
|
||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit bootPkgs targetPrefix;
|
||||
|
||||
inherit llvmPackages;
|
||||
inherit enableShared;
|
||||
|
||||
# This is used by the haskell builder to query
|
||||
# the presence of the haddock program.
|
||||
hasHaddock = enableHaddockProgram;
|
||||
|
||||
# Our Cabal compiler name
|
||||
haskellCompilerName = "ghc-${version}";
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "http://haskell.org/ghc";
|
||||
description = "The Glasgow Haskell Compiler";
|
||||
maintainers = with lib.maintainers; [
|
||||
guibou
|
||||
] ++ lib.teams.haskell.members;
|
||||
timeout = 24 * 3600;
|
||||
inherit (ghc.meta) license platforms;
|
||||
};
|
||||
|
||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
noAuditTmpdir = true;
|
||||
})
|
||||
362
pkgs/development/compilers/ghc/9.2.3.nix
Normal file
362
pkgs/development/compilers/ghc/9.2.3.nix
Normal file
|
|
@ -0,0 +1,362 @@
|
|||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
||||
|
||||
# build-tools
|
||||
, bootPkgs
|
||||
, autoconf, automake, coreutils, fetchpatch, fetchurl, perl, python3, m4, sphinx
|
||||
, xattr, autoSignDarwinBinariesHook
|
||||
, bash
|
||||
|
||||
, autoreconfHook # GHC 9.2.3 tarballs don't have autoconf run on them
|
||||
|
||||
, libiconv ? null, ncurses
|
||||
, glibcLocales ? null
|
||||
|
||||
, # GHC can be built with system libffi or a bundled one.
|
||||
libffi ? null
|
||||
|
||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
||||
|| stdenv.targetPlatform.isPower
|
||||
|| stdenv.targetPlatform.isSparc
|
||||
|| (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin))
|
||||
, # LLVM is conceptually a run-time-only depedendency, but for
|
||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
||||
# build-time dependency too.
|
||||
buildTargetLlvmPackages, llvmPackages
|
||||
|
||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
||||
# bignum backend instead of the faster but GPLed gmp backend.
|
||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
|
||||
, gmp
|
||||
|
||||
, # If enabled, use -fPIC when compiling static libs.
|
||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
||||
|
||||
# aarch64 outputs otherwise exceed 2GB limit
|
||||
, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
|
||||
|
||||
, # Whether to build dynamic libs for the standard library (on the target
|
||||
# platform). Static libs are always built.
|
||||
enableShared ? with stdenv.targetPlatform; !isWindows && !useiOSPrebuilt && !isStatic
|
||||
|
||||
, # Whether to build terminfo.
|
||||
enableTerminfo ? !stdenv.targetPlatform.isWindows
|
||||
|
||||
, # What flavour to build. An empty string indicates no
|
||||
# specific flavour and falls back to ghc default values.
|
||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
||||
|
||||
, # Whether to build sphinx documentation.
|
||||
enableDocs ? (
|
||||
# Docs disabled for musl and cross because it's a large task to keep
|
||||
# all `sphinx` dependencies building in those environments.
|
||||
# `sphinx` pulls in among others:
|
||||
# Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
&& !stdenv.hostPlatform.isMusl
|
||||
)
|
||||
|
||||
, enableHaddockProgram ?
|
||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
|
||||
, # Whether to disable the large address space allocator
|
||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
||||
}:
|
||||
|
||||
assert !enableNativeBignum -> gmp != null;
|
||||
|
||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
||||
# see note [HADDOCK_DOCS].
|
||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
||||
|
||||
let
|
||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
||||
|
||||
inherit (bootPkgs) ghc;
|
||||
|
||||
# TODO(@Ericson2314) Make unconditional
|
||||
targetPrefix = lib.optionalString
|
||||
(targetPlatform != hostPlatform)
|
||||
"${targetPlatform.config}-";
|
||||
|
||||
buildMK = ''
|
||||
BuildFlavour = ${ghcFlavour}
|
||||
ifneq \"\$(BuildFlavour)\" \"\"
|
||||
include mk/flavours/\$(BuildFlavour).mk
|
||||
endif
|
||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
||||
BUILD_SPHINX_PDF = NO
|
||||
'' +
|
||||
# Note [HADDOCK_DOCS]:
|
||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
||||
# program is built (which we generally always want to have a complete GHC install)
|
||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
||||
# (which is impossible for cross-compilation); see:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
||||
# program, so it can never generate haddocks for any packages.
|
||||
# If this is solved in the future, we'd like to unconditionally
|
||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
||||
''
|
||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
||||
Stage1Only = ${if targetPlatform.system == hostPlatform.system then "NO" else "YES"}
|
||||
CrossCompilePrefix = ${targetPrefix}
|
||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
||||
GhcLibWays = "v dyn"
|
||||
'' +
|
||||
# -fexternal-dynamic-refs apparently (because it's not clear from the documentation)
|
||||
# makes the GHC RTS able to load static libraries, which may be needed for TemplateHaskell.
|
||||
# This solution was described in https://www.tweag.io/blog/2020-09-30-bazel-static-haskell
|
||||
lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC -fexternal-dynamic-refs
|
||||
GhcRtsHcOpts += -fPIC -fexternal-dynamic-refs
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
EXTRA_CC_OPTS += -std=gnu99
|
||||
'';
|
||||
|
||||
# Splicer will pull out correct variations
|
||||
libDeps = platform: lib.optional enableTerminfo ncurses
|
||||
++ [libffi]
|
||||
++ lib.optional (!enableNativeBignum) gmp
|
||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv;
|
||||
|
||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
||||
toolsForTarget = [
|
||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
||||
|
||||
targetCC = builtins.head toolsForTarget;
|
||||
|
||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
||||
# derivation for certain tools depending on the platform.
|
||||
bintoolsFor = {
|
||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
||||
# x86_64-darwin.
|
||||
install_name_tool =
|
||||
if stdenv.targetPlatform.isAarch64
|
||||
then targetCC.bintools
|
||||
else targetCC.bintools.bintools;
|
||||
# Same goes for strip.
|
||||
strip =
|
||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
||||
then targetCC.bintools
|
||||
else targetCC.bintools.bintools;
|
||||
};
|
||||
|
||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
||||
# see #84670 and #49071 for more background.
|
||||
useLdGold = targetPlatform.linker == "gold" ||
|
||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
||||
|
||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
||||
variantSuffix = lib.concatStrings [
|
||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
||||
|
||||
stdenv.mkDerivation (rec {
|
||||
version = "9.2.3";
|
||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
|
||||
sha256 = "50ecdc2bef013e518f9a62a15245d7db0e4409d737c43b1cea7306fd82e1669e";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
outputs = [ "out" "doc" ];
|
||||
|
||||
postPatch = "patchShebangs .";
|
||||
|
||||
# GHC needs the locale configured during the Haddock phase.
|
||||
LANG = "en_US.UTF-8";
|
||||
|
||||
# GHC is a bit confused on its cross terminology.
|
||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
||||
preConfigure = ''
|
||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
||||
export "''${env#TARGET_}=''${!env}"
|
||||
done
|
||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
||||
# the *host* tools.
|
||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
||||
'' + lib.optionalString useLLVM ''
|
||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
||||
'' + ''
|
||||
|
||||
echo -n "${buildMK}" > mk/build.mk
|
||||
# GHC 9.2.3 tarball is not properly prepared
|
||||
./boot
|
||||
|
||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
||||
'' + lib.optionalString (stdenv.isLinux && hostPlatform.libc == "glibc") ''
|
||||
export LOCALE_ARCHIVE="${glibcLocales}/lib/locale/locale-archive"
|
||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
||||
|
||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
||||
'' + lib.optionalString targetPlatform.isMusl ''
|
||||
echo "patching llvm-targets for musl targets..."
|
||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
||||
echo "(go go gadget sed)"
|
||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
||||
|
||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
||||
for x in configure aclocal.m4; do
|
||||
substituteInPlace $x \
|
||||
--replace '*-android*|*-gnueabi*)' \
|
||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
||||
done
|
||||
'';
|
||||
|
||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
||||
configurePlatforms = [ "build" "host" ]
|
||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
||||
|
||||
# `--with` flags for libraries needed for RTS linker
|
||||
configureFlags = [
|
||||
"--datadir=$doc/share/doc/ghc"
|
||||
"--with-curses-includes=${ncurses.dev}/include" "--with-curses-libraries=${ncurses.out}/lib"
|
||||
] ++ lib.optionals (libffi != null) [
|
||||
"--with-system-libffi"
|
||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
||||
"--with-iconv-includes=${libiconv}/include"
|
||||
"--with-iconv-libraries=${libiconv}/lib"
|
||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
||||
"--enable-bootstrap-with-devel-snapshot"
|
||||
] ++ lib.optionals useLdGold [
|
||||
"CFLAGS=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
||||
] ++ lib.optionals (disableLargeAddressSpace) [
|
||||
"--disable-large-address-space"
|
||||
];
|
||||
|
||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
||||
strictDeps = true;
|
||||
|
||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
||||
dontAddExtraLibs = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
autoreconfHook # GHC 9.2.3 tarball hasn't autoconf run on it
|
||||
perl autoconf automake m4 python3
|
||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
||||
autoSignDarwinBinariesHook
|
||||
] ++ lib.optionals enableDocs [
|
||||
sphinx
|
||||
];
|
||||
|
||||
# For building runtime libs
|
||||
depsBuildTarget = toolsForTarget;
|
||||
|
||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
||||
|
||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
||||
|
||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
||||
# that in turn causes GHCi to abort
|
||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
||||
|
||||
checkTarget = "test";
|
||||
|
||||
hardeningDisable =
|
||||
[ "format" ]
|
||||
# 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
|
||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
||||
|
||||
# big-parallel allows us to build with more than 2 cores on
|
||||
# Hydra which already warrants a significant speedup
|
||||
requiredSystemFeatures = [ "big-parallel" ];
|
||||
|
||||
postInstall = ''
|
||||
# Install the bash completion file.
|
||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit bootPkgs targetPrefix;
|
||||
|
||||
inherit llvmPackages;
|
||||
inherit enableShared;
|
||||
|
||||
# This is used by the haskell builder to query
|
||||
# the presence of the haddock program.
|
||||
hasHaddock = enableHaddockProgram;
|
||||
|
||||
# Our Cabal compiler name
|
||||
haskellCompilerName = "ghc-${version}";
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "http://haskell.org/ghc";
|
||||
description = "The Glasgow Haskell Compiler";
|
||||
maintainers = with lib.maintainers; [
|
||||
guibou
|
||||
] ++ lib.teams.haskell.members;
|
||||
timeout = 24 * 3600;
|
||||
inherit (ghc.meta) license platforms;
|
||||
};
|
||||
|
||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt {
|
||||
dontStrip = true;
|
||||
dontPatchELF = true;
|
||||
noAuditTmpdir = true;
|
||||
})
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs
|
||||
index acd0d61..3e83c15 100644
|
||||
--- a/compiler/main/DriverPipeline.hs
|
||||
+++ b/compiler/main/DriverPipeline.hs
|
||||
@@ -1916,6 +1916,7 @@ linkBinary' staticLink dflags o_files dep_packages = do
|
||||
++ pkg_framework_opts
|
||||
++ debug_opts
|
||||
++ thread_opts
|
||||
+ ++ (if (platformOS platform `elem` [OSDarwin]) then [ "-Wl,-dead_strip_dylibs" ] else [])
|
||||
))
|
||||
|
||||
exeFileName :: Bool -> DynFlags -> FilePath
|
||||
diff --git a/compiler/main/SysTools.hs b/compiler/main/SysTools.hs
|
||||
index 1ab5b13..2ebbf51 100644
|
||||
--- a/compiler/main/SysTools.hs
|
||||
+++ b/compiler/main/SysTools.hs
|
||||
@@ -1737,6 +1737,7 @@ linkDynLib dflags0 o_files dep_packages
|
||||
++ map Option pkg_lib_path_opts
|
||||
++ map Option pkg_link_opts
|
||||
++ map Option pkg_framework_opts
|
||||
+ ++ [ Option "-Wl,-dead_strip_dylibs" ]
|
||||
)
|
||||
OSiOS -> throwGhcExceptionIO (ProgramError "dynamic libraries are not supported on iOS target")
|
||||
_ -> do
|
||||
99
pkgs/development/compilers/ghc/cabal-paths.patch
Normal file
99
pkgs/development/compilers/ghc/cabal-paths.patch
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
diff --git a/Cabal/Distribution/Simple/Build/PathsModule.hs b/Cabal/Distribution/Simple/Build/PathsModule.hs
|
||||
index 5e660e8d6..1ae603c94 100644
|
||||
--- a/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
|
||||
+++ b/libraries/Cabal/Cabal/Distribution/Simple/Build/PathsModule.hs
|
||||
@@ -37,6 +37,9 @@ import System.FilePath ( pathSeparator )
|
||||
-- * Building Paths_<pkg>.hs
|
||||
-- ------------------------------------------------------------
|
||||
|
||||
+splitPath :: FilePath -> [ String ]
|
||||
+splitPath = unintersperse pathSeparator
|
||||
+
|
||||
generatePathsModule :: PackageDescription -> LocalBuildInfo -> ComponentLocalBuildInfo -> String
|
||||
generatePathsModule pkg_descr lbi clbi =
|
||||
let pragmas =
|
||||
@@ -78,12 +81,44 @@ generatePathsModule pkg_descr lbi clbi =
|
||||
"import System.Environment (getExecutablePath)\n"
|
||||
| otherwise = ""
|
||||
|
||||
+ dirs = [ (flat_libdir, "LibDir")
|
||||
+ , (flat_dynlibdir, "DynLibDir")
|
||||
+ , (flat_datadir, "DataDir")
|
||||
+ , (flat_libexecdir, "LibexecDir")
|
||||
+ , (flat_sysconfdir, "SysconfDir") ];
|
||||
+
|
||||
+ shouldEmitPath p
|
||||
+ | (splitPath flat_prefix) `isPrefixOf` (splitPath flat_bindir) = True
|
||||
+ | (splitPath flat_prefix) `isPrefixOf` (splitPath p) = False
|
||||
+ | otherwise = True
|
||||
+
|
||||
+ shouldEmitDataDir = shouldEmitPath flat_datadir
|
||||
+
|
||||
+ nixEmitPathFn (path, name) = let
|
||||
+ varName = toLower <$> name
|
||||
+ fnName = "get"++name
|
||||
+ in if shouldEmitPath path then
|
||||
+ varName ++ " :: FilePath\n"++
|
||||
+ varName ++ " = " ++ show path ++
|
||||
+ "\n" ++ fnName ++ " :: IO FilePath" ++
|
||||
+ "\n" ++ fnName ++ " = " ++ mkGetEnvOr varName ("return " ++ varName)++"\n"
|
||||
+ else ""
|
||||
+
|
||||
+ absBody = intercalate "\n" $ nixEmitPathFn <$> dirs
|
||||
+
|
||||
+ warnPragma = case filter (not . shouldEmitPath . fst) dirs of
|
||||
+ [] -> ""
|
||||
+ omittedDirs -> "{-# WARNING \"The functions: "++omittedFns++" Have been omitted by the Nix build system.\" #-}"
|
||||
+ where omittedFns = intercalate ", " $ map snd omittedDirs
|
||||
+
|
||||
+ importList = intercalate ", " $ ("get" ++) . snd <$> filter (shouldEmitPath . fst) dirs
|
||||
+
|
||||
header =
|
||||
pragmas++
|
||||
- "module " ++ prettyShow paths_modulename ++ " (\n"++
|
||||
- " version,\n"++
|
||||
- " getBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir,\n"++
|
||||
- " getDataFileName, getSysconfDir\n"++
|
||||
+ "module " ++ prettyShow paths_modulename ++ " " ++ warnPragma ++ " (\n"++
|
||||
+ " version, getBinDir,\n"++
|
||||
+ (if shouldEmitDataDir then " getDataFileName, \n" else "\n")++
|
||||
+ " " ++ importList ++"\n"++
|
||||
" ) where\n"++
|
||||
"\n"++
|
||||
foreign_imports++
|
||||
@@ -136,26 +171,18 @@ generatePathsModule pkg_descr lbi clbi =
|
||||
"\n"++
|
||||
filename_stuff
|
||||
| absolute =
|
||||
- "\nbindir, libdir, dynlibdir, datadir, libexecdir, sysconfdir :: FilePath\n"++
|
||||
+ "\nbindir :: FilePath\n"++
|
||||
"\nbindir = " ++ show flat_bindir ++
|
||||
- "\nlibdir = " ++ show flat_libdir ++
|
||||
- "\ndynlibdir = " ++ show flat_dynlibdir ++
|
||||
- "\ndatadir = " ++ show flat_datadir ++
|
||||
- "\nlibexecdir = " ++ show flat_libexecdir ++
|
||||
- "\nsysconfdir = " ++ show flat_sysconfdir ++
|
||||
"\n"++
|
||||
- "\ngetBinDir, getLibDir, getDynLibDir, getDataDir, getLibexecDir, getSysconfDir :: IO FilePath\n"++
|
||||
+ "\ngetBinDir :: IO FilePath\n"++
|
||||
"getBinDir = "++mkGetEnvOr "bindir" "return bindir"++"\n"++
|
||||
- "getLibDir = "++mkGetEnvOr "libdir" "return libdir"++"\n"++
|
||||
- "getDynLibDir = "++mkGetEnvOr "dynlibdir" "return dynlibdir"++"\n"++
|
||||
- "getDataDir = "++mkGetEnvOr "datadir" "return datadir"++"\n"++
|
||||
- "getLibexecDir = "++mkGetEnvOr "libexecdir" "return libexecdir"++"\n"++
|
||||
- "getSysconfDir = "++mkGetEnvOr "sysconfdir" "return sysconfdir"++"\n"++
|
||||
- "\n"++
|
||||
- "getDataFileName :: FilePath -> IO FilePath\n"++
|
||||
- "getDataFileName name = do\n"++
|
||||
- " dir <- getDataDir\n"++
|
||||
- " return (dir ++ "++path_sep++" ++ name)\n"
|
||||
+ absBody ++ "\n"++
|
||||
+ (if shouldEmitDataDir then
|
||||
+ "getDataFileName :: FilePath -> IO FilePath\n"++
|
||||
+ "getDataFileName name = do\n"++
|
||||
+ " dir <- getDataDir\n"++
|
||||
+ " return (dir ++ "++path_sep++" ++ name)\n"
|
||||
+ else "\n")
|
||||
| otherwise =
|
||||
"\nprefix, bindirrel :: FilePath" ++
|
||||
"\nprefix = " ++ show flat_prefix ++
|
||||
46
pkgs/development/compilers/ghc/gcc-clang-wrapper.sh
Executable file
46
pkgs/development/compilers/ghc/gcc-clang-wrapper.sh
Executable file
|
|
@ -0,0 +1,46 @@
|
|||
#!@shell@
|
||||
|
||||
inPreprocessorMode () {
|
||||
hasE=0
|
||||
hasU=0
|
||||
hasT=0
|
||||
for arg in "$@"
|
||||
do
|
||||
if [ 'x-E' = "x$arg" ]; then hasE=1; fi
|
||||
if [ 'x-undef' = "x$arg" ]; then hasU=1; fi
|
||||
if [ 'x-traditional' = "x$arg" ]; then hasT=1; fi
|
||||
done
|
||||
[ "$hasE$hasU$hasT" = '111' ]
|
||||
}
|
||||
|
||||
extraClangArgs="-Wno-invalid-pp-token -Wno-unicode -Wno-trigraphs"
|
||||
|
||||
adjustPreprocessorLanguage () {
|
||||
newArgs=''
|
||||
while [ $# -gt 0 ]
|
||||
do
|
||||
newArgs="$newArgs $1"
|
||||
if [ "$1" = '-x' ]
|
||||
then
|
||||
shift
|
||||
if [ $# -gt 0 ]
|
||||
then
|
||||
if [ "$1" = 'c' ]
|
||||
then
|
||||
newArgs="$newArgs assembler-with-cpp"
|
||||
else
|
||||
newArgs="$newArgs $1"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
shift
|
||||
done
|
||||
echo $newArgs
|
||||
}
|
||||
|
||||
if inPreprocessorMode "$@"
|
||||
then
|
||||
exec clang $extraClangArgs `adjustPreprocessorLanguage "$@"`
|
||||
else
|
||||
exec clang $extraClangArgs "${@/-nodefaultlibs/}"
|
||||
fi
|
||||
375
pkgs/development/compilers/ghc/head.nix
Normal file
375
pkgs/development/compilers/ghc/head.nix
Normal file
|
|
@ -0,0 +1,375 @@
|
|||
{ lib, stdenv, pkgsBuildTarget, pkgsHostTarget, targetPackages
|
||||
|
||||
# build-tools
|
||||
, bootPkgs
|
||||
, autoconf, autoreconfHook, automake, coreutils, fetchgit, perl, python3, m4, sphinx
|
||||
, xattr, autoSignDarwinBinariesHook
|
||||
, bash
|
||||
|
||||
, libiconv ? null, ncurses
|
||||
|
||||
, # GHC can be built with system libffi or a bundled one.
|
||||
libffi ? null
|
||||
|
||||
# Libdw.c only supports x86_64, i686 and s390x
|
||||
, enableDwarf ? (stdenv.targetPlatform.isx86 ||
|
||||
(stdenv.targetPlatform.isS390 && stdenv.targetPlatform.is64bit)) &&
|
||||
lib.meta.availableOn stdenv.hostPlatform elfutils &&
|
||||
lib.meta.availableOn stdenv.targetPlatform elfutils
|
||||
, elfutils # for DWARF support
|
||||
|
||||
, useLLVM ? !(stdenv.targetPlatform.isx86
|
||||
|| stdenv.targetPlatform.isPower
|
||||
|| stdenv.targetPlatform.isSparc
|
||||
|| (stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin))
|
||||
, # LLVM is conceptually a run-time-only depedendency, but for
|
||||
# non-x86, we need LLVM to bootstrap later stages, so it becomes a
|
||||
# build-time dependency too.
|
||||
buildTargetLlvmPackages, llvmPackages
|
||||
|
||||
, # If enabled, GHC will be built with the GPL-free but slightly slower native
|
||||
# bignum backend instead of the faster but GPLed gmp backend.
|
||||
enableNativeBignum ? !(lib.meta.availableOn stdenv.hostPlatform gmp)
|
||||
, gmp
|
||||
|
||||
, # If enabled, use -fPIC when compiling static libs.
|
||||
enableRelocatedStaticLibs ? stdenv.targetPlatform != stdenv.hostPlatform
|
||||
|
||||
# aarch64 outputs otherwise exceed 2GB limit
|
||||
, enableProfiledLibs ? !stdenv.targetPlatform.isAarch64
|
||||
|
||||
, # Whether to build dynamic libs for the standard library (on the target
|
||||
# platform). Static libs are always built.
|
||||
enableShared ? !stdenv.targetPlatform.isWindows && !stdenv.targetPlatform.useiOSPrebuilt
|
||||
|
||||
, version ? "9.3.20220406"
|
||||
, # What flavour to build. An empty string indicates no
|
||||
# specific flavour and falls back to ghc default values.
|
||||
ghcFlavour ? lib.optionalString (stdenv.targetPlatform != stdenv.hostPlatform)
|
||||
(if useLLVM then "perf-cross" else "perf-cross-ncg")
|
||||
|
||||
, # Whether to build sphinx documentation.
|
||||
enableDocs ? (
|
||||
# Docs disabled for musl and cross because it's a large task to keep
|
||||
# all `sphinx` dependencies building in those environments.
|
||||
# `sphinx` pullls in among others:
|
||||
# Ruby, Python, Perl, Rust, OpenGL, Xorg, gtk, LLVM.
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
&& !stdenv.hostPlatform.isMusl
|
||||
)
|
||||
|
||||
, enableHaddockProgram ?
|
||||
# Disabled for cross; see note [HADDOCK_DOCS].
|
||||
(stdenv.targetPlatform == stdenv.hostPlatform)
|
||||
|
||||
, # Whether to disable the large address space allocator
|
||||
# necessary fix for iOS: https://www.reddit.com/r/haskell/comments/4ttdz1/building_an_osxi386_to_iosarm64_cross_compiler/d5qvd67/
|
||||
disableLargeAddressSpace ? stdenv.targetPlatform.isiOS
|
||||
}:
|
||||
|
||||
assert !enableNativeBignum -> gmp != null;
|
||||
|
||||
# Cross cannot currently build the `haddock` program for silly reasons,
|
||||
# see note [HADDOCK_DOCS].
|
||||
assert (stdenv.targetPlatform != stdenv.hostPlatform) -> !enableHaddockProgram;
|
||||
|
||||
let
|
||||
inherit (stdenv) buildPlatform hostPlatform targetPlatform;
|
||||
|
||||
inherit (bootPkgs) ghc;
|
||||
|
||||
# TODO(@Ericson2314) Make unconditional
|
||||
targetPrefix = lib.optionalString
|
||||
(targetPlatform != hostPlatform)
|
||||
"${targetPlatform.config}-";
|
||||
|
||||
buildMK = dontStrip: ''
|
||||
BuildFlavour = ${ghcFlavour}
|
||||
ifneq \"\$(BuildFlavour)\" \"\"
|
||||
include mk/flavours/\$(BuildFlavour).mk
|
||||
endif
|
||||
BUILD_SPHINX_HTML = ${if enableDocs then "YES" else "NO"}
|
||||
BUILD_SPHINX_PDF = NO
|
||||
'' +
|
||||
# Note [HADDOCK_DOCS]:
|
||||
# Unfortunately currently `HADDOCK_DOCS` controls both whether the `haddock`
|
||||
# program is built (which we generally always want to have a complete GHC install)
|
||||
# and whether it is run on the GHC sources to generate hyperlinked source code
|
||||
# (which is impossible for cross-compilation); see:
|
||||
# https://gitlab.haskell.org/ghc/ghc/-/issues/20077
|
||||
# This implies that currently a cross-compiled GHC will never have a `haddock`
|
||||
# program, so it can never generate haddocks for any packages.
|
||||
# If this is solved in the future, we'd like to unconditionally
|
||||
# build the haddock program (removing the `enableHaddockProgram` option).
|
||||
''
|
||||
HADDOCK_DOCS = ${if enableHaddockProgram then "YES" else "NO"}
|
||||
DYNAMIC_GHC_PROGRAMS = ${if enableShared then "YES" else "NO"}
|
||||
BIGNUM_BACKEND = ${if enableNativeBignum then "native" else "gmp"}
|
||||
'' + lib.optionalString (targetPlatform != hostPlatform) ''
|
||||
Stage1Only = ${if (targetPlatform.system == hostPlatform.system && !targetPlatform.isiOS) then "NO" else "YES"}
|
||||
CrossCompilePrefix = ${targetPrefix}
|
||||
'' + lib.optionalString dontStrip ''
|
||||
STRIP_CMD = :
|
||||
'' + lib.optionalString (!enableProfiledLibs) ''
|
||||
GhcLibWays = "v dyn"
|
||||
'' + lib.optionalString enableRelocatedStaticLibs ''
|
||||
GhcLibHcOpts += -fPIC
|
||||
GhcRtsHcOpts += -fPIC
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
EXTRA_CC_OPTS += -std=gnu99
|
||||
''
|
||||
# While split sections are now enabled by default in ghc 8.8 for windows,
|
||||
# they seem to lead to `too many sections` errors when building base for
|
||||
# profiling.
|
||||
+ lib.optionalString targetPlatform.isWindows ''
|
||||
SplitSections = NO
|
||||
'';
|
||||
|
||||
# Splicer will pull out correct variations
|
||||
libDeps = platform:
|
||||
[libffi ncurses]
|
||||
++ lib.optional (!enableNativeBignum) gmp
|
||||
++ lib.optional (platform.libc != "glibc" && !targetPlatform.isWindows) libiconv
|
||||
++ lib.optional enableDwarf elfutils;
|
||||
|
||||
# TODO(@sternenseemann): is buildTarget LLVM unnecessary?
|
||||
# GHC doesn't seem to have {LLC,OPT}_HOST
|
||||
toolsForTarget = [
|
||||
pkgsBuildTarget.targetPackages.stdenv.cc
|
||||
] ++ lib.optional useLLVM buildTargetLlvmPackages.llvm;
|
||||
|
||||
targetCC = builtins.head toolsForTarget;
|
||||
|
||||
# Sometimes we have to dispatch between the bintools wrapper and the unwrapped
|
||||
# derivation for certain tools depending on the platform.
|
||||
bintoolsFor = {
|
||||
# GHC needs install_name_tool on all darwin platforms. On aarch64-darwin it is
|
||||
# part of the bintools wrapper (due to codesigning requirements), but not on
|
||||
# x86_64-darwin.
|
||||
install_name_tool =
|
||||
if stdenv.targetPlatform.isAarch64
|
||||
then targetCC.bintools
|
||||
else targetCC.bintools.bintools;
|
||||
# Same goes for strip.
|
||||
strip =
|
||||
# TODO(@sternenseemann): also use wrapper if linker == "bfd" or "gold"
|
||||
if stdenv.targetPlatform.isAarch64 && stdenv.targetPlatform.isDarwin
|
||||
then targetCC.bintools
|
||||
else targetCC.bintools.bintools;
|
||||
};
|
||||
|
||||
# Use gold either following the default, or to avoid the BFD linker due to some bugs / perf issues.
|
||||
# But we cannot avoid BFD when using musl libc due to https://sourceware.org/bugzilla/show_bug.cgi?id=23856
|
||||
# see #84670 and #49071 for more background.
|
||||
useLdGold = targetPlatform.linker == "gold" ||
|
||||
(targetPlatform.linker == "bfd" && (targetCC.bintools.bintools.hasGold or false) && !targetPlatform.isMusl);
|
||||
|
||||
# Makes debugging easier to see which variant is at play in `nix-store -q --tree`.
|
||||
variantSuffix = lib.concatStrings [
|
||||
(lib.optionalString stdenv.hostPlatform.isMusl "-musl")
|
||||
(lib.optionalString enableNativeBignum "-native-bignum")
|
||||
];
|
||||
|
||||
in
|
||||
|
||||
# C compiler, bintools and LLVM are used at build time, but will also leak into
|
||||
# the resulting GHC's settings file and used at runtime. This means that we are
|
||||
# currently only able to build GHC if hostPlatform == buildPlatform.
|
||||
assert targetCC == pkgsHostTarget.targetPackages.stdenv.cc;
|
||||
assert buildTargetLlvmPackages.llvm == llvmPackages.llvm;
|
||||
assert stdenv.targetPlatform.isDarwin -> buildTargetLlvmPackages.clang == llvmPackages.clang;
|
||||
|
||||
stdenv.mkDerivation (rec {
|
||||
inherit version;
|
||||
inherit (src) rev;
|
||||
pname = "${targetPrefix}ghc${variantSuffix}";
|
||||
|
||||
src = fetchgit {
|
||||
url = "https://gitlab.haskell.org/ghc/ghc.git/";
|
||||
rev = "c44432db254d2fc960d7864e080cb50e65dfa7c6";
|
||||
sha256 = "0xagijcfcw3a19s6dmh6z7085lvkrakys3lcby4ncq1v0syh507h";
|
||||
};
|
||||
|
||||
enableParallelBuilding = true;
|
||||
|
||||
outputs = [ "out" "doc" ];
|
||||
|
||||
postPatch = "patchShebangs .";
|
||||
|
||||
# GHC is a bit confused on its cross terminology.
|
||||
# TODO(@sternenseemann): investigate coreutils dependencies and pass absolute paths
|
||||
preConfigure = ''
|
||||
for env in $(env | grep '^TARGET_' | sed -E 's|\+?=.*||'); do
|
||||
export "''${env#TARGET_}=''${!env}"
|
||||
done
|
||||
# GHC is a bit confused on its cross terminology, as these would normally be
|
||||
# the *host* tools.
|
||||
export CC="${targetCC}/bin/${targetCC.targetPrefix}cc"
|
||||
export CXX="${targetCC}/bin/${targetCC.targetPrefix}c++"
|
||||
# Use gold to work around https://sourceware.org/bugzilla/show_bug.cgi?id=16177
|
||||
# and more generally have a faster linker.
|
||||
export LD="${targetCC.bintools}/bin/${targetCC.bintools.targetPrefix}ld${lib.optionalString useLdGold ".gold"}"
|
||||
export AS="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}as"
|
||||
export AR="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ar"
|
||||
export NM="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}nm"
|
||||
export RANLIB="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}ranlib"
|
||||
export READELF="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}readelf"
|
||||
export STRIP="${bintoolsFor.strip}/bin/${bintoolsFor.strip.targetPrefix}strip"
|
||||
'' + lib.optionalString (stdenv.targetPlatform.linker == "cctools") ''
|
||||
export OTOOL="${targetCC.bintools.bintools}/bin/${targetCC.bintools.targetPrefix}otool"
|
||||
export INSTALL_NAME_TOOL="${bintoolsFor.install_name_tool}/bin/${bintoolsFor.install_name_tool.targetPrefix}install_name_tool"
|
||||
'' + lib.optionalString useLLVM ''
|
||||
export LLC="${lib.getBin buildTargetLlvmPackages.llvm}/bin/llc"
|
||||
export OPT="${lib.getBin buildTargetLlvmPackages.llvm}/bin/opt"
|
||||
'' + lib.optionalString (useLLVM && stdenv.targetPlatform.isDarwin) ''
|
||||
# LLVM backend on Darwin needs clang: https://downloads.haskell.org/~ghc/latest/docs/html/users_guide/codegens.html#llvm-code-generator-fllvm
|
||||
export CLANG="${buildTargetLlvmPackages.clang}/bin/${buildTargetLlvmPackages.clang.targetPrefix}clang"
|
||||
'' + ''
|
||||
|
||||
# otherwise haddock fails when generating the compiler docs
|
||||
export LANG=C.UTF-8
|
||||
|
||||
echo -n "${buildMK dontStrip}" > mk/build.mk
|
||||
echo ${version} > VERSION
|
||||
echo ${src.rev} > GIT_COMMIT_ID
|
||||
./boot
|
||||
sed -i -e 's|-isysroot /Developer/SDKs/MacOSX10.5.sdk||' configure
|
||||
'' + lib.optionalString (!stdenv.isDarwin) ''
|
||||
export NIX_LDFLAGS+=" -rpath $out/lib/ghc-${version}"
|
||||
'' + lib.optionalString stdenv.isDarwin ''
|
||||
export NIX_LDFLAGS+=" -no_dtrace_dof"
|
||||
|
||||
# GHC tries the host xattr /usr/bin/xattr by default which fails since it expects python to be 2.7
|
||||
export XATTR=${lib.getBin xattr}/bin/xattr
|
||||
'' + lib.optionalString targetPlatform.useAndroidPrebuilt ''
|
||||
sed -i -e '5i ,("armv7a-unknown-linux-androideabi", ("e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64", "cortex-a8", ""))' llvm-targets
|
||||
'' + lib.optionalString targetPlatform.isMusl ''
|
||||
echo "patching llvm-targets for musl targets..."
|
||||
echo "Cloning these existing '*-linux-gnu*' targets:"
|
||||
grep linux-gnu llvm-targets | sed 's/^/ /'
|
||||
echo "(go go gadget sed)"
|
||||
sed -i 's,\(^.*linux-\)gnu\(.*\)$,\0\n\1musl\2,' llvm-targets
|
||||
echo "llvm-targets now contains these '*-linux-musl*' targets:"
|
||||
grep linux-musl llvm-targets | sed 's/^/ /'
|
||||
|
||||
echo "And now patching to preserve '-musleabi' as done with '-gnueabi'"
|
||||
# (aclocal.m4 is actual source, but patch configure as well since we don't re-gen)
|
||||
for x in configure aclocal.m4; do
|
||||
substituteInPlace $x \
|
||||
--replace '*-android*|*-gnueabi*)' \
|
||||
'*-android*|*-gnueabi*|*-musleabi*)'
|
||||
done
|
||||
'';
|
||||
|
||||
# TODO(@Ericson2314): Always pass "--target" and always prefix.
|
||||
configurePlatforms = [ "build" "host" ]
|
||||
++ lib.optional (targetPlatform != hostPlatform) "target";
|
||||
|
||||
# `--with` flags for libraries needed for RTS linker
|
||||
configureFlags = [
|
||||
"--datadir=$doc/share/doc/ghc"
|
||||
"--with-curses-libraries=${ncurses.out}/lib"
|
||||
] ++ lib.optionals (libffi != null) [
|
||||
"--with-system-libffi"
|
||||
"--with-ffi-includes=${targetPackages.libffi.dev}/include"
|
||||
"--with-ffi-libraries=${targetPackages.libffi.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && !enableNativeBignum) [
|
||||
"--with-gmp-includes=${targetPackages.gmp.dev}/include"
|
||||
"--with-gmp-libraries=${targetPackages.gmp.out}/lib"
|
||||
] ++ lib.optionals (targetPlatform == hostPlatform && hostPlatform.libc != "glibc" && !targetPlatform.isWindows) [
|
||||
"--with-iconv-includes=${libiconv}/include"
|
||||
"--with-iconv-libraries=${libiconv}/lib"
|
||||
] ++ lib.optionals (targetPlatform != hostPlatform) [
|
||||
"--enable-bootstrap-with-devel-snapshot"
|
||||
] ++ lib.optionals useLdGold [
|
||||
"CFLAGS=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE1=-fuse-ld=gold"
|
||||
"CONF_GCC_LINKER_OPTS_STAGE2=-fuse-ld=gold"
|
||||
] ++ lib.optional disableLargeAddressSpace "--disable-large-address-space"
|
||||
++ lib.optionals enableDwarf [
|
||||
"--enable-dwarf-unwind"
|
||||
"--with-libdw-includes=${lib.getDev elfutils}/include"
|
||||
"--with-libdw-libraries=${lib.getLib elfutils}/lib"
|
||||
];
|
||||
|
||||
# Make sure we never relax`$PATH` and hooks support for compatibility.
|
||||
strictDeps = true;
|
||||
|
||||
# Don’t add -liconv to LDFLAGS automatically so that GHC will add it itself.
|
||||
dontAddExtraLibs = true;
|
||||
|
||||
nativeBuildInputs = [
|
||||
perl autoconf autoreconfHook automake m4 python3
|
||||
ghc bootPkgs.alex bootPkgs.happy bootPkgs.hscolour
|
||||
] ++ lib.optionals (stdenv.isDarwin && stdenv.isAarch64) [
|
||||
autoSignDarwinBinariesHook
|
||||
] ++ lib.optionals enableDocs [
|
||||
sphinx
|
||||
];
|
||||
|
||||
# For building runtime libs
|
||||
depsBuildTarget = toolsForTarget;
|
||||
|
||||
buildInputs = [ perl bash ] ++ (libDeps hostPlatform);
|
||||
|
||||
depsTargetTarget = map lib.getDev (libDeps targetPlatform);
|
||||
depsTargetTargetPropagated = map (lib.getOutput "out") (libDeps targetPlatform);
|
||||
|
||||
# required, because otherwise all symbols from HSffi.o are stripped, and
|
||||
# that in turn causes GHCi to abort
|
||||
stripDebugFlags = [ "-S" ] ++ lib.optional (!targetPlatform.isDarwin) "--keep-file-symbols";
|
||||
|
||||
checkTarget = "test";
|
||||
|
||||
hardeningDisable =
|
||||
[ "format" ]
|
||||
# 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
|
||||
++ lib.optional stdenv.targetPlatform.isMusl "pie";
|
||||
|
||||
# big-parallel allows us to build with more than 2 cores on
|
||||
# Hydra which already warrants a significant speedup
|
||||
requiredSystemFeatures = [ "big-parallel" ];
|
||||
|
||||
postInstall = ''
|
||||
# Install the bash completion file.
|
||||
install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit bootPkgs targetPrefix;
|
||||
|
||||
inherit llvmPackages;
|
||||
inherit enableShared;
|
||||
|
||||
# This is used by the haskell builder to query
|
||||
# the presence of the haddock program.
|
||||
hasHaddock = enableHaddockProgram;
|
||||
|
||||
# Our Cabal compiler name
|
||||
haskellCompilerName = "ghc-${version}";
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "http://haskell.org/ghc";
|
||||
description = "The Glasgow Haskell Compiler";
|
||||
maintainers = with lib.maintainers; [
|
||||
guibou
|
||||
] ++ lib.teams.haskell.members;
|
||||
timeout = 24 * 3600;
|
||||
inherit (ghc.meta) license platforms;
|
||||
# ghcHEAD times out on aarch64-linux on Hydra.
|
||||
hydraPlatforms = builtins.filter (p: p != "aarch64-linux") ghc.meta.platforms;
|
||||
};
|
||||
|
||||
dontStrip = (targetPlatform.useAndroidPrebuilt || targetPlatform.isWasm);
|
||||
|
||||
} // lib.optionalAttrs targetPlatform.useAndroidPrebuilt{
|
||||
dontPatchELF = true;
|
||||
noAuditTmpdir = true;
|
||||
})
|
||||
296
pkgs/development/compilers/ghc/issue-18549.patch
Normal file
296
pkgs/development/compilers/ghc/issue-18549.patch
Normal file
|
|
@ -0,0 +1,296 @@
|
|||
From fac083e7ac8a37b61a4082bbbca2848e52fd1bb2 Mon Sep 17 00:00:00 2001
|
||||
From: Ben Gamari <ben@smart-cactus.org>
|
||||
Date: Sun, 9 Aug 2020 09:15:16 -0400
|
||||
Subject: [PATCH] Revert "[linker/rtsSymbols] More linker symbols"
|
||||
|
||||
This reverts commit aa2e5863699306920513b216f337de09e29b5bb8.
|
||||
---
|
||||
rts/RtsSymbols.c | 224 ++++-------------------------------------------
|
||||
1 file changed, 17 insertions(+), 207 deletions(-)
|
||||
|
||||
diff --git a/rts/RtsSymbols.c b/rts/RtsSymbols.c
|
||||
index d10a6900db..b2f90a892d 100644
|
||||
--- a/rts/RtsSymbols.c
|
||||
+++ b/rts/RtsSymbols.c
|
||||
@@ -58,6 +58,7 @@
|
||||
SymI_HasProto(signal_handlers) \
|
||||
SymI_HasProto(stg_sig_install) \
|
||||
SymI_HasProto(rtsTimerSignal) \
|
||||
+ SymI_HasProto(atexit) \
|
||||
SymI_NeedsDataProto(nocldstop)
|
||||
#endif
|
||||
|
||||
@@ -976,213 +977,29 @@
|
||||
RTS_USER_SIGNALS_SYMBOLS \
|
||||
RTS_INTCHAR_SYMBOLS
|
||||
|
||||
+
|
||||
// 64-bit support functions in libgcc.a
|
||||
-// See https://gcc.gnu.org/onlinedocs/gccint/Libgcc.html#Libgcc
|
||||
-#define RTS_LIBGCC_SYMBOLS_32 \
|
||||
- SymI_NeedsProto(__fixunsdfdi) \
|
||||
- /* 4 The GCC low-level runtime library */\
|
||||
- /* 4.1.1 Arithmetic functions */\
|
||||
- /* SymI_NeedsProto(__ashlsi3) */\
|
||||
- SymI_NeedsProto(__ashldi3) \
|
||||
- /* SymI_NeedsProto(__ashlti3) */\
|
||||
- /* These functions return the result of shifting a left by b bits. */\
|
||||
- /* SymI_NeedsProto(__ashrsi3) */\
|
||||
- SymI_NeedsProto(__ashrdi3) \
|
||||
- /* SymI_NeedsProto(__ashrti3) */\
|
||||
- /* These functions return the result of arithmetically shifting a right by b bits. */\
|
||||
- /* SymI_NeedsProto(__divsi3) */\
|
||||
- SymI_NeedsProto(__divdi3) \
|
||||
- /* SymI_NeedsProto(__divti3) */\
|
||||
- /* These functions return the quotient of the signed division of a and b. */\
|
||||
- /* SymI_NeedsProto(__lshrsi3) */ \
|
||||
- SymI_NeedsProto(__lshrdi3) \
|
||||
- /* SymI_NeedsProto(__lshrti3) */ \
|
||||
- /* These functions return the result of logically shifting a right by b bits. */\
|
||||
- /* SymI_NeedsProto(__modsi3) */ \
|
||||
- SymI_NeedsProto(__moddi3) \
|
||||
- /* SymI_NeedsProto(__modti3) */ \
|
||||
- /* These functions return the remainder of the signed division of a and b. */\
|
||||
- /* SymI_NeedsProto(__mulsi3) */ \
|
||||
- SymI_NeedsProto(__muldi3) \
|
||||
- /* SymI_NeedsProto(__multi3) */ \
|
||||
- /* These functions return the product of a and b. */\
|
||||
- SymI_NeedsProto(__negdi2) \
|
||||
- /* SymI_NeedsProto(__negti2) */ \
|
||||
- /* These functions return the negation of a. */\
|
||||
- /* SymI_NeedsProto(__udivsi3) */ \
|
||||
- SymI_NeedsProto(__udivdi3) \
|
||||
- /* SymI_NeedsProto(__udivti3) */ \
|
||||
- /* These functions return the quotient of the unsigned division of a and b. */\
|
||||
- SymI_NeedsProto(__udivmoddi4) \
|
||||
- /* SymI_NeedsProto(__udivmodti4) */ \
|
||||
- /* These functions calculate both the quotient and remainder of the unsigned division of a and b. The return value is the quotient, and the remainder is placed in variable pointed to by c. */\
|
||||
- /* SymI_NeedsProto(__umodsi3) */ \
|
||||
- SymI_NeedsProto(__umoddi3) \
|
||||
- /* SymI_NeedsProto(__umodti3) */ \
|
||||
- /* These functions return the remainder of the unsigned division of a and b. */\
|
||||
- /* 4.1.2 Comparison functions */\
|
||||
- /* The following functions implement integral comparisons. These functions implement a low-level compare, upon which the higher level comparison operators (such as less than and greater than or equal to) can be constructed. The returned values lie in the range zero to two, to allow the high-level operators to be implemented by testing the returned result using either signed or unsigned comparison. */\
|
||||
- SymI_NeedsProto(__cmpdi2) \
|
||||
- /* SymI_NeedsProto(__cmpti2) */ \
|
||||
- /* These functions perform a signed comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\
|
||||
- SymI_NeedsProto(__ucmpdi2) \
|
||||
- /* SymI_NeedsProto(__ucmpti2) */ \
|
||||
- /* These functions perform an unsigned comparison of a and b. If a is less than b, they return 0; if a is greater than b, they return 2; and if a and b are equal they return 1. */\
|
||||
- /* 4.1.3 Trapping arithmetic functions */\
|
||||
- /* The following functions implement trapping arithmetic. These functions call the libc function abort upon signed arithmetic overflow. */\
|
||||
- SymI_NeedsProto(__absvsi2) \
|
||||
- SymI_NeedsProto(__absvdi2) \
|
||||
- /* These functions return the absolute value of a. */\
|
||||
- /* SymI_NeedsProto(__addvsi3) */ \
|
||||
- SymI_NeedsProto(__addvdi3) \
|
||||
- /* These functions return the sum of a and b; that is a + b. */\
|
||||
- /* SymI_NeedsProto(__mulvsi3) */ \
|
||||
- SymI_NeedsProto(__mulvdi3) \
|
||||
- /* The functions return the product of a and b; that is a * b. */\
|
||||
- SymI_NeedsProto(__negvsi2) \
|
||||
- SymI_NeedsProto(__negvdi2) \
|
||||
- /* These functions return the negation of a; that is -a. */\
|
||||
- /* SymI_NeedsProto(__subvsi3) */ \
|
||||
- SymI_NeedsProto(__subvdi3) \
|
||||
- /* These functions return the difference between b and a; that is a - b. */\
|
||||
- /* 4.1.4 Bit operations */\
|
||||
- SymI_NeedsProto(__clzsi2) \
|
||||
- SymI_NeedsProto(__clzdi2) \
|
||||
- /* SymI_NeedsProto(__clzti2) */ \
|
||||
- /* These functions return the number of leading 0-bits in a, starting at the most significant bit position. If a is zero, the result is undefined. */\
|
||||
- SymI_NeedsProto(__ctzsi2) \
|
||||
- SymI_NeedsProto(__ctzdi2) \
|
||||
- /* SymI_NeedsProto(__ctzti2) */ \
|
||||
- /* These functions return the number of trailing 0-bits in a, starting at the least significant bit position. If a is zero, the result is undefined. */\
|
||||
- SymI_NeedsProto(__ffsdi2) \
|
||||
- /* SymI_NeedsProto(__ffsti2) */ \
|
||||
- /* These functions return the index of the least significant 1-bit in a, or the value zero if a is zero. The least significant bit is index one. */\
|
||||
- SymI_NeedsProto(__paritysi2) \
|
||||
- SymI_NeedsProto(__paritydi2) \
|
||||
- /* SymI_NeedsProto(__parityti2) */\
|
||||
- /* These functions return the value zero if the number of bits set in a is even, and the value one otherwise. */\
|
||||
- SymI_NeedsProto(__popcountsi2) \
|
||||
- SymI_NeedsProto(__popcountdi2) \
|
||||
- /* SymI_NeedsProto(__popcountti2) */ \
|
||||
- /* These functions return the number of bits set in a. */\
|
||||
- SymI_NeedsProto(__bswapsi2) \
|
||||
- SymI_NeedsProto(__bswapdi2)
|
||||
-#define RTS_LIBGCC_SYMBOLS_aarch32 \
|
||||
- /* armv6l */\
|
||||
- /* TODO: should check for __ARM_EABI__ */\
|
||||
- SymI_NeedsProto(__aeabi_d2f) \
|
||||
- SymI_NeedsProto(__aeabi_d2iz) \
|
||||
- SymI_NeedsProto(__aeabi_d2lz) \
|
||||
- SymI_NeedsProto(__aeabi_d2uiz) \
|
||||
- SymI_NeedsProto(__aeabi_d2ulz) \
|
||||
- SymI_NeedsProto(__aeabi_dadd) \
|
||||
- SymI_NeedsProto(__aeabi_dcmpeq) \
|
||||
- SymI_NeedsProto(__aeabi_dcmpge) \
|
||||
- SymI_NeedsProto(__aeabi_dcmpgt) \
|
||||
- SymI_NeedsProto(__aeabi_dcmple) \
|
||||
- SymI_NeedsProto(__aeabi_dcmplt) \
|
||||
- SymI_NeedsProto(__aeabi_dcmpun) \
|
||||
- SymI_NeedsProto(__aeabi_ddiv) \
|
||||
- SymI_NeedsProto(__aeabi_dmul) \
|
||||
- SymI_NeedsProto(__aeabi_dneg) \
|
||||
- SymI_NeedsProto(__aeabi_dsub) \
|
||||
- SymI_NeedsProto(__aeabi_f2d) \
|
||||
- SymI_NeedsProto(__aeabi_f2iz) \
|
||||
- SymI_NeedsProto(__aeabi_f2lz) \
|
||||
- SymI_NeedsProto(__aeabi_f2uiz) \
|
||||
- SymI_NeedsProto(__aeabi_f2ulz) \
|
||||
- SymI_NeedsProto(__aeabi_fadd) \
|
||||
- SymI_NeedsProto(__aeabi_fcmpeq) \
|
||||
- SymI_NeedsProto(__aeabi_fcmpge) \
|
||||
- SymI_NeedsProto(__aeabi_fcmpgt) \
|
||||
- SymI_NeedsProto(__aeabi_fcmple) \
|
||||
- SymI_NeedsProto(__aeabi_fcmplt) \
|
||||
- SymI_NeedsProto(__aeabi_fcmpun) \
|
||||
- SymI_NeedsProto(__aeabi_fdiv) \
|
||||
- SymI_NeedsProto(__aeabi_fmul) \
|
||||
- SymI_NeedsProto(__aeabi_fneg) \
|
||||
- SymI_NeedsProto(__aeabi_fsub) \
|
||||
- SymI_NeedsProto(__aeabi_i2d) \
|
||||
- SymI_NeedsProto(__aeabi_i2f) \
|
||||
- SymI_NeedsProto(__aeabi_idiv) \
|
||||
- SymI_NeedsProto(__aeabi_idivmod) \
|
||||
- SymI_NeedsProto(__aeabi_l2d) \
|
||||
- SymI_NeedsProto(__aeabi_l2f) \
|
||||
- SymI_NeedsProto(__aeabi_lasr) \
|
||||
- SymI_NeedsProto(__aeabi_lcmp) \
|
||||
- SymI_NeedsProto(__aeabi_ldivmod) \
|
||||
- SymI_NeedsProto(__aeabi_llsl) \
|
||||
- SymI_NeedsProto(__aeabi_llsr) \
|
||||
- SymI_NeedsProto(__aeabi_lmul) \
|
||||
- SymI_NeedsProto(__aeabi_ui2d) \
|
||||
- SymI_NeedsProto(__aeabi_ui2f) \
|
||||
- SymI_NeedsProto(__aeabi_uidiv) \
|
||||
- SymI_NeedsProto(__aeabi_uidivmod) \
|
||||
- SymI_NeedsProto(__aeabi_ul2d) \
|
||||
- SymI_NeedsProto(__aeabi_ul2f) \
|
||||
- SymI_NeedsProto(__aeabi_ulcmp) \
|
||||
- SymI_NeedsProto(__aeabi_uldivmod)
|
||||
-#define RTS_LIBGCC_SYMBOLS_64 \
|
||||
+#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
|
||||
+#define RTS_LIBGCC_SYMBOLS \
|
||||
+ SymI_NeedsProto(__divdi3) \
|
||||
+ SymI_NeedsProto(__udivdi3) \
|
||||
+ SymI_NeedsProto(__moddi3) \
|
||||
+ SymI_NeedsProto(__umoddi3) \
|
||||
+ SymI_NeedsProto(__muldi3) \
|
||||
+ SymI_NeedsProto(__ashldi3) \
|
||||
+ SymI_NeedsProto(__ashrdi3) \
|
||||
+ SymI_NeedsProto(__lshrdi3) \
|
||||
+ SymI_NeedsProto(__fixunsdfdi)
|
||||
+#elif defined(__GNUC__) && SIZEOF_VOID_P == 8
|
||||
+#define RTS_LIBGCC_SYMBOLS \
|
||||
SymI_NeedsProto(__udivti3) \
|
||||
SymI_NeedsProto(__umodti3)
|
||||
-
|
||||
-/* for aarch64 */
|
||||
-#define RTS_LIBGCC_SYMBOLS_aarch64 \
|
||||
- SymI_NeedsProto(__netf2) \
|
||||
- SymI_NeedsProto(__addtf3) \
|
||||
- SymI_NeedsProto(__subtf3) \
|
||||
- SymI_NeedsProto(__multf3) \
|
||||
- SymI_NeedsProto(__extenddftf2) \
|
||||
- SymI_NeedsProto(__fixtfsi) \
|
||||
- SymI_NeedsProto(__fixunstfsi) \
|
||||
- SymI_NeedsProto(__floatsitf) \
|
||||
- SymI_NeedsProto(__floatunsitf)
|
||||
-
|
||||
-#if defined(__GNUC__) && SIZEOF_VOID_P <= 4 && defined(arm_HOST_OS)
|
||||
-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32 RTS_LIBGCC_SYMBOLS_aarch32
|
||||
-#elif defined(__GNUC__) && SIZEOF_VOID_P <= 4 && !defined(_ABIN32)
|
||||
-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_32
|
||||
-#elif defined(__GNUC__) && SIZEOF_VOID_P == 8 && defined(aarch64_HOST_OS)
|
||||
-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64 RTS_LIBGCC_SYMBOLS_aarch64
|
||||
-#elif defined(__GNUC__) && SIZEOF_VOID_P == 8
|
||||
-#define RTS_LIBGCC_SYMBOLS RTS_LIBGCC_SYMBOLS_64
|
||||
#else
|
||||
#define RTS_LIBGCC_SYMBOLS
|
||||
#endif
|
||||
|
||||
-#if !defined(mingw32_HOST_OS) && !defined(DYNAMIC) && (defined(_FORTIFY_SOURCE) || defined(__SSP__))
|
||||
-#define RTS_SSP_SYMBOLS \
|
||||
- SymI_NeedsProto(__stack_chk_guard) \
|
||||
- SymI_NeedsProto(__stack_chk_fail)
|
||||
-#else
|
||||
-#define RTS_SSP_SYMBOLS
|
||||
-#endif
|
||||
-#if !defined(DYNAMIC) && defined(linux_HOST_OS)
|
||||
-// we need these for static musl builds. However when
|
||||
-// linking shared objects (DLLs) this will fail, hence
|
||||
-// we do not include them when building with -DDYNAMIC
|
||||
-#define RTS_LINKER_SYMBOLS \
|
||||
- SymI_NeedsProto(__fini_array_start) \
|
||||
- SymI_NeedsProto(__fini_array_end)
|
||||
-#else
|
||||
-#define RTS_LINKER_SYMBOLS
|
||||
-#endif
|
||||
-
|
||||
-#if defined(darwin_HOST_OS) && defined(powerpc_HOST_ARCH)
|
||||
- // Symbols that don't have a leading underscore
|
||||
- // on Mac OS X. They have to receive special treatment,
|
||||
- // see machoInitSymbolsWithoutUnderscore()
|
||||
-#define RTS_MACHO_NOUNDERLINE_SYMBOLS \
|
||||
- SymI_NeedsProto(saveFP) \
|
||||
- SymI_NeedsProto(restFP)
|
||||
-#endif
|
||||
-
|
||||
/* entirely bogus claims about types of these symbols */
|
||||
-/* to prevent a bit of define expansion, SymI_NeedsProto is a variadic
|
||||
- * macro. And we'll concat vvv with the __VA_ARGS__. This prevents
|
||||
- * vvv from getting macro expanded.
|
||||
- */
|
||||
-#define SymI_NeedsProto(vvv,...) extern void vvv ## __VA_ARGS__ (void);
|
||||
+#define SymI_NeedsProto(vvv) extern void vvv(void);
|
||||
#define SymI_NeedsDataProto(vvv) extern StgWord vvv[];
|
||||
#if defined(COMPILING_WINDOWS_DLL)
|
||||
#define SymE_HasProto(vvv) SymE_HasProto(vvv);
|
||||
@@ -1209,8 +1026,6 @@ RTS_DARWIN_ONLY_SYMBOLS
|
||||
RTS_OPENBSD_ONLY_SYMBOLS
|
||||
RTS_LIBGCC_SYMBOLS
|
||||
RTS_LIBFFI_SYMBOLS
|
||||
-RTS_SSP_SYMBOLS
|
||||
-RTS_LINKER_SYMBOLS
|
||||
#undef SymI_NeedsProto
|
||||
#undef SymI_NeedsDataProto
|
||||
#undef SymI_HasProto
|
||||
@@ -1230,7 +1045,7 @@ RTS_LINKER_SYMBOLS
|
||||
#define SymE_HasDataProto(vvv) \
|
||||
SymE_HasProto(vvv)
|
||||
|
||||
-#define SymI_NeedsProto(vvv,...) SymI_HasProto(vvv ## __VA_ARGS__)
|
||||
+#define SymI_NeedsProto(vvv) SymI_HasProto(vvv)
|
||||
#define SymI_NeedsDataProto(vvv) SymI_HasDataProto(vvv)
|
||||
#define SymE_NeedsProto(vvv) SymE_HasProto(vvv)
|
||||
#define SymE_NeedsDataProto(vvv) SymE_HasDataProto(vvv)
|
||||
@@ -1251,8 +1066,6 @@ RTS_LINKER_SYMBOLS
|
||||
#define SymI_HasProto_deprecated(vvv) \
|
||||
{ #vvv, (void*)0xBAADF00D, true },
|
||||
|
||||
-void *RTS_DYNAMIC = NULL;
|
||||
-
|
||||
RtsSymbolVal rtsSyms[] = {
|
||||
RTS_SYMBOLS
|
||||
RTS_RET_SYMBOLS
|
||||
@@ -1264,14 +1077,11 @@ RtsSymbolVal rtsSyms[] = {
|
||||
RTS_LIBGCC_SYMBOLS
|
||||
RTS_LIBFFI_SYMBOLS
|
||||
SymI_HasDataProto(nonmoving_write_barrier_enabled)
|
||||
- RTS_SSP_SYMBOLS
|
||||
- RTS_LINKER_SYMBOLS
|
||||
#if defined(darwin_HOST_OS) && defined(i386_HOST_ARCH)
|
||||
// dyld stub code contains references to this,
|
||||
// but it should never be called because we treat
|
||||
// lazy pointers as nonlazy.
|
||||
{ "dyld_stub_binding_helper", (void*)0xDEADBEEF, false },
|
||||
#endif
|
||||
- { "_DYNAMIC", (void*)(&RTS_DYNAMIC), false },
|
||||
{ 0, 0, false } /* sentinel */
|
||||
};
|
||||
--
|
||||
2.25.4
|
||||
|
||||
32
pkgs/development/compilers/ghc/rename-numa-api-call.patch
Normal file
32
pkgs/development/compilers/ghc/rename-numa-api-call.patch
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
diff --git a/rts/win32/OSMem.c b/rts/win32/OSMem.c
|
||||
--- a/rts/win32/OSMem.c
|
||||
+++ b/rts/win32/OSMem.c
|
||||
@@ -41,7 +41,7 @@ static block_rec* free_blocks = NULL;
|
||||
typedef LPVOID(WINAPI *VirtualAllocExNumaProc)(HANDLE, LPVOID, SIZE_T, DWORD, DWORD, DWORD);
|
||||
|
||||
/* Cache NUMA API call. */
|
||||
-VirtualAllocExNumaProc VirtualAllocExNuma;
|
||||
+VirtualAllocExNumaProc _VirtualAllocExNuma;
|
||||
|
||||
void
|
||||
osMemInit(void)
|
||||
@@ -52,8 +52,8 @@ osMemInit(void)
|
||||
/* Resolve and cache VirtualAllocExNuma. */
|
||||
if (osNumaAvailable() && RtsFlags.GcFlags.numa)
|
||||
{
|
||||
- VirtualAllocExNuma = (VirtualAllocExNumaProc)GetProcAddress(GetModuleHandleW(L"kernel32"), "VirtualAllocExNuma");
|
||||
- if (!VirtualAllocExNuma)
|
||||
+ _VirtualAllocExNuma = (VirtualAllocExNumaProc)(void*)GetProcAddress(GetModuleHandleW(L"kernel32"), "VirtualAllocExNuma");
|
||||
+ if (!_VirtualAllocExNuma)
|
||||
{
|
||||
sysErrorBelch(
|
||||
"osBindMBlocksToNode: VirtualAllocExNuma does not exist. How did you get this far?");
|
||||
@@ -569,7 +569,7 @@ void osBindMBlocksToNode(
|
||||
On windows also -xb is broken, it does nothing so that can't
|
||||
be used to tweak it (see #12577). So for now, just let the OS decide.
|
||||
*/
|
||||
- temp = VirtualAllocExNuma(
|
||||
+ temp = _VirtualAllocExNuma(
|
||||
GetCurrentProcess(),
|
||||
NULL, // addr? See base memory
|
||||
size,
|
||||
25
pkgs/development/compilers/ghc/respect-ar-path.patch
Normal file
25
pkgs/development/compilers/ghc/respect-ar-path.patch
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
diff -urd a/aclocal.m4 b/aclocal.m4
|
||||
--- a/aclocal.m4
|
||||
+++ b/aclocal.m4
|
||||
@@ -1199,7 +1199,8 @@
|
||||
# thinks that target == host so it never checks the unqualified
|
||||
# tools for Windows. See #14274.
|
||||
AC_DEFUN([FP_PROG_AR],
|
||||
-[if test -z "$fp_prog_ar"; then
|
||||
+[AC_SUBST(fp_prog_ar,$AR)
|
||||
+if test -z "$fp_prog_ar"; then
|
||||
if test "$HostOS" = "mingw32"
|
||||
then
|
||||
AC_PATH_PROG([fp_prog_ar], [ar])
|
||||
diff -urd a/configure b/configure
|
||||
--- a/configure
|
||||
+++ b/configure
|
||||
@@ -10744,6 +10744,8 @@
|
||||
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
|
||||
|
||||
|
||||
+fp_prog_ar=$AR
|
||||
+
|
||||
if test -z "$fp_prog_ar"; then
|
||||
if test "$HostOS" = "mingw32"
|
||||
then
|
||||
11
pkgs/development/compilers/ghc/sphinx-4-configuration.patch
Normal file
11
pkgs/development/compilers/ghc/sphinx-4-configuration.patch
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
--- ghc-8.10.4/docs/users_guide/conf.py.orig 2021-06-21 13:46:34.196383559 +0200
|
||||
+++ ghc-8.10.4/docs/users_guide/conf.py 2021-06-21 13:46:54.839349941 +0200
|
||||
@@ -100,7 +100,7 @@
|
||||
latex_elements = {
|
||||
'inputenc': '',
|
||||
'utf8extra': '',
|
||||
- 'preamble': '''
|
||||
+ 'preamble': r'''
|
||||
\usepackage{fontspec}
|
||||
\usepackage{makeidx}
|
||||
\setsansfont{DejaVu Sans}
|
||||
Loading…
Add table
Add a link
Reference in a new issue