[bug#53964,3/4] gnu: ghc@4: Build without referring to packages in commencement.scm.
Commit Message
* gnu/packages/haskell.scm (ghc-4)[arguments]: Remove #:implicit-inputs?.
In 'bootstrap' phase, pass '-optc-D_GNU_SOURCE=1'. Use
'search-input-file' to locate lib{bfd,iberty}.a, and 'which' for cpp.
Patch 'mk/config.mk.in'. In 'configure' phase, emit "config.cache".
In 'make-boot' phase, replace "CLK_TCK" in 'nHandle.c'.
[native-inputs]: Remove now-implicit inputs; remove GLIBC-2.2.5,
GCC-MESBOOT0, and BINUTILS-MESBOOT. Add GCC-2.95 and BINUTILS-2.33.
Remove input labels.
---
gnu/packages/haskell.scm | 82 +++++++++++++++++-----------------------
1 file changed, 35 insertions(+), 47 deletions(-)
Comments
Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
> - (patches (list (search-patch "ghc-4.patch")))))
> + (patches (search-patches "ghc-4.patch"))))
Looks like an unrelated change to me. From (guix)Submitting Patches:
13. Verify that your patch contains only one set of related changes.
Bundling unrelated changes together makes reviewing harder and
slower.
Examples of unrelated changes include the addition of several
packages, or a package update along with fixes to that package.
Perhaps this is acceptable though for the same reasons removing
trailing #t from phases is acceptable ...
Greetings,
Maxime.
Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
> +GhcRtsHcOpts=-optc-DDEBUG -optc-D__HUGS__ -unreg -optc-g -optc-D_GNU_SOURCE=1
> +GhcRtsCcOpts=-optc-DDEBUG -optc-g -optc-D__HUGS__ -optc-D_GNU_SOURCE=1
What's this for? AFAICT this seems rather unrelated to ‘Build without
referring to packages in [...]’, but then I don't know what these two
lines mean so maybe it is actually related.
Greetings,
Maxime.
Maxime Devos <maximedevos@telenet.be> skribis:
> Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
>> - (patches (list (search-patch "ghc-4.patch")))))
>> + (patches (search-patches "ghc-4.patch"))))
>
> Looks like an unrelated change to me. From (guix)Submitting Patches:
>
> 13. Verify that your patch contains only one set of related changes.
> Bundling unrelated changes together makes reviewing harder and
> slower.
>
> Examples of unrelated changes include the addition of several
> packages, or a package update along with fixes to that package.
>
> Perhaps this is acceptable though for the same reasons removing
> trailing #t from phases is acceptable ...
You’re right, I can make it a different patch.
Ludo’.
Maxime Devos <maximedevos@telenet.be> skribis:
> Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
>> +GhcRtsHcOpts=-optc-DDEBUG -optc-D__HUGS__ -unreg -optc-g -optc-D_GNU_SOURCE=1
>> +GhcRtsCcOpts=-optc-DDEBUG -optc-g -optc-D__HUGS__ -optc-D_GNU_SOURCE=1
>
> What's this for? AFAICT this seems rather unrelated to ‘Build without
> referring to packages in [...]’, but then I don't know what these two
> lines mean so maybe it is actually related.
These lines were already there. I add ‘-D_GNU_SOURCE=1’ to allow builds
with current libc.
Overall a large part of the things in this patch series were already
there, only in a different form. :-)
Ludo’.
@@ -193,12 +193,11 @@ (define-public ghc-4
(sha256
(base32
"0ar4nxy4cr5vwvfj71gmc174vx0n3lg9ka05sa1k60c8z0g3xp1q"))
- (patches (list (search-patch "ghc-4.patch")))))
+ (patches (search-patches "ghc-4.patch"))))
(build-system gnu-build-system)
(supported-systems '("i686-linux" "x86_64-linux"))
(arguments
`(#:system "i686-linux"
- #:implicit-inputs? #f
#:strip-binaries? #f
#:phases
(modify-phases %standard-phases
@@ -223,8 +222,8 @@ (define-public ghc-4
#HsLibsFor=hugs
# Setting this leads to building the interpreter.
GhcHcOpts=-DDEBUG
-GhcRtsHcOpts=-optc-DDEBUG -optc-D__HUGS__ -unreg -optc-g
-GhcRtsCcOpts=-optc-DDEBUG -optc-g -optc-D__HUGS__
+GhcRtsHcOpts=-optc-DDEBUG -optc-D__HUGS__ -unreg -optc-g -optc-D_GNU_SOURCE=1
+GhcRtsCcOpts=-optc-DDEBUG -optc-g -optc-D__HUGS__ -optc-D_GNU_SOURCE=1
SplitObjs=NO
")))
@@ -247,8 +246,8 @@ (define-public ghc-4
;; this old linker understands.
(substitute* "ghc/interpreter/Makefile"
(("-lbfd -liberty")
- (string-append (assoc-ref inputs "binutils") "/lib/libbfd.a "
- (assoc-ref inputs "binutils") "/lib/libiberty.a")))
+ (string-append (search-input-file inputs "/lib/libbfd.a") " "
+ (search-input-file inputs "/lib/libiberty.a"))))
(let ((bash (which "bash")))
(substitute* '("configure.in"
@@ -271,7 +270,13 @@ (define-public ghc-4
(setenv "CONFIG_SHELL" bash)
(setenv "SHELL" bash))
- (setenv "CPP" (string-append (assoc-ref inputs "gcc") "/bin/cpp"))
+ ;; The 'hscpp' script invokes GCC 2.95's 'cpp' (RAWCPP), which
+ ;; segfaults unless passed '-x c'.
+ (substitute* "mk/config.mk.in"
+ (("-traditional")
+ "-traditional -x c"))
+
+ (setenv "CPP" (which "cpp"))
(invoke "autoreconf" "--verbose" "--force")))
(add-before 'configure 'configure-gmp
(lambda* (#:key build inputs outputs #:allow-other-keys)
@@ -283,6 +288,12 @@ (define-public ghc-4
(lambda* (#:key build inputs outputs #:allow-other-keys)
(let ((bash (which "bash"))
(out (assoc-ref outputs "out")))
+ (call-with-output-file "config.cache"
+ (lambda (port)
+ ;; GCC 2.95 fails to deal with anonymous unions in glibc's
+ ;; 'struct_rusage.h', so skip that.
+ (display "ac_cv_func_getrusage=no\n" port)))
+
(invoke bash "./configure"
"--enable-hc-boot"
(string-append "--prefix=" out)
@@ -290,14 +301,15 @@ (define-public ghc-4
(string-append "--host=" build)))))
(add-before 'build 'make-boot
(lambda _
+ ;; CLK_TCK has been removed from recent libc.
+ (substitute* "ghc/interpreter/nHandle.c"
+ (("CLK_TCK") "sysconf (_SC_CLK_TCK)"))
+
;; Only when building with more recent GCC
(when #false
;; GCC 2.95 is fine with these comments, but GCC 4.6 is not.
(substitute* "ghc/rts/universal_call_c.S"
- (("^# .*") ""))
- ;; CLK_TCK has been removed
- (substitute* "ghc/interpreter/nHandle.c"
- (("CLK_TCK") "sysconf(_SC_CLK_TCK)")))
+ (("^# .*") "")))
;; Only when using more recent Perl
(when #false
@@ -334,45 +346,21 @@ (define-public ghc-4
(copy-recursively "ghc/interpreter/lib" lib)
(install-file "ghc/interpreter/nHandle.so" lib)))))))
(native-inputs
- `(("findutils" ,findutils)
- ("tar" ,tar)
- ("bzip2" ,bzip2)
- ("xz" ,xz)
- ("diffutils" ,diffutils)
- ("file" ,file)
- ("gawk" ,gawk)
- ("autoconf" ,autoconf-2.13)
- ("automake" ,automake)
- ("bison" ,bison) ;for parser.y
+ (list autoconf-2.13
+ automake
+ bison ;for parser.y
- ("make" ,gnu-make)
- ("sed" ,sed)
- ("grep" ,grep)
- ("coreutils" ,coreutils)
- ("bash" ,bash-minimal)
+ ;; Needed to support lvalue casts.
+ gcc-2.95
- ("libc" ,glibc-2.2.5)
- ;; Lazily resolve binutils-mesboot in (gnu packages commencement) to
- ;; avoid a cycle.
- ("gcc-wrapper"
- ,(module-ref (resolve-interface
- '(gnu packages commencement))
- 'gcc-2.95-wrapper))
- ("gcc"
- ,(module-ref (resolve-interface
- '(gnu packages commencement))
- 'gcc-mesboot0))
- ("binutils"
- ,(module-ref (resolve-interface
- '(gnu packages commencement))
- 'binutils-mesboot))
- ("kernel-headers" ,linux-libre-headers)
+ ;; Use an older assembler to work around this error in GMP:
+ ;; Error: `%edx' not allowed with `testb'
+ binutils-2.33
- ;; TODO: Perl used to allow setting $* to enable multi-line
- ;; matching. If we want to use a more recent Perl we need to
- ;; patch all expressions that require multi-line matching. Hard
- ;; to tell.
- ("perl" ,perl-5.14)))
+ ;; TODO: Perl used to allow setting $* to enable multi-line
+ ;; matching. If we want to use a more recent Perl we need to patch
+ ;; all expressions that require multi-line matching. Hard to tell.
+ perl-5.14))
(home-page "https://www.haskell.org/ghc")
(synopsis "The Glasgow Haskell Compiler")
(description