diff mbox series

[bug#53964,2/4] gnu: gcc: Add 2.95.

Message ID 20220212214532.23087-2-ludo@gnu.org
State Accepted
Headers show
Series Build nhc98 and ghc@4 with regular dependencies | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Ludovic Courtès Feb. 12, 2022, 9:45 p.m. UTC
* gnu/packages/gcc.scm (gcc-2.95): New variable.
---
 gnu/packages/gcc.scm | 71 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)

Comments

M Feb. 12, 2022, 10:35 p.m. UTC | #1
Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
> +               (replace 'configure
> +                 (lambda* (#:key outputs build configure-flags
> +                           #:allow-other-keys)
> +                   ;; It's an old 'configure' script so it needs some help.
> +                   (let ((out (assoc-ref outputs "out")))

Input labels (well, ‘output labels’) can be removed here to a degree:

(lambda* (#:key build configure-flags #:allow-other-keys)
  ;; [...]
  (define out #$output)
  (setenv "CONFIG_SHELL" [...])
  [...])

Greetings,
Maxime.
M Feb. 12, 2022, 10:37 p.m. UTC | #2
Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
> +                     (apply invoke "./configure"
> +                            (string-append "--prefix=" out)
> +                            (string-append "--build=" build)
> +                            (string-append "--host=" build)
> +                            configure-flags))))

Seems incorrect when gcc is being cross-compiled, "--build" or "--host"
(I always forget which) should be set to 'target' (in the Guix sense,
not the autools sense).

Or perhaps it doesn't matter since #:system is always "i686-linux" ...

Greetings,
Maxime.
M Feb. 12, 2022, 10:40 p.m. UTC | #3
Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
> +               (add-before 'configure 'remove-bundled-texinfo
> +                 (lambda _
> +                   ;; Do not build the bundled Texinfo.
> +                   (delete-file-recursively "texinfo")

Unbundling seems more something for a source snippet to me,
since it's ‘cleaning up’ the source code.  ‘(guix)Snipppets versus
Phases’ also says:

The boundary between using an origin snippet versus a build phase to
modify the sources of a package can be elusive.  Origin snippets are
typically used to remove unwanted files such as bundled libraries,
[...]

Greetings,
Maxime.
M Feb. 12, 2022, 10:43 p.m. UTC | #4
Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
> +    (native-inputs (list texinfo))
> [...]
> +                   ;; Go ahead despite the many warnings.
> +                   (substitute* '("Makefile.in" "gcc/Makefile.in")
> +                     (("^MAKEINFOFLAGS =.*")
> +                      "MAKEINFOFLAGS = --force\n")))))))

FWIW, since gcc@2.95 is an ancient version of gcc only used for
bootstrapping, personally I would not bother with building the
documentation.

OTOH, there have been quite some changes in gcc, and the documentation
isn't getting in the way of anyone not interested in it ...

Greetings,
Maxime.
M Feb. 12, 2022, 10:45 p.m. UTC | #5
Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
> +    (native-search-paths
> +     (list (search-path-specification
> +            (variable "C_INCLUDE_PATH")
> +            (files '("include")))
> +           (search-path-specification
> +            (variable "LIBRARY_PATH")
> +            (files '("lib")))))))

Perhaps a comment

  ;; version 2.95 of gcc@ only supports C, so no CPLUS_INCLUDE_PATH

would be useful to answer the question of why the search paths are
overridden?

Greetings,
Maxime
M Feb. 12, 2022, 10:47 p.m. UTC | #6
Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
> +           #:tests? #f

Why are tests disabled here?

Greetings,
Maxime.
Ludovic Courtès Feb. 14, 2022, 9:23 a.m. UTC | #7
Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
>> +                     (apply invoke "./configure"
>> +                            (string-append "--prefix=" out)
>> +                            (string-append "--build=" build)
>> +                            (string-append "--host=" build)
>> +                            configure-flags))))
>
> Seems incorrect when gcc is being cross-compiled, "--build" or "--host"
> (I always forget which) should be set to 'target' (in the Guix sense,
> not the autools sense).
>
> Or perhaps it doesn't matter since #:system is always "i686-linux" ...

Right, it probably cannot be cross-compiled and that’s fine.

(For some reason this old ‘configure’ script needed both ‘--build’ and
‘--host’.)

Ludo’.
Ludovic Courtès Feb. 14, 2022, 9:25 a.m. UTC | #8
Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
>> +               (add-before 'configure 'remove-bundled-texinfo
>> +                 (lambda _
>> +                   ;; Do not build the bundled Texinfo.
>> +                   (delete-file-recursively "texinfo")
>
> Unbundling seems more something for a source snippet to me,
> since it's ‘cleaning up’ the source code.

Right I’ll move it there.

(The bundled texinfo was a surprise to me; it actually builds but seems
to be broken in some way.)

Ludo’.
Ludovic Courtès Feb. 14, 2022, 9:26 a.m. UTC | #9
Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
>> +    (native-search-paths
>> +     (list (search-path-specification
>> +            (variable "C_INCLUDE_PATH")
>> +            (files '("include")))
>> +           (search-path-specification
>> +            (variable "LIBRARY_PATH")
>> +            (files '("lib")))))))
>
> Perhaps a comment
>
>   ;; version 2.95 of gcc@ only supports C, so no CPLUS_INCLUDE_PATH
>
> would be useful to answer the question of why the search paths are
> overridden?

Good idea, will do!
Ludovic Courtès Feb. 14, 2022, 9:33 a.m. UTC | #10
Maxime Devos <maximedevos@telenet.be> skribis:

> Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
>> +           #:tests? #f
>
> Why are tests disabled here?

That’s the same for all the GCC variants, including ‘gcc-core-mesboot0’,
which was the inspiration for this one.  I think the main reason is that
“it’s difficult” (there’s a dependency on DejaGNU, the fact that you
cannot expect all tests to pass, and the fact that many tests would
probably need to be adjusted.)

In this case I didn’t even try, but since it’s an ancient package, it’s
even more likely to be problematic, and since it’s only used for
bootstrapping, I would not bother as long as it’s good enough to build
ghc@4.

Thoughts?

Ludo’.
Ludovic Courtès Feb. 14, 2022, 11:22 a.m. UTC | #11
Ludovic Courtès <ludo@gnu.org> skribis:

> Maxime Devos <maximedevos@telenet.be> skribis:
>
>> Ludovic Courtès schreef op za 12-02-2022 om 22:45 [+0100]:
>>> +           #:tests? #f
>>
>> Why are tests disabled here?
>
> That’s the same for all the GCC variants, including ‘gcc-core-mesboot0’,
> which was the inspiration for this one.  I think the main reason is that
> “it’s difficult” (there’s a dependency on DejaGNU, the fact that you
> cannot expect all tests to pass, and the fact that many tests would
> probably need to be adjusted.)

So I tried out of curiosity and was surprised to see that ‘make check’
succeeds!  It’s not entirely clear how many tests were run though since
DejaGNU isn’t very talkative:

--8<---------------cut here---------------start------------->8---
Test run by nixbld on Mon Feb 14 11:21:04 2022
Native configuration is i686-unknown-linux-gnu
Test run by nixbld on Mon Feb 14 11:21:04 2022

		=== gcc tests ===

Native configuration is i686-unknown-linux-gnu

		=== g77 tests ===

Schedule of variations:
WARNING: Couldn't find tool init file
    unix


[...]


		=== g++ Summary ===

make[1]: Leaving directory '/tmp/guix-build-gcc-2.95.3.drv-0/gcc-2.95.3/gcc'
/gnu/store/7s2zlc4r9wqvlh9x2gqmzm4lnmbsdzmn-bash-minimal-5.1.8/bin/sh ./regress-demangle ./demangle-expected
All 616 tests passed
make[2]: Leaving directory '/tmp/guix-build-gcc-2.95.3.drv-0/gcc-2.95.3/libiberty/testsuite'
make[1]: Leaving directory '/tmp/guix-build-gcc-2.95.3.drv-0/gcc-2.95.3/libiberty'
--8<---------------cut here---------------end--------------->8---

Anyway, it can’t hurt.

I also found that building in parallel is reliable enough.

Ludo’.
diff mbox series

Patch

diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index efa0baeaa1..2f947e4322 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -1,5 +1,5 @@ 
 ;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus <rekado@elephly.net>
 ;;; Copyright © 2015 Andreas Enge <andreas@enge.fr>
@@ -641,6 +641,75 @@  (define-public gcc-11
 ;;       the gcc-toolchain-* definitions.
 (define-public gcc gcc-10)
 
+
+;;;
+;;; Historical version.
+;;;
+
+(define-public gcc-2.95
+  ;; Note: 'gcc-core-mesboot0' in commencement.scm provides 2.95 as well, but
+  ;; with additional tricks to support compilation with TinyCC and Mes-libc.
+  (package
+    (inherit gcc)
+    (version "2.95.3")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
+    (supported-systems '("i686-linux" "x86_64-linux"))
+    (native-inputs (list texinfo))
+    (inputs '())
+    (propagated-inputs '())
+    (outputs '("out"))
+    (arguments
+     (list #:system "i686-linux"                ;x86_64 didn't exist back then
+           #:tests? #f
+           #:parallel-build? #f
+           #:configure-flags #~'("--disable-werror")
+
+           #:phases
+           #~(modify-phases %standard-phases
+               (add-before 'configure 'set-dynamic-linker-file-name
+                 (lambda* (#:key inputs #:allow-other-keys)
+                   ;; Tell GCC what the real loader file name is.
+                   (substitute* "gcc/config/i386/linux.h"
+                     (("/lib/ld-linux\\.so\\.[12]")
+                      (search-input-file inputs "/lib/ld-linux.so.2")))))
+               (replace 'configure
+                 (lambda* (#:key outputs build configure-flags
+                           #:allow-other-keys)
+                   ;; It's an old 'configure' script so it needs some help.
+                   (let ((out (assoc-ref outputs "out")))
+                     (setenv "CONFIG_SHELL" (which "sh"))
+                     (apply invoke "./configure"
+                            (string-append "--prefix=" out)
+                            (string-append "--build=" build)
+                            (string-append "--host=" build)
+                            configure-flags))))
+               (add-before 'configure 'remove-bundled-texinfo
+                 (lambda _
+                   ;; Do not build the bundled Texinfo.
+                   (delete-file-recursively "texinfo")
+                   (substitute* "configure"
+                     (("host_tools=(.*)texinfo" _ before)
+                      (string-append "host_tools=" before)))
+
+                   ;; Go ahead despite the many warnings.
+                   (substitute* '("Makefile.in" "gcc/Makefile.in")
+                     (("^MAKEINFOFLAGS =.*")
+                      "MAKEINFOFLAGS = --force\n")))))))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "C_INCLUDE_PATH")
+            (files '("include")))
+           (search-path-specification
+            (variable "LIBRARY_PATH")
+            (files '("lib")))))))
+
+
 (define-public (make-libstdc++ gcc)
   "Return a libstdc++ package based on GCC.  The primary use case is when
 using compilers other than GCC."