diff mbox

gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu.

Message ID 7ta8ci68s3.fsf@gmail.com
State New
Headers show

Commit Message

Carlos Sánchez de La Lama Nov. 29, 2016, 7:32 a.m. UTC
* gnu/packages/bootstrap.scm (glib-dynamic-linker): Add value for
* gnu/packages/linux.scm (system->defconfig): New procedure.
(linux-libre-headers): Use system->defconfig.
* gnu/packages/cross-base.scm (xlinux-headers): Use system->defconfig.
* gnu/packages/gcc.scm (gcc-4.7): Add powerpc specific substitutions for
dynamic linker and start files locations.
* gnu/packages/make-bootstrap.scm (%gcc-static): Remove -lgcc_s added in
powerpc specific substitutions.
 gnu/packages/bootstrap.scm      |  1 +
 gnu/packages/cross-base.scm     |  3 ++-
 gnu/packages/gcc.scm            | 18 ++++++++++++++++--
 gnu/packages/linux.scm          | 15 ++++++++++++---
 gnu/packages/make-bootstrap.scm |  5 +++--
 5 files changed, 34 insertions(+), 8 deletions(-)


Carlos Sánchez de La Lama Nov. 29, 2016, 7:38 a.m. UTC | #1

I finally found some time to clean-up my work. This patch is for
core-updates branch, and allows bootstrap tarball generation by

guix build --target=powerpc-linux-gnu bootstrap-tarballs

I think the best way to proceed is integrate this onto core-updates
(once reviewed & approved), then generate a bootstrap binaries on hydra,
making them available for download on the bootstrap binaries URL. At
that point I can update the rest of the powerpc-linux-gnu patches (which
use this binaries) with the correct hashes, and send them to the list.

As Ludo suggested, I am also preparing a tutorial/blog on the porting


diff mbox


diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
index f6faba3..64a8239 100644
--- a/gnu/packages/bootstrap.scm
+++ b/gnu/packages/bootstrap.scm
@@ -168,6 +168,7 @@  successful, or false to signal an error."
         ((string=? system "i586-gnu") "/lib/ld.so.1")
         ((string=? system "i686-gnu") "/lib/ld.so.1")
         ((string=? system "aarch64-linux") "/lib/ld-linux-aarch64.so.1")
+        ((string=? system "powerpc-linux") "/lib/ld.so.1")
         ;; XXX: This one is used bare-bones, without a libc, so add a case
         ;; here just so we can keep going.
diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index e6553dc..bfff1f2 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -315,7 +315,8 @@  GCC that does not target a libc; otherwise, target that libc."
               (setenv "ARCH" ,(system->linux-architecture target))
               (format #t "`ARCH' set to `~a' (cross compiling)~%" (getenv "ARCH"))
-              (and (zero? (system* "make" "defconfig"))
+              (and (zero? (system* "make"
+                                   ,(system->defconfig target)))
                    (zero? (system* "make" "mrproper" "headers_check"))))
       (native-inputs `(("cross-gcc" ,xgcc)
diff --git a/gnu/packages/gcc.scm b/gnu/packages/gcc.scm
index c26cc4f..cb53272 100644
--- a/gnu/packages/gcc.scm
+++ b/gnu/packages/gcc.scm
@@ -211,7 +211,7 @@  where the OS part is overloaded to denote a specific ABI---into GCC
                 ;; Fix the dynamic linker's file name.
                 (substitute* (find-files "gcc/config"
-                                         "^(linux|gnu)(64|-elf|-eabi)?\\.h$")
+                                         "^(linux|gnu|sysv4)(64|-elf|-eabi)?\\.h$")
                   (("#define GLIBC_DYNAMIC_LINKER([^ ]*).*$" _ suffix)
                    (format #f "#define GLIBC_DYNAMIC_LINKER~a \"~a\"~%"
@@ -240,7 +240,21 @@  where the OS part is overloaded to denote a specific ABI---into GCC
                    (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
-                           libc line))))
+                           libc line)))
+              ;; rs6000 (a.k.a. powerpc) config in gcc does not use
+              ;; GNU_USER_* defines. Do the above for this case.
+              (substitute*
+                  "gcc/config/rs6000/sysv4.h"
+                (("#define LIB_LINUX_SPEC (.*)$" _ suffix)
+                 (format #f "#define LIB_LINUX_SPEC \
+\"-L~a/lib %{!static:-rpath=~a/lib %{!static-libgcc:-rpath=~a/lib -lgcc_s}} \" ~a"
+                         libc libc libdir suffix))
+                (("#define	STARTFILE_LINUX_SPEC.*$" line)
+                 (format #f "#define STANDARD_STARTFILE_PREFIX_1 \"~a/lib\"
+                         libc line))))
               ;; Don't retain a dependency on the build-time sed.
               (substitute* "fixincludes/fixincl.x"
diff --git a/gnu/packages/linux.scm b/gnu/packages/linux.scm
index c504a12..57c11f3 100644
--- a/gnu/packages/linux.scm
+++ b/gnu/packages/linux.scm
@@ -98,6 +98,13 @@ 
           ((string-prefix? "aarch64" arch) "arm64")
           (else arch))))
+(define-public (system->defconfig system)
+  "Some systems (notably powerpc-linux) require a special target for kernel
+defconfig. Return the appropiate make target if applicable, otherwise return
+  (cond ((string-prefix? "powerpc-" system) "pmac32_defconfig")
+        (else "defconfig")))
 (define (linux-libre-urls version)
   "Return a list of URLs for Linux-Libre VERSION."
   (list (string-append
@@ -137,11 +144,13 @@ 
            (lambda _
              (let ((arch ,(system->linux-architecture
                           (or (%current-target-system)
-                              (%current-system)))))
+                              (%current-system))))
+                   (defconfig ,(system->defconfig
+                               (or (%current-target-system)
+                                   (%current-system)))))
                (setenv "ARCH" arch)
                (format #t "`ARCH' set to `~a'~%" (getenv "ARCH"))
-               (and (zero? (system* "make" "defconfig"))
+               (and (zero? (system* "make" defconfig))
                     (zero? (system* "make" "mrproper" "headers_check"))))))
          (replace 'install
            (lambda* (#:key outputs #:allow-other-keys)
diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index f31db6a..b4771a7 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -441,8 +441,9 @@  for `sh' in $PATH, and without nscd, and with static NSS modules."
                  ;; the 'pre-configure phase of our main gcc package, because
                  ;; that shared library is not present in this static gcc.  See
                  ;; <https://lists.gnu.org/archive/html/guix-devel/2015-01/msg00008.html>.
-                 (substitute* (find-files "gcc/config"
-                                          "^gnu-user.*\\.h$")
+                 (substitute* (cons* "gcc/config/rs6000/sysv4.h"
+                                     (find-files "gcc/config"
+                                                 "^gnu-user.*\\.h$"))
                    ((" -lgcc_s}}") "}}")))