unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu.
@ 2016-11-29  7:32 Carlos Sánchez de La Lama
  2016-11-29  7:38 ` Carlos Sánchez de La Lama
  2017-01-04 23:02 ` Ludovic Courtès
  0 siblings, 2 replies; 5+ messages in thread
From: Carlos Sánchez de La Lama @ 2016-11-29  7:32 UTC (permalink / raw)
  To: guix-devel


* gnu/packages/bootstrap.scm (glib-dynamic-linker): Add value for
powerpc-linux.
* 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(-)

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"))))
             ,phases))))
       (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\"~%"
                            suffix
@@ -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\"
 #define STANDARD_STARTFILE_PREFIX_2 \"\"
 ~a"
-                           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\"
+#define STANDARD_STARTFILE_PREFIX_2 \"\"
+~a"
+                         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
+\"defconfig\"."
+  (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}}") "}}")))
                ,phases)))))
      (native-inputs
-- 
2.9.2

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu.
  2016-11-29  7:32 [PATCH] gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu Carlos Sánchez de La Lama
@ 2016-11-29  7:38 ` Carlos Sánchez de La Lama
  2017-01-04 23:02 ` Ludovic Courtès
  1 sibling, 0 replies; 5+ messages in thread
From: Carlos Sánchez de La Lama @ 2016-11-29  7:38 UTC (permalink / raw)
  To: guix-devel

Hi!

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
process.

BR

Carlos

-- 
It is better to be lucky. But I would rather be exact. Then, when luck comes
you are ready.

Ernest Hemingway, "The Old Man and the Sea" (1952)

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu.
  2016-11-29  7:32 [PATCH] gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu Carlos Sánchez de La Lama
  2016-11-29  7:38 ` Carlos Sánchez de La Lama
@ 2017-01-04 23:02 ` Ludovic Courtès
  2017-01-05  8:35   ` Carlos Sánchez de La Lama
  1 sibling, 1 reply; 5+ messages in thread
From: Ludovic Courtès @ 2017-01-04 23:02 UTC (permalink / raw)
  To: Carlos Sánchez de La Lama; +Cc: guix-devel

Hello Carlos!

Happy new year!  :-)

Leo just reminded me of this patch on IRC, and I feel guilty that it
stood there for so long.  Apologies!

csanchezdll@gmail.com (Carlos Sánchez de La Lama) skribis:

> * gnu/packages/bootstrap.scm (glib-dynamic-linker): Add value for
> powerpc-linux.
> * 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.

I ended up splitting it in 3 patches (gcc, linux-libre, and
glibc-dynamic-linker) that I just pushed to ‘core-updates’.  I also
added copyright lines for you where appropriate.  Hope that’s fine!

> 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.

Sounds like a good plan.

Commit 9410a5aa916035bb4d7f032a5fe81cfb497887c8 adds powerpc-linux-gnu
cross-builds for Hydra (though Hydra is currently busy with the
‘staging’ branch.)

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

Awesome!

Sorry again for the delay and the frustration it probably entailed.

Cheers,
Ludo’.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu.
  2017-01-04 23:02 ` Ludovic Courtès
@ 2017-01-05  8:35   ` Carlos Sánchez de La Lama
  2017-01-05 10:32     ` Ludovic Courtès
  0 siblings, 1 reply; 5+ messages in thread
From: Carlos Sánchez de La Lama @ 2017-01-05  8:35 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hi Ludo!

> Happy new year!  :-)

Thanks! Happy new year!

> I ended up splitting it in 3 patches (gcc, linux-libre, and
> glibc-dynamic-linker) that I just pushed to ‘core-updates’.  I also
> added copyright lines for you where appropriate.  Hope that’s fine!

Thats perfect :)

>> 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.
>
> Sounds like a good plan.
>
> Commit 9410a5aa916035bb4d7f032a5fe81cfb497887c8 adds powerpc-linux-gnu
> cross-builds for Hydra (though Hydra is currently busy with the
> ‘staging’ branch.)

Nice! I will generate the bootstrap tarballs locally using that commit
to check everything target-side works, before hydra time is spent on
that. If everything goes all right, I will then update the powerpc
patches with the new hashes (and the expected URL for the binaries), so
any powerpc user can jump in and use/test GUIX.

>> As Ludo suggested, I am also preparing a tutorial/blog on the porting
>> process.
>
> Awesome!

It is getting a little bit more complex than expected, and my time
allowance also shorter. I am writting a set of "steps" on how I made the
porting, including all the debugging I had to do, so what is already
written might be useful as it is (not only as a porting guide but also
as an example of GUIX hacking). Do you think it makes sense to publish
it already so I can complete it later? Or better wait till it is
finished?

> Sorry again for the delay and the frustration it probably entailed.

Do not worry. I know how it is with a lot of patches coming in :). I
needed (and still need more) time for writing the tutorial anyways.

Thanks!

-- 
Carlos

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu.
  2017-01-05  8:35   ` Carlos Sánchez de La Lama
@ 2017-01-05 10:32     ` Ludovic Courtès
  0 siblings, 0 replies; 5+ messages in thread
From: Ludovic Courtès @ 2017-01-05 10:32 UTC (permalink / raw)
  To: Carlos Sánchez de La Lama; +Cc: guix-devel

Hi!

csanchezdll@gmail.com (Carlos Sánchez de La Lama) skribis:

>> I ended up splitting it in 3 patches (gcc, linux-libre, and
>> glibc-dynamic-linker) that I just pushed to ‘core-updates’.  I also
>> added copyright lines for you where appropriate.  Hope that’s fine!
>
> Thats perfect :)
>
>>> 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.
>>
>> Sounds like a good plan.
>>
>> Commit 9410a5aa916035bb4d7f032a5fe81cfb497887c8 adds powerpc-linux-gnu
>> cross-builds for Hydra (though Hydra is currently busy with the
>> ‘staging’ branch.)
>
> Nice! I will generate the bootstrap tarballs locally using that commit
> to check everything target-side works, before hydra time is spent on
> that. If everything goes all right, I will then update the powerpc
> patches with the new hashes (and the expected URL for the binaries), so
> any powerpc user can jump in and use/test GUIX.

Sounds good!

>>> As Ludo suggested, I am also preparing a tutorial/blog on the porting
>>> process.
>>
>> Awesome!
>
> It is getting a little bit more complex than expected, and my time
> allowance also shorter. I am writting a set of "steps" on how I made the
> porting, including all the debugging I had to do, so what is already
> written might be useful as it is (not only as a porting guide but also
> as an example of GUIX hacking). Do you think it makes sense to publish
> it already so I can complete it later? Or better wait till it is
> finished?

Up to you!  If you have something that’s self-contained and intelligible
to people who don’t have your experience, that’s probably fine.

Cheers,
Ludo’.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-01-05 10:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-29  7:32 [PATCH] gnu: bootstrap-tarballs: Cross-compile for powerpc-linux-gnu Carlos Sánchez de La Lama
2016-11-29  7:38 ` Carlos Sánchez de La Lama
2017-01-04 23:02 ` Ludovic Courtès
2017-01-05  8:35   ` Carlos Sánchez de La Lama
2017-01-05 10:32     ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).