From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timothy Sample Subject: Re: Help needed: Updating GHC to 8.4.3 Date: Sat, 25 Aug 2018 15:28:30 -0400 Message-ID: <87tvni5jq9.fsf@ngyro.com> References: <87tvnpfir4.fsf@gnu.org> <874lfptjd3.fsf@elephly.net> <87k1of6nlq.fsf@ngyro.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([208.118.235.92]:53920) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fteEu-0006AU-8X for guix-devel@gnu.org; Sat, 25 Aug 2018 15:28:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fteEa-0004r2-A2 for guix-devel@gnu.org; Sat, 25 Aug 2018 15:28:36 -0400 Received: from out1-smtp.messagingengine.com ([66.111.4.25]:42251) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fteEa-0004qJ-32 for guix-devel@gnu.org; Sat, 25 Aug 2018 15:28:32 -0400 In-Reply-To: <87k1of6nlq.fsf@ngyro.com> (Timothy Sample's message of "Sat, 25 Aug 2018 01:07:13 -0400") List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: "Guix-devel" To: Ricardo Wurmus Cc: guix-devel@gnu.org, Ricardo Wurmus --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Hi Again, I=E2=80=99ve attached an updated patch that builds a working GHC 8.4.3 (tha= t is, it compiles =E2=80=9Chello.hs=E2=80=9D in a pure environment). It might ne= ed a bit more work yet. See notes below. Timothy Sample writes: > Hi Ricardo, > > Ricardo Wurmus writes: > >> Hi Ludo, >> >>> Hello, >>> >>> Ricardo Wurmus 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=E2=80=99t= seem to >>>> behave right in some edge case that GHC depends on. I tried porting t= he >>>> 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=E2=80=99s 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=E2=80=99m not sure what they are about, but they ar= e 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 =E2=80=9C-fuse-ld=3Dbfd=E2=80=9D to the later-stage compilers=E2=80= =99 =E2=80=9Cgcc=E2=80=9D invocations by > default. Since =E2=80=9Cld.bfd=E2=80=9D does not point to the ld-wrapper= , the wrapper > gets bypassed. > > There are two easy solutions to this: > > 1. Use the =E2=80=9C--disable-ld-override=E2=80=9D configure flag. > 2. Set the =E2=80=9CLD=E2=80=9D environment variable. > > I got the package to build using option 1. However, it didn=E2=80=99t wo= rk > because it expected all the build tools (=E2=80=9Cgcc=E2=80=9D, =E2=80=9C= ld=E2=80=9D, etc.) to be in > =E2=80=9CPATH=E2=80=9D. They traded =E2=80=9CAC_PATH_=E2=80=9D for =E2= =80=9CAC_CHECK_=E2=80=9D, 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=E2=80=99s example, and set environment variables. I didn=E2= =80=99t set the same ones as Nix, since some of them are Windows- or Clang-specific, and one of them (=E2=80=9Car=E2=80=9D) didn=E2=80=99t work. These tools need to be used by the resulting compiler, so I made sure that they are =E2=80=9Cinputs=E2=80=9D rather than =E2=80=9Cnative-inputs= =E2=80=9D. I don=E2=80=99t know if GHC can be cross compiled, but I think something like this is necessary for it. To be honest, I=E2=80=99m not sure I did this correctly, so do take a careful look. > Also, I didn=E2=80=99t need the response files patch, and the > =E2=80=9Cnative-search-paths=E2=80=9D field needs to be updated. I added the =E2=80=9Cnative-search-paths=E2=80=9D field. > Hope that helps! > > > -- Tim --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=ghc-tim-2.patch Content-Description: GHC 8.4.3 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=, 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 --=-=-=--