From 643169bbb48126a3b6ec3c4a32bbbe7a815d11c8 Mon Sep 17 00:00:00 2001 From: Cheng Shao Date: Mon, 25 Jan 2021 09:41:25 +0000 Subject: [PATCH] Fix ar command path in GHC. Previously, the "ar command" in the global config of GHC in nixpkgs is simply "ar" instead of a proper absolute path in the nix store. This will result in an "ar: command not found" error when using GHC and cabal in a pure nix shell. This commit adds the patch and applies to all pre-9.0 versions. See output of ghc --info for "ar command" value. --- pkgs/development/compilers/ghc/8.10.1.nix | 10 ++++++++ pkgs/development/compilers/ghc/8.10.2.nix | 10 +++++++- pkgs/development/compilers/ghc/8.10.3.nix | 10 +++++++- pkgs/development/compilers/ghc/8.6.5.nix | 8 ++++++ pkgs/development/compilers/ghc/8.8.2.nix | 10 ++++++++ pkgs/development/compilers/ghc/8.8.3.nix | 10 ++++++++ pkgs/development/compilers/ghc/8.8.4.nix | 10 ++++++++ .../compilers/ghc/respect-ar-path.patch | 25 +++++++++++++++++++ 8 files changed, 91 insertions(+), 2 deletions(-) create mode 100644 pkgs/development/compilers/ghc/respect-ar-path.patch diff --git a/pkgs/development/compilers/ghc/8.10.1.nix b/pkgs/development/compilers/ghc/8.10.1.nix index 661dd5cb0026..83604630545e 100644 --- a/pkgs/development/compilers/ghc/8.10.1.nix +++ b/pkgs/development/compilers/ghc/8.10.1.nix @@ -116,6 +116,16 @@ stdenv.mkDerivation (rec { 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 + ]; + postPatch = "patchShebangs ."; # GHC is a bit confused on its cross terminology. diff --git a/pkgs/development/compilers/ghc/8.10.2.nix b/pkgs/development/compilers/ghc/8.10.2.nix index 6e194b68faa2..a42dfce6468a 100644 --- a/pkgs/development/compilers/ghc/8.10.2.nix +++ b/pkgs/development/compilers/ghc/8.10.2.nix @@ -107,8 +107,16 @@ stdenv.mkDerivation (rec { outputs = [ "out" "doc" ]; - # https://gitlab.haskell.org/ghc/ghc/-/issues/18549 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 + + # https://gitlab.haskell.org/ghc/ghc/-/issues/18549 ./issue-18549.patch ] ++ lib.optionals stdenv.isDarwin [ # Make Block.h compile with c++ compilers. Remove with the next release diff --git a/pkgs/development/compilers/ghc/8.10.3.nix b/pkgs/development/compilers/ghc/8.10.3.nix index 582817cca070..f1b225b12c80 100644 --- a/pkgs/development/compilers/ghc/8.10.3.nix +++ b/pkgs/development/compilers/ghc/8.10.3.nix @@ -107,7 +107,15 @@ stdenv.mkDerivation (rec { outputs = [ "out" "doc" ]; - patches = lib.optionals stdenv.isDarwin [ + 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 + ] ++ stdenv.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"; diff --git a/pkgs/development/compilers/ghc/8.6.5.nix b/pkgs/development/compilers/ghc/8.6.5.nix index 219ace5a9164..8237f27241e7 100644 --- a/pkgs/development/compilers/ghc/8.6.5.nix +++ b/pkgs/development/compilers/ghc/8.6.5.nix @@ -110,6 +110,14 @@ stdenv.mkDerivation (rec { 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 + (fetchpatch { # https://phabricator.haskell.org/D5123 url = "https://gitlab.haskell.org/ghc/ghc/-/commit/13ff0b7ced097286e0d7b054f050871effe07f86.diff"; name = "D5123.diff"; diff --git a/pkgs/development/compilers/ghc/8.8.2.nix b/pkgs/development/compilers/ghc/8.8.2.nix index 94553e56a811..144e46459759 100644 --- a/pkgs/development/compilers/ghc/8.8.2.nix +++ b/pkgs/development/compilers/ghc/8.8.2.nix @@ -111,6 +111,16 @@ stdenv.mkDerivation (rec { 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 + ]; + postPatch = "patchShebangs ."; # GHC is a bit confused on its cross terminology. diff --git a/pkgs/development/compilers/ghc/8.8.3.nix b/pkgs/development/compilers/ghc/8.8.3.nix index ca4dc35ccdc4..9e99207d9aaa 100644 --- a/pkgs/development/compilers/ghc/8.8.3.nix +++ b/pkgs/development/compilers/ghc/8.8.3.nix @@ -116,6 +116,16 @@ stdenv.mkDerivation (rec { 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 + ]; + postPatch = "patchShebangs ."; # GHC is a bit confused on its cross terminology. diff --git a/pkgs/development/compilers/ghc/8.8.4.nix b/pkgs/development/compilers/ghc/8.8.4.nix index ab5f2c12e230..9bef190ad1c3 100644 --- a/pkgs/development/compilers/ghc/8.8.4.nix +++ b/pkgs/development/compilers/ghc/8.8.4.nix @@ -116,6 +116,16 @@ stdenv.mkDerivation (rec { 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 + ]; + postPatch = "patchShebangs ."; # GHC is a bit confused on its cross terminology. diff --git a/pkgs/development/compilers/ghc/respect-ar-path.patch b/pkgs/development/compilers/ghc/respect-ar-path.patch new file mode 100644 index 000000000000..a08a802c18a0 --- /dev/null +++ b/pkgs/development/compilers/ghc/respect-ar-path.patch @@ -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