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

From: Ludovic Courtès <[email-masked]>
Date: Sat, 12 Feb 2022 22:45:30 +0100

* gnu/packages/gcc.scm (gcc-2.95): New variable.
---
 gnu/packages/gcc.scm | 71 +++++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 70 insertions(+), 1 deletion(-)

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 <[email-masked]>
+;;; Copyright © 2012-2022 Ludovic Courtès <[email-masked]>
 ;;; Copyright © 2014, 2015, 2018 Mark H Weaver <[email-masked]>
 ;;; Copyright © 2014, 2015, 2016, 2017, 2019, 2021 Ricardo Wurmus <[email-masked]>
 ;;; Copyright © 2015 Andreas Enge <[email-masked]>
@@ -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."
-- 
2.34.0