all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Timothy Sample <samplet@ngyro.com>
To: Ricardo Wurmus <rekado@elephly.net>
Cc: guix-devel@gnu.org, Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de>
Subject: Re: Help needed: Updating GHC to 8.4.3
Date: Sat, 25 Aug 2018 15:28:30 -0400	[thread overview]
Message-ID: <87tvni5jq9.fsf@ngyro.com> (raw)
In-Reply-To: <87k1of6nlq.fsf@ngyro.com> (Timothy Sample's message of "Sat, 25 Aug 2018 01:07:13 -0400")

[-- Attachment #1: Type: text/plain, Size: 3011 bytes --]

Hi Again,

I’ve attached an updated patch that builds a working GHC 8.4.3 (that is,
it compiles “hello.hs” in a pure environment).  It might need a bit more
work yet.  See notes below.

Timothy Sample <samplet@ngyro.com> writes:

> Hi Ricardo,
>
> Ricardo Wurmus <rekado@elephly.net> writes:
>
>> Hi Ludo,
>>
>>> Hello,
>>>
>>> Ricardo Wurmus <ricardo.wurmus@mdc-berlin.de> skribis:
>>>
>>>> GHC 8.0 had been patched with
>>>> "ghc-dont-pass-linker-flags-via-response-files.patch" to avoid using
>>>> response files with the linker, because our ld-wrapper doesn’t seem to
>>>> behave right in some edge case that GHC depends on.  I tried porting the
>>>> patch to GHC 8.4.3 by applying this snippet:
>>>
>>> I think this patch predates the addition of support for response files
>>> in ld-wrapper.  That support is not entirely faithful (see the FIXME in
>>> ld-wrapper.in), but I think it’s good enough for GHC.
>>>
>>> Could you maybe try removing the patch and see if it works better?
>>
>> I did try to build GHC 8.4.3 without any patches first, but this failed
>> (with the same errors and warnings when trying to set up the tests).
>> Only then did I try to port the patch from 8.0.x to 8.4.3.
>
> I had some success with GHC 8.4.3.  It turns out that the warnings exist
> for 8.0.2 as well.  I’m not sure what they are about, but they are not a
> new problem.
>
> The new problem is that the stage-2 GHC compiler is not using the
> ld-wrapper.  This is due to some changes to their Autoconf scripts which
> add “-fuse-ld=bfd” to the later-stage compilers’ “gcc” invocations by
> default.  Since “ld.bfd” does not point to the ld-wrapper, the wrapper
> gets bypassed.
>
> There are two easy solutions to this:
>
>   1. Use the “--disable-ld-override” configure flag.
>   2. Set the “LD” environment variable.
>
> I got the package to build using option 1.  However, it didn’t work
> because it expected all the build tools (“gcc”, “ld”, etc.) to be in
> “PATH”.  They traded “AC_PATH_” for “AC_CHECK_”, setting the variables
> to just the command names.  Nix uses option 2 and sets explicit paths
> for all the tools via environment variables.  I think we have to do the
> same.

I followed Nix’s example, and set environment variables.  I didn’t set
the same ones as Nix, since some of them are Windows- or Clang-specific,
and one of them (“ar”) didn’t work.

These tools need to be used by the resulting compiler, so I made sure
that they are “inputs” rather than “native-inputs”.  I don’t know if GHC
can be cross compiled, but I think something like this is necessary for
it.  To be honest, I’m not sure I did this correctly, so do take a
careful look.

> Also, I didn’t need the response files patch, and the
> “native-search-paths” field needs to be updated.

I added the “native-search-paths” field.

> Hope that helps!
>
>
> -- Tim


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: GHC 8.4.3 --]
[-- Type: text/x-patch, Size: 6372 bytes --]

diff --git a/gnu/packages/haskell.scm b/gnu/packages/haskell.scm
index 7347c8753..2dd1d0c66 100644
--- a/gnu/packages/haskell.scm
+++ b/gnu/packages/haskell.scm
@@ -33,6 +33,7 @@
 
 (define-module (gnu packages haskell)
   #:use-module (gnu packages)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages bootstrap)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
@@ -320,7 +321,7 @@ top of CLISP.")
 interactive environment for the functional language Haskell.")
     (license license:bsd-3)))
 
-(define-public ghc-8
+(define-public ghc-8.0
   (package
     (name "ghc")
     (version "8.0.2")
@@ -432,7 +433,129 @@ interactive environment for the functional language Haskell.")
 interactive environment for the functional language Haskell.")
     (license license:bsd-3)))
 
-(define-public ghc ghc-8)
+(define-public ghc-8
+  (package
+    (inherit ghc-8.0)
+    (name "ghc")
+    (version "8.4.3")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (string-append "https://www.haskell.org/ghc/dist/"
+                           version "/" name "-" version "-src.tar.xz"))
+       (sha256
+        (base32
+         "1mk046vb561j75saz05rghhbkps46ym5aci4264dwc2qk3dayixf"))))
+    (inputs
+     `(("gmp" ,gmp)
+       ("ncurses" ,ncurses)
+       ("libffi" ,libffi)
+       ("target-binutils" ,binutils)
+       ("target-gcc" ,gcc)
+       ("target-ld-wrapper" ,(make-ld-wrapper "ld-wrapper"
+                                              #:binutils binutils))))
+    (native-inputs
+     `(("perl" ,perl)
+       ("python" ,python)            ; for tests
+       ("ghostscript" ,ghostscript)  ; for tests
+       ;; GHC 8.4.3 is built with GHC 8.
+       ("ghc-bootstrap" ,ghc-8.0)
+       ("ghc-testsuite"
+        ,(origin
+           (method url-fetch)
+           (uri (string-append
+                 "https://www.haskell.org/ghc/dist/"
+                 version "/" name "-" version "-testsuite.tar.xz"))
+           (sha256
+            (base32
+             "1z55b1z0m3plqd2d1ks6w5wvx7igm7zsk3i4v7cms003z0as0hzz"))))))
+    (arguments
+     `(#:test-target "test"
+       ;; We get a smaller number of test failures by disabling parallel test
+       ;; execution.
+       #:parallel-tests? #f
+
+       ;; The DSOs use $ORIGIN to refer to each other, but (guix build
+       ;; gremlin) doesn't support it yet, so skip this phase.
+       #:validate-runpath? #f
+
+       ;; Don't pass --build=<triplet>, because the configure script
+       ;; auto-detects slightly different triplets for --host and --target and
+       ;; then complains that they don't match.
+       #:build #f
+
+       #:configure-flags
+       (list
+        (string-append "--with-gmp-libraries="
+                       (assoc-ref %build-inputs "gmp") "/lib")
+        (string-append "--with-gmp-includes="
+                       (assoc-ref %build-inputs "gmp") "/include")
+        "--with-system-libffi"
+        (string-append "--with-ffi-libraries="
+                       (assoc-ref %build-inputs "libffi") "/lib")
+        (string-append "--with-ffi-includes="
+                       (assoc-ref %build-inputs "libffi") "/include")
+        (string-append "--with-curses-libraries="
+                       (assoc-ref %build-inputs "ncurses") "/lib")
+        (string-append "--with-curses-includes="
+                       (assoc-ref %build-inputs "ncurses") "/include"))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'unpack-testsuite
+           (lambda* (#:key inputs #:allow-other-keys)
+             (invoke "tar" "xvf"
+                     (assoc-ref inputs "ghc-testsuite")
+                     "--strip-components=1")
+             #t))
+         (add-after 'unpack-testsuite 'fix-shell-wrappers
+           (lambda _
+             (substitute* '("driver/ghci/ghc.mk"
+                            "utils/mkdirhier/ghc.mk"
+                            "rules/shell-wrapper.mk")
+               (("echo '#!/bin/sh'")
+                (format #f "echo '#!~a'" (which "sh"))))
+             #t))
+         (add-before 'configure 'set-target-programs
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let ((binutils (assoc-ref inputs "target-binutils"))
+                   (gcc (assoc-ref inputs "target-gcc"))
+                   (ld-wrapper (assoc-ref inputs "target-ld-wrapper")))
+               (setenv "CC" (string-append gcc "/bin/gcc"))
+               (setenv "CXX" (string-append gcc "/bin/g++"))
+               (setenv "LD" (string-append ld-wrapper "/bin/ld"))
+               (setenv "NM" (string-append binutils "/bin/nm"))
+               (setenv "RANLIB" (string-append binutils "/bin/ranlib"))
+               (setenv "STRIP" (string-append binutils "/bin/strip"))
+               ;; The 'ar' command does not follow the same pattern.
+               (setenv "fp_prog_ar" (string-append binutils "/bin/ar")))))
+         (add-before 'build 'fix-references
+           (lambda _
+             (substitute* '("testsuite/timeout/Makefile"
+                            "testsuite/timeout/timeout.py"
+                            "testsuite/timeout/timeout.hs"
+                            "testsuite/tests/programs/life_space_leak/life.test"
+                            ;; libraries
+                            "libraries/process/System/Process/Posix.hs"
+                            "libraries/process/tests/process001.hs"
+                            "libraries/process/tests/process002.hs"
+                            "libraries/unix/cbits/execvpe.c")
+               (("/bin/sh") (which "sh"))
+               (("/bin/ls") (which "ls"))
+               (("/bin/rm") "rm"))
+             #t))
+         (add-before 'build 'fix-environment
+           (lambda _
+             (unsetenv "GHC_PACKAGE_PATH")
+             (setenv "CONFIG_SHELL" (which "bash"))
+             #t)))))
+    (native-search-paths (list (search-path-specification
+                                (variable "GHC_PACKAGE_PATH")
+                                (files (list
+                                        (string-append "lib/ghc-" version)))
+                                (file-pattern ".*\\.conf\\.d$")
+                                (file-type 'directory))))))
+
+(define-public ghc ghc-8.0)
 
 (define-public ghc-hostname
   (package

  reply	other threads:[~2018-08-25 19:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-17 15:08 Help needed: Updating GHC to 8.4.3 Ricardo Wurmus
2018-08-20 10:13 ` Ludovic Courtès
2018-08-20 10:36   ` Ricardo Wurmus
2018-08-25  5:07     ` Timothy Sample
2018-08-25 19:28       ` Timothy Sample [this message]
2018-08-26 14:29         ` Timothy Sample
2018-08-28 16:02           ` Ricardo Wurmus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87tvni5jq9.fsf@ngyro.com \
    --to=samplet@ngyro.com \
    --cc=guix-devel@gnu.org \
    --cc=rekado@elephly.net \
    --cc=ricardo.wurmus@mdc-berlin.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.