[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Help needed: Updating GHC to 8.4.3
From: |
Timothy Sample |
Subject: |
Re: Help needed: Updating GHC to 8.4.3 |
Date: |
Sat, 25 Aug 2018 15:28:30 -0400 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux) |
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 <address@hidden> writes:
> Hi Ricardo,
>
> Ricardo Wurmus <address@hidden> writes:
>
>> Hi Ludo,
>>
>>> Hello,
>>>
>>> Ricardo Wurmus <address@hidden> 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
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