guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

22/26: commencement: gcc-core-mesboot0: Support ARM.


From: guix-commits
Subject: 22/26: commencement: gcc-core-mesboot0: Support ARM.
Date: Sat, 9 Jan 2021 13:30:52 -0500 (EST)

janneke pushed a commit to branch wip-arm-bootstrap
in repository guix.

commit a3348bd8978ca04498d84415b67fb5760857b3a6
Author: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
AuthorDate: Wed Dec 23 09:50:05 2020 +0100

    commencement: gcc-core-mesboot0: Support ARM.
    
    * gnu/packages/patches/gcc-boot-2.95.3-arm.patch: New file.
    * gnu/local.mk (dist_patch_DATA): Add it.
    * gnu/packages/commencement.scm (gcc-core-mesboot0)[arguments]: Use it in
    "apply-patches" stage, renamed from "apply-boot-patch".  Parameterize
    configure-flags' --build,--host,--target.
    [supported-systems]: Add aarch64-linux, armhf-linux.
---
 gnu/local.mk                                   |   1 +
 gnu/packages/commencement.scm                  | 243 +++++++++++++------------
 gnu/packages/patches/gcc-boot-2.95.3-arm.patch | 229 +++++++++++++++++++++++
 3 files changed, 358 insertions(+), 115 deletions(-)

diff --git a/gnu/local.mk b/gnu/local.mk
index 67482b8..6bbeceb 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1009,6 +1009,7 @@ dist_patch_DATA =                                         
\
   %D%/packages/patches/gcc-arm-link-spec-fix.patch             \
   %D%/packages/patches/gcc-asan-missing-include.patch          \
   %D%/packages/patches/gcc-boot-2.95.3.patch                   \
+  %D%/packages/patches/gcc-boot-2.95.3-arm.patch               \
   %D%/packages/patches/gcc-boot-4.6.4.patch                    \
   %D%/packages/patches/gcc-cross-environment-variables.patch   \
   %D%/packages/patches/gcc-fix-texi2pod.patch                  \
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index fbab612..9f10210 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -1231,123 +1231,136 @@ $MES -e '(mescc)' module/mescc.scm -- \"$@\"
   ;; library, such as dir.h/struct DIR/readdir, locales, signals...  Also,
   ;; with gcc-2.95.3, binutils (2.14.0, 2.20.1a) and glibc-2.2.5 we found a
   ;; GNU toolchain triplet "that works".
-  (package
-    (inherit gcc)
-    (name "gcc-core-mesboot0")
-    (version "2.95.3")
-    (source (origin
-              (method url-fetch)
-              (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
-                                  version
-                                  ".tar.gz"))
-              ;; `patches' needs XZ
-              ;; (patches (search-patches "gcc-boot-2.95.3.patch"))
-              (sha256
-               (base32
-                "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
-    (supported-systems '("i686-linux" "x86_64-linux"))
-    (inputs '())
-    (propagated-inputs '())
-    (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
-                     ("binutils" ,binutils-mesboot0)
-                     ,@(%boot-tcc-inputs)))
-    (outputs '("out"))
-    (arguments
-     `(#:implicit-inputs? #f
-       #:guile ,%bootstrap-guile
-       #:tests? #f
-       #:parallel-build? #f
-       #:strip-binaries? #f
-       #:configure-flags
-       (let ((out (assoc-ref %outputs "out")))
-         `("--enable-static"
-           "--disable-shared"
-           "--disable-werror"
-           "--build=i686-unknown-linux-gnu"
-           "--host=i686-unknown-linux-gnu"
-           ,(string-append "--prefix=" out)))
-       #:make-flags
-       `("CC=tcc -static -D __GLIBC_MINOR__=6"
-         "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
-         "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
-         "AR=ar"
-         "RANLIB=ranlib"
-         ,(string-append "LIBGCC2_INCLUDES=-I "
-                         (assoc-ref %build-inputs "tcc")
-                         "/include")
-         "LANGUAGES=c"
-         ,(string-append "BOOT_LDFLAGS="
-                         " -B" (assoc-ref %build-inputs "tcc")
-                         "/lib/"))
-       #:modules ((guix build gnu-build-system)
-                  (guix build utils)
-                  (srfi srfi-1))
-       #:phases
-       (modify-phases %standard-phases
-         (add-after 'unpack 'apply-boot-patch
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let ((patch-file (assoc-ref inputs "boot-patch")))
-               (system* "patch" "--force" "-p1" "-i" patch-file)
-               #t)))
-         (add-before 'configure 'setenv
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((out (assoc-ref outputs "out"))
-                    (bash (assoc-ref %build-inputs "bash"))
-                    (shell (string-append bash "/bin/bash"))
-                    (tcc (assoc-ref %build-inputs "tcc"))
-                    (cppflags " -D __GLIBC_MINOR__=6"))
-               (setenv "CONFIG_SHELL" shell)
-               (setenv "CPPFLAGS" cppflags)
-               (setenv "CC" (string-append "tcc" cppflags))
-               (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags))
-               (setenv "CPP" (string-append "tcc -E" cppflags))
-               (with-output-to-file "config.cache"
-                 (lambda _
-                   (display "
+  (let ((triplet (match (%current-system)
+                   ((or "armhf-linux" "aarch64-linux")
+                    "arm-unknown-linux-gnu")
+                   ((or "i686-linux" "x86_64-linux")
+                    "i686-unknown-linux-gnu"))))
+    (package
+      (inherit gcc)
+      (name "gcc-core-mesboot0")
+      (version "2.95.3")
+      (source (origin
+                (method url-fetch)
+                (uri (string-append "mirror://gnu/gcc/gcc-2.95.3/gcc-core-"
+                                    version
+                                    ".tar.gz"))
+                ;; `patches' needs XZ
+                ;; (patches (search-patches "gcc-boot-2.95.3.patch"
+                ;;                          "gcc-boot-2.95.3-arm.patch"))
+                (sha256
+                 (base32
+                  "1xvfy4pqhrd5v2cv8lzf63iqg92k09g6z9n2ah6ndd4h17k1x0an"))))
+      (supported-systems '("armhf-linux" "aarch64-linux"
+                           "i686-linux" "x86_64-linux"))
+      (inputs '())
+      (propagated-inputs '())
+      (native-inputs `(("boot-patch" ,(search-patch "gcc-boot-2.95.3.patch"))
+                       ("arm-patch" ,(search-patch 
"gcc-boot-2.95.3-arm.patch"))
+                       ("binutils" ,binutils-mesboot0)
+                       ,@(%boot-tcc-inputs)))
+      (outputs '("out"))
+      (arguments
+       `(#:implicit-inputs? #f
+         #:guile ,%bootstrap-guile
+         #:tests? #f
+         #:parallel-build? #f
+         #:strip-binaries? #f
+         #:configure-flags
+         (let ((out (assoc-ref %outputs "out")))
+           (list "--enable-static"
+                 "--disable-shared"
+                 "--disable-werror"
+                 (string-append "--build=" ,triplet)
+                 (string-append "--host=" ,triplet)
+                 (string-append "--target=" ,triplet)
+                 (string-append "--prefix=" out)))
+         #:make-flags
+         `("CC=tcc -static -D __GLIBC_MINOR__=6"
+           "OLDCC=tcc -static -D __GLIBC_MINOR__=6"
+           "CC_FOR_BUILD=tcc -static -D __GLIBC_MINOR__=6"
+           "AR=ar"
+           "RANLIB=ranlib"
+           ,(string-append "LIBGCC2_INCLUDES=-I "
+                           (assoc-ref %build-inputs "tcc")
+                           "/include")
+           "LANGUAGES=c"
+           ,(string-append "BOOT_LDFLAGS="
+                           " -B" (assoc-ref %build-inputs "tcc")
+                           "/lib/"))
+         #:modules ((guix build gnu-build-system)
+                    (guix build utils)
+                    (srfi srfi-1))
+         #:phases
+         (modify-phases %standard-phases
+           (add-after 'unpack 'apply-patches
+             (lambda* (#:key inputs #:allow-other-keys)
+               (for-each
+                (lambda (name)
+                  (let ((patch (assoc-ref inputs name)))
+                    (invoke "patch" "-p1" "--force" "-i" patch)))
+                '("boot-patch"
+                  "arm-patch"))))
+           (add-before 'configure 'setenv
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((out (assoc-ref outputs "out"))
+                      (bash (assoc-ref %build-inputs "bash"))
+                      (shell (string-append bash "/bin/bash"))
+                      (tcc (assoc-ref %build-inputs "tcc"))
+                      (cppflags " -D __GLIBC_MINOR__=6"))
+                 (setenv "CONFIG_SHELL" shell)
+                 (setenv "CPPFLAGS" cppflags)
+                 (setenv "CC" (string-append "tcc" cppflags))
+                 (setenv "CC_FOR_BUILD" (string-append "tcc" cppflags))
+                 (setenv "CPP" (string-append "tcc -E" cppflags))
+                 (setenv "enable_threads" "single")
+                 (with-output-to-file "config.cache"
+                   (lambda _
+                     (display "
 ac_cv_c_float_format='IEEE (little-endian)'
 "))))))
-         ;; gcc-2.95.3
-         (replace 'configure           ; needs classic invocation of configure
-           (lambda* (#:key configure-flags  #:allow-other-keys)
-             (format (current-error-port)
-                     "running ./configure ~a\n" (string-join configure-flags))
-             (apply invoke "./configure" configure-flags)))
-         (add-after 'configure 'remove-info
-           (lambda _
-             ;; no info at this stage
-             (delete-file-recursively "texinfo")
-             (invoke "touch" "gcc/cpp.info" "gcc/gcc.info")))
-         (add-after 'install 'install2
-           (lambda* (#:key outputs #:allow-other-keys)
-             (let* ((tcc (assoc-ref %build-inputs "tcc"))
-                    (tcc-lib (string-append tcc "/lib/x86-mes-gcc"))
-                    (out (assoc-ref outputs "out"))
-                    (gcc-dir (string-append
-                              out 
"/lib/gcc-lib/i686-unknown-linux-gnu/2.95.3")))
-               (mkdir-p "tmp")
-               (with-directory-excursion "tmp"
-                 (invoke "ar" "x" (string-append "../gcc/libgcc2.a"))
-                 (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
-                 (apply invoke "ar" "r" (string-append gcc-dir "/libgcc.a")
-                        (find-files "." "\\.o")))
-               (copy-file "gcc/libgcc2.a" (string-append out "/lib/libgcc2.a"))
-               (copy-file (string-append tcc "/lib/libtcc1.a")
-                          (string-append out "/lib/libtcc1.a"))
-               (invoke "ar" "x" (string-append tcc "/lib/libtcc1.a"))
-               (invoke "ar" "x" (string-append tcc "/lib/libc.a"))
-               (invoke "ar" "r" (string-append gcc-dir "/libc.a")
-                       "libc.o" "libtcc1.o")
-               #t))))))
-    (native-search-paths
-     (list (search-path-specification
-            (variable "C_INCLUDE_PATH")
-            (files '("include"
-
-                     ;; Needed to get things like GCC's <stddef.h>.
-                     "lib/gcc-lib/i686-unknown-linux-gnu/2.95.3/include")))
-           (search-path-specification
-            (variable "LIBRARY_PATH")
-            (files '("lib")))))))
+           ;; gcc-2.95.3
+           (replace 'configure ; needs classic invocation of configure
+             (lambda* (#:key configure-flags  #:allow-other-keys)
+               (format (current-error-port)
+                       "running ./configure ~a\n" (string-join 
configure-flags))
+               (apply invoke "./configure" configure-flags)))
+           (add-after 'configure 'remove-info
+             (lambda _
+               ;; no info at this stage
+               (delete-file-recursively "texinfo")
+               (invoke "touch" "gcc/cpp.info" "gcc/gcc.info")))
+           (add-after 'install 'install2
+             (lambda* (#:key outputs #:allow-other-keys)
+               (let* ((tcc (assoc-ref %build-inputs "tcc"))
+                      (out (assoc-ref outputs "out"))
+                      (gcc-dir (string-append
+                                out "/lib/gcc-lib/" ,triplet "/2.95.3")))
+                 (mkdir-p "tmp")
+                 (with-directory-excursion "tmp"
+                   (invoke "ar" "x" (string-append "../gcc/libgcc2.a"))
+                   (invoke "ar" "x" (string-append tcc "/lib/tcc/libtcc1.a"))
+                   (copy-file "../gcc/libgcc.a" "libgcc.a")
+                   (apply invoke "ar" "r" "libgcc.a" (find-files "." "\\.o"))
+                   (copy-file "libgcc.a" (string-append gcc-dir "/libgcc.a")))
+                 (copy-file "gcc/libgcc2.a"
+                            (string-append out "/lib/libgcc2.a"))
+                 (copy-file (string-append tcc "/lib/tcc/libtcc1.a")
+                            (string-append out "/lib/libtcc1.a"))
+                 (invoke "ar" "x" (string-append tcc "/lib/tcc/libtcc1.a"))
+                 (invoke "ar" "x" (string-append tcc "/lib/libc.a"))
+                 (invoke "ar" "r" (string-append gcc-dir "/libc.a")
+                         "libc.o" "libtcc1.o")
+                 #t))))))
+      (native-search-paths
+       (list (search-path-specification
+              (variable "C_INCLUDE_PATH")
+              (files `("include"
+                       ;; Needed to get things like GCC's <stddef.h>.
+                       ,(string-append "lib/gcc-lib/" triplet 
"/2.95.3/include"))))
+             (search-path-specification
+              (variable "LIBRARY_PATH")
+              (files '("lib"))))))))
 
 (define (%boot-mesboot-core-inputs)
   `(("binutils" ,binutils-mesboot0)
diff --git a/gnu/packages/patches/gcc-boot-2.95.3-arm.patch 
b/gnu/packages/patches/gcc-boot-2.95.3-arm.patch
new file mode 100644
index 0000000..92e089e
--- /dev/null
+++ b/gnu/packages/patches/gcc-boot-2.95.3-arm.patch
@@ -0,0 +1,229 @@
+This patch enables building gcc-2.95.3 on armhf-linux using TCC and
+Mes C Library.
+
+  * Add include/asm/unist.h linux header.
+  * Disable libgcc2.c float and long long functions.
+
+Upstream status: Not presented upstream.
+
+--- gcc-2.95.3/gcc/libgcc2.c.orig      2020-12-23 07:40:48.730917496 +0100
++++ gcc-2.95.3/gcc/libgcc2.c   2020-12-23 07:42:25.520714866 +0100
+@@ -818,6 +781,8 @@
+ {
+   TFtype b;
+   UDItype v;
++#if !__arm__
++
+ 
+   if (a < 0)
+     return 0;
+@@ -837,6 +802,7 @@
+     v -= (USItype) (- a);
+   else
+     v += (USItype) a;
++#endif
+   return v;
+ }
+ #endif
+@@ -860,6 +826,8 @@
+ {
+   XFtype b;
+   UDItype v;
++#if !__arm__
++
+ 
+   if (a < 0)
+     return 0;
+@@ -879,6 +847,7 @@
+     v -= (USItype) (- a);
+   else
+     v += (USItype) a;
++#endif
+   return v;
+ }
+ #endif
+@@ -902,6 +871,8 @@
+ {
+   DFtype b;
+   UDItype v;
++#if !__arm__
++
+ 
+   if (a < 0)
+     return 0;
+@@ -921,6 +892,7 @@
+     v -= (USItype) (- a);
+   else
+     v += (USItype) a;
++#endif
+   return v;
+ }
+ #endif
+@@ -929,9 +901,13 @@
+ DItype
+ __fixdfdi (DFtype a)
+ {
++#if __arm__
++  return 0;
++#else
+   if (a < 0)
+     return - __fixunsdfdi (-a);
+   return __fixunsdfdi (a);
++#endif
+ }
+ #endif
+ 
+@@ -948,6 +924,8 @@
+   DFtype a = original_a;
+   DFtype b;
+   UDItype v;
++#if !__arm__
++
+ 
+   if (a < 0)
+     return 0;
+@@ -967,6 +945,7 @@
+     v -= (USItype) (- a);
+   else
+     v += (USItype) a;
++#endif
+   return v;
+ }
+ #endif
+@@ -975,9 +954,13 @@
+ DItype
+ __fixsfdi (SFtype a)
+ {
++#if __arm__
++  return 0;
++#else
+   if (a < 0)
+     return - __fixunssfdi (-a);
+   return __fixunssfdi (a);
++#endif
+ }
+ #endif
+ 
+@@ -990,12 +973,15 @@
+ __floatdixf (DItype u)
+ {
+   XFtype d;
++#if !__arm__
++
+ 
+   d = (SItype) (u >> WORD_SIZE);
+   d *= HIGH_HALFWORD_COEFF;
+   d *= HIGH_HALFWORD_COEFF;
+   d += (USItype) (u & (HIGH_WORD_COEFF - 1));
+ 
++#endif
+   return d;
+ }
+ #endif
+@@ -1009,12 +995,15 @@
+ __floatditf (DItype u)
+ {
+   TFtype d;
++#if !__arm__
++
+ 
+   d = (SItype) (u >> WORD_SIZE);
+   d *= HIGH_HALFWORD_COEFF;
+   d *= HIGH_HALFWORD_COEFF;
+   d += (USItype) (u & (HIGH_WORD_COEFF - 1));
+ 
++#endif
+   return d;
+ }
+ #endif
+@@ -1028,12 +1017,15 @@
+ __floatdidf (DItype u)
+ {
+   DFtype d;
++#if !__arm__
++
+ 
+   d = (SItype) (u >> WORD_SIZE);
+   d *= HIGH_HALFWORD_COEFF;
+   d *= HIGH_HALFWORD_COEFF;
+   d += (USItype) (u & (HIGH_WORD_COEFF - 1));
+ 
++#endif
+   return d;
+ }
+ #endif
+@@ -1079,6 +1071,8 @@
+      so that we don't lose any of the precision of the high word
+      while multiplying it.  */
+   DFtype f;
++#if !__arm__
++
+ 
+   /* Protect against double-rounding error.
+      Represent any low-order bits, that might be truncated in DFmode,
+@@ -1102,6 +1096,7 @@
+   f *= HIGH_HALFWORD_COEFF;
+   f += (USItype) (u & (HIGH_WORD_COEFF - 1));
+ 
++#endif
+   return (SFtype) f;
+ }
+ #endif
+@@ -1122,8 +1117,10 @@
+ USItype
+ __fixunsxfsi (XFtype a)
+ {
+-  if (a >= - (DFtype) LONG_MIN)
++ #if !__arm__
++ if (a >= - (DFtype) LONG_MIN)
+     return (SItype) (a + LONG_MIN) - LONG_MIN;
++#endif
+   return (SItype) a;
+ }
+ #endif
+@@ -1144,8 +1141,10 @@
+ USItype
+ __fixunsdfsi (DFtype a)
+ {
+-  if (a >= - (DFtype) LONG_MIN)
++ #if !__arm__
++ if (a >= - (DFtype) LONG_MIN)
+     return (SItype) (a + LONG_MIN) - LONG_MIN;
++#endif
+   return (SItype) a;
+ }
+ #endif
+@@ -1166,8 +1165,10 @@
+ USItype
+ __fixunssfsi (SFtype a)
+ {
++#if !__arm__
+   if (a >= - (SFtype) LONG_MIN)
+     return (SItype) (a + LONG_MIN) - LONG_MIN;
++#endif
+   return (SItype) a;
+ }
+ #endif
+--- gcc-2.95.3/include/asm/unistd.h.orig       1970-01-01 01:00:00.000000000 
+0100
++++ gcc-2.95.3/include/asm/unistd.h    2020-12-23 07:49:44.156673879 +0100
+@@ -0,0 +1,9 @@
++#ifndef __ASM_UNISTD_H
++#define  __ASM_UNISTD_H
++
++#if __arm__
++#define __NR_getpid 0x14
++#define __NR_kill 0x25
++#endif
++
++#endif // __ASM_UNISTD_H
+--- gcc-2.95.3/gcc/Makefile.in.orig    2020-12-23 08:31:57.733501802 +0100
++++ gcc-2.95.3/gcc/Makefile.in 2020-12-23 08:31:49.985371208 +0100
+@@ -1260,7 +1260,7 @@
+       -(cd tmpcopy; chmod +w * > /dev/null 2>&1)
+       (cd tmpcopy; $(AR_FOR_TARGET) x ../$(LIBGCC2))
+       (cd tmpcopy; $(AR_FOR_TARGET) $(AR_FLAGS_FOR_TARGET) ../tmplibgcc.a 
*$(objext))
+-      rm -rf libgcc2.a tmpcopy
++      rm -rf tmpcopy
+       if $(RANLIB_TEST_FOR_TARGET) ; then \
+         $(RANLIB_FOR_TARGET) tmplibgcc.a; \
+       else true; fi



reply via email to

[Prev in Thread] Current Thread [Next in Thread]