Fix GHC loadArchive clang++ error on macOS

GHC 8.6.4 introduced an issue where linking to `-libc++` will cause
GHC to resolve the library patch to `c++`, which in turn is a link to
clang++.

This results in the following error:

```
ghc: loadArchive: Neither an archive, nor a fat archive: `/nix/store/?-clang-wrapper-5.0.2/bin/clang++'

<no location info>: error:
    loadArchive "/nix/store/?-clang-wrapper-5.0.2/bin/clang++": failed
```

This commit applies the relevant patch to revert GHC's linking behavior
on darwin for the applicable versions of GHC (i.e. after 8.6.4).

# Conflicts:
#	pkgs/development/compilers/ghc/8.10.7.nix
#	pkgs/development/compilers/ghc/9.0.1.nix
#	pkgs/development/compilers/ghc/9.2.1.nix
This commit is contained in:
jkachmar 2021-12-09 18:36:53 -05:00 committed by iko
parent d2b3c67e62
commit 9dc87ff9c2
Signed by: iko
GPG Key ID: 82C257048D1026F2
4 changed files with 23 additions and 1 deletions

View File

@ -212,6 +212,10 @@ stdenv.mkDerivation (rec {
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/97d0b0a367e4c6a52a17c3299439ac7de129da24.patch";
sha256 = "0r4zjj0bv1x1m2dgxp3adsf2xkr94fjnyj1igsivd9ilbs5ja0b5";
})
(fetchpatch {
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/613ec38dbd62ab7929178c9c7ffff71df9bb86be/overlays/patches/ghc/ghc-macOS-loadArchive-fix.patch";
sha256 = "1adywy867cwbh288ghr2f7mg8xq0g0kif1d6vswd0zqxwrbg9dh5";
})
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
# Prevent the paths module from emitting symbols that we don't use

View File

@ -195,6 +195,12 @@ stdenv.mkDerivation (rec {
# Renamed to match ghc8.8:
# https://gitlab.haskell.org/ghc/ghc/-/commit/4b431f334018eaef2cf36de3316025c68c922915#20d64c0bdc272817149d1d5cf20a73a8b5fd637f
./rename-numa-api-call.patch
] ++ lib.optionals stdenv.isDarwin [
# Reverts the linking behavior of GHC to not resolve `-libc++` to `c++`.
(fetchpatch {
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/902d94ddd7d02472c8ee52877cf8538041f9071a/overlays/patches/ghc/ghc-macOS-loadArchive-fix.patch";
sha256 = "1adywy867cwbh288ghr2f7mg8xq0g0kif1d6vswd0zqxwrbg9dh5";
})
];
postPatch = "patchShebangs .";

View File

@ -176,7 +176,7 @@ stdenv.mkDerivation (rec {
src = fetchurl {
url = "https://downloads.haskell.org/ghc/${version}/ghc-${version}-src.tar.xz";
sha256 = "140e42b96346322d1a39eb17602bcdc76e292028ad4a69286b230bab188a9197";
sha256 = "sha256-FA5CuWNGMi0aOesXYCvNx24pICitSmkoayMLqxiKkZc";
};
enableParallelBuilding = true;
@ -192,6 +192,11 @@ stdenv.mkDerivation (rec {
url = "https://gitlab.haskell.org/ghc/ghc/-/commit/c6132c782d974a7701e7f6447bdcd2bf6db4299a.patch?merge_request_iid=7423";
sha256 = "sha256-b4feGZIaKDj/UKjWTNY6/jH4s2iate0wAgMxG3rAbZI=";
})
] ++ lib.optionals stdenv.targetPlatform.isDarwin [
(fetchpatch {
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/902d94ddd7d02472c8ee52877cf8538041f9071a/overlays/patches/ghc/ghc-9.0-macOS-loadArchive-fix.patch";
sha256 = "038bgkwrkqgpiy0riimbgs979wvzx3flll72m4zi22075dx0mnhm";
})
] ++ lib.optionals (stdenv.targetPlatform.isDarwin && stdenv.targetPlatform.isAarch64) [
# Prevent the paths module from emitting symbols that we don't use

View File

@ -183,6 +183,13 @@ stdenv.mkDerivation (rec {
outputs = [ "out" "doc" ];
patches = lib.optionals stdenv.isDarwin [
(fetchpatch {
url = "https://raw.githubusercontent.com/input-output-hk/haskell.nix/902d94ddd7d02472c8ee52877cf8538041f9071a/overlays/patches/ghc/ghc-9.2-macOS-loadArchive-fix.patch";
sha256 = "1wb8zf10w805ldcyjm7vcjpg9g71rvxdl30r0kcgk4pdcpz0hxi2";
})
];
postPatch = "patchShebangs .";
# GHC needs the locale configured during the Haddock phase.