beHi,

I've updated our ghc-8 Haskell compiler to the latest version (8.0.2)
and in doing so I've investigated why both 8.0.1 and 8.0.2 do not work
without setting LD_LIBRARY_PATH to the required system libraries.
I've found that NIX had the same problem.  The root cause for them was
that their gcc-wrapper was not able to properly handle arguments
passed through response files.  I suspect that we have the same
problem.

https://github.com/NixOS/nixpkgs/issues/10752
https://github.com/NixOS/nixpkgs/issues/11762

For the moment I've borrowed a patch for GHC that they did use before
fixing the gcc-wrapper. Going forward it would probably be wise to fix
our gcc/ld wrapper as well.

Regards,
Fede
From 35c4fa12cf2eb7316583b41c0c4e8b60f7a59bdc Mon Sep 17 00:00:00 2001
From: Federico Beffa <[email protected]>
Date: Wed, 25 Jan 2017 18:21:43 +0100
Subject: [PATCH] gnu: ghc-8: Update to 8.0.2.

* gnu/packages/haskell.scm (ghc-8): Update to 8.0.2.
* gnu/packages/patches/ghc-dont-pass-linker-flags-via-response-files.patch:
  New file.
* gnu/local.mk (dist_patch_DATA): Add it.
---
 gnu/local.mk                                       |  1 +
 gnu/packages/haskell.scm                           | 31 ++++++----------------
 ...dont-pass-linker-flags-via-response-files.patch | 24 +++++++++++++++++
 3 files changed, 33 insertions(+), 23 deletions(-)
 create mode 100644 gnu/packages/patches/ghc-dont-pass-linker-flags-via-response-files.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 24013a5..93b0c3d 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -549,6 +549,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/gd-fix-tests-on-i686.patch		\
   %D%/packages/patches/gegl-CVE-2012-4433.patch			\
   %D%/packages/patches/geoclue-config.patch			\
+  %D%/packages/patches/ghc-dont-pass-linker-flags-via-response-files.patch	\
   %D%/packages/patches/ghostscript-CVE-2013-5653.patch		\
   %D%/packages/patches/ghostscript-CVE-2015-3228.patch		\
   %D%/packages/patches/ghostscript-CVE-2016-7976.patch		\
diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm
index 331057a..bdcda7f 100644
--- a/gnu/packages/haskell.scm
+++ b/gnu/packages/haskell.scm
@@ -31,6 +31,7 @@
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (guix build-system haskell)
+  #:use-module (gnu packages)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages compression)
@@ -264,14 +265,17 @@ interactive environment for the functional language Haskell.")
 (define-public ghc-8
   (package
     (name "ghc")
-    (version "8.0.1")
+    (version "8.0.2")
     (source
      (origin
       (method url-fetch)
       (uri (string-append "https://www.haskell.org/ghc/dist/";
                           version "/" name "-" version "-src.tar.xz"))
       (sha256
-       (base32 "1lniqy29djhjkddnailpaqhlqh4ld2mqvb1fxgxw1qqjhz6j1ywh"))))
+       (base32 "1c8qc4fhkycynk4g1f9hvk53dj6a1vvqi6bklqznns6hw59m8qhi"))
+      (patches
+       (search-patches
+        "ghc-dont-pass-linker-flags-via-response-files.patch"))))
     (build-system gnu-build-system)
     (supported-systems '("i686-linux" "x86_64-linux"))
     (outputs '("out" "doc"))
@@ -287,7 +291,7 @@ interactive environment for the functional language Haskell.")
                  "https://www.haskell.org/ghc/dist/";
                  version "/" name "-" version "-testsuite.tar.xz"))
            (sha256
-            (base32 "0lc1vjivkxn01aw3jg2gd7fmqb5pj7a5j987c7pn5r7caqv1cmxw"))))))
+            (base32 "1wjc3x68l305bl1h1ijd3yhqp2vqj83lkp3kqbr94qmmkqlms8sj"))))))
     (native-inputs
      `(("perl" ,perl)
        ("python" ,python-2)                ; for tests
@@ -309,13 +313,6 @@ interactive environment for the functional language Haskell.")
        ;; then complains that they don't match.
        #:build #f
 
-       #:modules ((guix build gnu-build-system)
-                  (guix build utils)
-                  (guix build rpath)
-                  (srfi srfi-26)
-                  (srfi srfi-1))
-       #:imported-modules (,@%gnu-build-system-modules
-                           (guix build rpath))
        #:configure-flags
        (list
         (string-append "--with-gmp-libraries="
@@ -363,19 +360,7 @@ interactive environment for the functional language Haskell.")
                        "testsuite/tests/programs/life_space_leak/life.test")
                (("/bin/sh") (which "sh"))
                (("/bin/rm") "rm"))
-             #t))
-         ;; the testsuite can't find shared libraries.
-         (add-before 'check 'configure-testsuite
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let* ((gmp (assoc-ref inputs "gmp"))
-                    (gmp-lib (string-append gmp "/lib"))
-                    (ffi (assoc-ref inputs "libffi"))
-                    (ffi-lib (string-append ffi "/lib"))
-                    (ncurses (assoc-ref inputs "ncurses"))
-                    (ncurses-lib (string-append ncurses "/lib")))
-               (setenv "LD_LIBRARY_PATH"
-                       (string-append gmp-lib ":" ffi-lib ":" ncurses-lib))
-               #t))))))
+             #t)))))
     (native-search-paths (list (search-path-specification
                                 (variable "GHC_PACKAGE_PATH")
                                 (files (list
diff --git a/gnu/packages/patches/ghc-dont-pass-linker-flags-via-response-files.patch b/gnu/packages/patches/ghc-dont-pass-linker-flags-via-response-files.patch
new file mode 100644
index 0000000..8a1a133
--- /dev/null
+++ b/gnu/packages/patches/ghc-dont-pass-linker-flags-via-response-files.patch
@@ -0,0 +1,24 @@
+See https://github.com/NixOS/nixpkgs/commit/a421e7bd4a28c69bded8b17888325e31554f61a1
+
+diff --git a/compiler/main/SysTools.hs.orig b/compiler/main/SysTools.hs
+index 1ab5b13..99270fc 100644
+--- a/compiler/main/SysTools.hs.orig
++++ b/compiler/main/SysTools.hs
+@@ -424,7 +424,7 @@ runCc dflags args =   do
+       args1 = map Option (getOpts dflags opt_c)
+       args2 = args0 ++ args1 ++ args
+   mb_env <- getGccEnv args2
+-  runSomethingResponseFile dflags cc_filter "C Compiler" p args2 mb_env
++  runSomethingFiltered dflags cc_filter "C Compiler" p args2 mb_env
+  where
+   -- discard some harmless warnings from gcc that we can't turn off
+   cc_filter = unlines . doFilter . lines
+@@ -945,7 +945,7 @@ runLink dflags args = do
+       args1     = map Option (getOpts dflags opt_l)
+       args2     = args0 ++ linkargs ++ args1 ++ args
+   mb_env <- getGccEnv args2
+-  runSomethingResponseFile dflags ld_filter "Linker" p args2 mb_env
++  runSomethingFiltered dflags ld_filter "Linker" p args2 mb_env
+   where
+     ld_filter = case (platformOS (targetPlatform dflags)) of
+                   OSSolaris2 -> sunos_ld_filter
-- 
2.10.1

Reply via email to