unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
* [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
@ 2015-06-30 10:14 Manolis Ragkousis
  2015-06-30 19:56 ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Manolis Ragkousis @ 2015-06-30 10:14 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 281 bytes --]

Καλημέρα

I chose this approach in %glibc-stripped because later on, as more
things will be needed to be Hurd-specific, it's going to get messy
with conditional code. This way we can safely change/add things
without worrying it will break the other. WDYT?

Manolis

[-- Attachment #2: 0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch --]
[-- Type: text/x-patch, Size: 10108 bytes --]

From fa84fdeb8a479f3b59b38f762f551d744def2e5f Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Tue, 30 Jun 2015 12:53:24 +0300
Subject: [PATCH] gnu: make-bootstrap: Produce the correct
 %glibc-bootstrap-tarball for Hurd systems.

* gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
  (%glibc-stripped): Make it a procedure that produces the correct %glibc-stripped
  depending on the target system.
---
 gnu/packages/make-bootstrap.scm | 164 +++++++++++++++++++++++++---------------
 1 file changed, 102 insertions(+), 62 deletions(-)

diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index 3d43421..f9b8026 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -33,6 +33,7 @@
   #:use-module (gnu packages guile)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages multiprecision)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
@@ -327,68 +328,107 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("binutils" ,%binutils-static)))))
 
-(define %glibc-stripped
+(define (%glibc-stripped target) 
   ;; GNU libc's essential shared libraries, dynamic linker, and headers,
   ;; with all references to store directories stripped.  As a result,
   ;; libc.so is unusable and need to be patched for proper relocation.
-  (let ((glibc (glibc-for-bootstrap)))
-    (package (inherit glibc)
-      (name "glibc-stripped")
-      (build-system trivial-build-system)
-      (arguments
-       `(#:modules ((guix build utils))
-         #:builder
-         (begin
-           (use-modules (guix build utils))
-
-           (setvbuf (current-output-port) _IOLBF)
-           (let* ((out    (assoc-ref %outputs "out"))
-                  (libdir (string-append out "/lib"))
-                  (incdir (string-append out "/include"))
-                  (libc   (assoc-ref %build-inputs "libc"))
-                  (linux  (assoc-ref %build-inputs "linux-headers")))
-             (mkdir-p libdir)
-             (for-each (lambda (file)
-                         (let ((target (string-append libdir "/"
-                                                      (basename file))))
-                           (copy-file file target)
-                           (remove-store-references target)))
-                       (find-files (string-append libc "/lib")
-                                   "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
-             (copy-recursively (string-append libc "/include") incdir)
-
-             ;; Copy some of the Linux-Libre headers that glibc headers
-             ;; refer to.
-             (mkdir (string-append incdir "/linux"))
-             (for-each (lambda (file)
-                         (copy-file (string-append linux "/include/linux/" file)
-                                    (string-append incdir "/linux/"
-                                                   (basename file))))
-                       '("limits.h" "errno.h" "socket.h" "kernel.h"
-                         "sysctl.h" "param.h" "ioctl.h" "types.h"
-                         "posix_types.h" "stddef.h"))
-
-             (copy-recursively (string-append linux "/include/asm")
-                               (string-append incdir "/asm"))
-             (copy-recursively (string-append linux "/include/asm-generic")
-                               (string-append incdir "/asm-generic"))
-
-             ;; Remove the '.install' and '..install.cmd' files; the latter
-             ;; contains store paths, which prevents bit reproducibility.
-             (for-each delete-file (find-files incdir "\\.install"))
-
-             #t))))
-      (inputs `(("libc" ,(let ((target (%current-target-system)))
-                           (if target
-                               (glibc-for-bootstrap
-                                (parameterize ((%current-target-system #f))
-                                  (cross-libc target)))
-                               glibc)))
-                ("linux-headers" ,linux-libre-headers)))
-
-      ;; Only one output.
-      (outputs '("out")))))
+  (match target
+    ("i586-pc-gnu"
+     (let ((glibc (glibc-for-bootstrap)))
+       (package (inherit glibc/hurd)
+        (name "glibc-stripped")
+        (build-system trivial-build-system)
+        (arguments
+         `(#:modules ((guix build utils))
+           #:builder
+           (begin
+             (use-modules (guix build utils))
+
+             (setvbuf (current-output-port) _IOLBF)
+             (let* ((out    (assoc-ref %outputs "out"))
+                    (libdir (string-append out "/lib"))
+                    (incdir (string-append out "/include"))
+                    (libc   (assoc-ref %build-inputs "libc"))
+                    (mach (assoc-ref %build-inputs "gnumach-headers")))
+               (mkdir-p libdir)
+               (for-each (lambda (file)
+                           (let ((target (string-append libdir "/"
+                                                        (basename file))))
+                             (copy-file file target)
+                             (remove-store-references target)))
+                         (find-files (string-append libc "/lib")
+                                     "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
+
+               (copy-recursively (string-append libc "/include") incdir)
+
+               (copy-recursively (string-append mach "/include/mach")
+                                 (string-append incdir "/mach"))
+               #t))))
+        (inputs `(("libc" ,(let ((target (%current-target-system)))
+                             (if target
+                                 (glibc-for-bootstrap
+                                  (parameterize ((%current-target-system #f))
+                                    (cross-libc target)))
+                                 glibc)))
+                  ("gnumach-headers" ,gnumach-headers)))
+
+        ;; Only one output.
+        (outputs '("out")))))
+    (_
+     (let ((glibc (glibc-for-bootstrap)))
+       (package (inherit glibc/linux)
+        (name "glibc-stripped")
+        (build-system trivial-build-system)
+        (arguments
+         `(#:modules ((guix build utils))
+           #:builder
+           (begin
+             (use-modules (guix build utils))
+
+             (setvbuf (current-output-port) _IOLBF)
+             (let* ((out    (assoc-ref %outputs "out"))
+                    (libdir (string-append out "/lib"))
+                    (incdir (string-append out "/include"))
+                    (libc   (assoc-ref %build-inputs "libc"))
+                    (linux  (assoc-ref %build-inputs "linux-headers")))
+               (mkdir-p libdir)
+               (for-each (lambda (file)
+                           (let ((target (string-append libdir "/"
+                                                        (basename file))))
+                             (copy-file file target)
+                             (remove-store-references target)))
+                         (find-files (string-append libc "/lib")
+                                     "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
+
+               (copy-recursively (string-append libc "/include") incdir)
+
+               ;; Copy some of the Linux-Libre headers that glibc headers
+               ;; refer to.
+               (mkdir (string-append incdir "/linux"))
+               (for-each (lambda (file)
+                           (copy-file (string-append linux "/include/linux/" file)
+                                      (string-append incdir "/linux/"
+                                                     (basename file))))
+                         '("limits.h" "errno.h" "socket.h" "kernel.h"
+                           "sysctl.h" "param.h" "ioctl.h" "types.h"
+                           "posix_types.h" "stddef.h"))
+
+               (copy-recursively (string-append linux "/include/asm")
+                                 (string-append incdir "/asm"))
+               (copy-recursively (string-append linux "/include/asm-generic")
+                                 (string-append incdir "/asm-generic"))
+
+               #t))))
+        (inputs `(("libc" ,(let ((target (%current-target-system)))
+                             (if target
+                                 (glibc-for-bootstrap
+                                  (parameterize ((%current-target-system #f))
+                                    (cross-libc target)))
+                                 glibc)))
+                  ("linux-headers" ,linux-libre-headers)))
+
+        ;; Only one output.
+        (outputs '("out")))))))
 
 (define %gcc-static
   ;; A statically-linked GCC, with stripped-down functionality.
@@ -641,9 +681,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
   ;; A tarball with the statically-linked Binutils programs.
   (tarball-package %binutils-static-stripped))
 
-(define %glibc-bootstrap-tarball
+(define (%glibc-bootstrap-tarball)
   ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
-  (tarball-package %glibc-stripped))
+  (tarball-package (%glibc-stripped (or (%current-target-system) (%current-system)))))
 
 (define %gcc-bootstrap-tarball
   ;; A tarball with a dynamic-linked GCC and its headers.
@@ -683,7 +723,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
               ("gcc-tarball" ,%gcc-bootstrap-tarball)
               ("binutils-tarball" ,%binutils-bootstrap-tarball)
-              ("glibc-tarball" ,%glibc-bootstrap-tarball)
+              ("glibc-tarball" ,(%glibc-bootstrap-tarball))
               ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
     (synopsis #f)
     (description #f)
-- 
2.4.4


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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2015-06-30 10:14 Manolis Ragkousis
@ 2015-06-30 19:56 ` Ludovic Courtès
  2015-07-01 21:50   ` Manolis Ragkousis
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2015-06-30 19:56 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: Guix-devel

Γειά σας!

Manolis Ragkousis <manolis837@gmail.com> skribis:

> I chose this approach in %glibc-stripped because later on, as more
> things will be needed to be Hurd-specific, it's going to get messy
> with conditional code. This way we can safely change/add things
> without worrying it will break the other. WDYT?

The problem is that this patch duplicates 54 lines that are mostly
identical.

I think it would be preferable to make it more concise.

> From fa84fdeb8a479f3b59b38f762f551d744def2e5f Mon Sep 17 00:00:00 2001
> From: Manolis Ragkousis <manolis837@gmail.com>
> Date: Tue, 30 Jun 2015 12:53:24 +0300
> Subject: [PATCH] gnu: make-bootstrap: Produce the correct
>  %glibc-bootstrap-tarball for Hurd systems.
>
> * gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
>   (%glibc-stripped): Make it a procedure that produces the correct %glibc-stripped
>   depending on the target system.

[...]

> +  (match target
> +    ("i586-pc-gnu"
> +     (let ((glibc (glibc-for-bootstrap)))
> +       (package (inherit glibc/hurd)
> +        (name "glibc-stripped")
> +        (build-system trivial-build-system)
> +        (arguments
> +         `(#:modules ((guix build utils))
> +           #:builder
> +           (begin
> +             (use-modules (guix build utils))
> +
> +             (setvbuf (current-output-port) _IOLBF)
> +             (let* ((out    (assoc-ref %outputs "out"))
> +                    (libdir (string-append out "/lib"))
> +                    (incdir (string-append out "/include"))
> +                    (libc   (assoc-ref %build-inputs "libc"))
> +                    (mach (assoc-ref %build-inputs "gnumach-headers")))
> +               (mkdir-p libdir)
> +               (for-each (lambda (file)
> +                           (let ((target (string-append libdir "/"
> +                                                        (basename file))))
> +                             (copy-file file target)
> +                             (remove-store-references target)))
> +                         (find-files (string-append libc "/lib")
> +                                     "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
> +
> +               (copy-recursively (string-append libc "/include") incdir)
> +
> +               (copy-recursively (string-append mach "/include/mach")
> +                                 (string-append incdir "/mach"))
> +               #t))))

What about introducing a (guix build make-bootstrap) module to hide all
this plumbing?

It could expose a procedure like:

  (define (make-stripped-libc output libc kernel-headers)
    "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
  when producing a bootstrap libc."
    ;; ...
    (if (directory-exists? (string-append kernel-headers "/mach"))
        (copy-mach-headers output kernel-headers)
        (copy-linux-headers output kernel-headers)))

  ;; ...


That way, the #:builder above would become:

  #:builder (begin
              (use-modules (guix build make-bootstrap))
              (make-stripped-libc (assoc-ref %outputs "out")
                                  (assoc-ref %build-inputs "libc")
                                  (assoc-ref %build-inputs "kernel-headers")))

and so we’d be duplicating fewer lines.

The ‘match’ itself could be moved to the ‘inputs’ field, where we’d be
selecting the right headers:

  (define (%glibc-stripped)
    (package (inherit (glibc-for-bootstrap))
      ;; ...
      (inputs `(("kernel-headers"
                 ,(if (or (and (%current-target-system)
                               (hurd-triplet? (%current-target-system)))
                          (string-suffix? "-hurd" (%current-system)))
                      gnumach-headers
                      linux-libre-headers))
                ...))))

where:

  (define (hurd-triplet? triplet)
    (and (string-suffix? "-gnu" triplet)
         (not (string-contains triplet "linux"))))

Note that (%current-target-system) is a GNU triplet whereas
(%current-system) is ARCH-KERNEL.

Does that make sense?  Does that sound doable?

Thank you!

Ludo’.

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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2015-06-30 19:56 ` Ludovic Courtès
@ 2015-07-01 21:50   ` Manolis Ragkousis
  2015-07-07 14:58     ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Manolis Ragkousis @ 2015-07-01 21:50 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 198 bytes --]

Καλησπέρα :-)

Updated patch according to your suggestions.

Your solution is much more elegant. I added you as a co-author, I hope
you don't have a problem with that. :-)

Manolis

[-- Attachment #2: 0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch --]
[-- Type: text/x-patch, Size: 10085 bytes --]

From e93fe7ae5b22245d41814e079279a8e893781287 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Tue, 30 Jun 2015 12:53:24 +0300
Subject: [PATCH] gnu: make-bootstrap: Produce the correct
 %glibc-bootstrap-tarball for Hurd systems.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
  (%glibc-stripped): Make it a procedure and move the kernel specific part from
  here to ...
* guix/build/make-bootstrap.scm (make-stripped-libc): ... here. New file.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
 gnu/packages/make-bootstrap.scm | 71 ++++++++++++-------------------------
 guix/build/make-bootstrap.scm   | 77 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 100 insertions(+), 48 deletions(-)
 create mode 100644 guix/build/make-bootstrap.scm

diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index 3d43421..852044d 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -33,6 +33,7 @@
   #:use-module (gnu packages guile)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages multiprecision)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
@@ -327,65 +328,39 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("binutils" ,%binutils-static)))))
 
-(define %glibc-stripped
+(define (%glibc-stripped)
   ;; GNU libc's essential shared libraries, dynamic linker, and headers,
   ;; with all references to store directories stripped.  As a result,
   ;; libc.so is unusable and need to be patched for proper relocation.
+  (define (hurd-triplet? triplet)
+    (and (string-suffix? "-gnu" triplet)
+         (not (string-contains triplet "linux"))))
+
   (let ((glibc (glibc-for-bootstrap)))
     (package (inherit glibc)
       (name "glibc-stripped")
       (build-system trivial-build-system)
       (arguments
-       `(#:modules ((guix build utils))
+       `(#:modules ((guix build utils)
+                    (guix build make-bootstrap))
          #:builder
          (begin
-           (use-modules (guix build utils))
-
-           (setvbuf (current-output-port) _IOLBF)
-           (let* ((out    (assoc-ref %outputs "out"))
-                  (libdir (string-append out "/lib"))
-                  (incdir (string-append out "/include"))
-                  (libc   (assoc-ref %build-inputs "libc"))
-                  (linux  (assoc-ref %build-inputs "linux-headers")))
-             (mkdir-p libdir)
-             (for-each (lambda (file)
-                         (let ((target (string-append libdir "/"
-                                                      (basename file))))
-                           (copy-file file target)
-                           (remove-store-references target)))
-                       (find-files (string-append libc "/lib")
-                                   "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
-             (copy-recursively (string-append libc "/include") incdir)
-
-             ;; Copy some of the Linux-Libre headers that glibc headers
-             ;; refer to.
-             (mkdir (string-append incdir "/linux"))
-             (for-each (lambda (file)
-                         (copy-file (string-append linux "/include/linux/" file)
-                                    (string-append incdir "/linux/"
-                                                   (basename file))))
-                       '("limits.h" "errno.h" "socket.h" "kernel.h"
-                         "sysctl.h" "param.h" "ioctl.h" "types.h"
-                         "posix_types.h" "stddef.h"))
-
-             (copy-recursively (string-append linux "/include/asm")
-                               (string-append incdir "/asm"))
-             (copy-recursively (string-append linux "/include/asm-generic")
-                               (string-append incdir "/asm-generic"))
-
-             ;; Remove the '.install' and '..install.cmd' files; the latter
-             ;; contains store paths, which prevents bit reproducibility.
-             (for-each delete-file (find-files incdir "\\.install"))
-
-             #t))))
-      (inputs `(("libc" ,(let ((target (%current-target-system)))
+           (use-modules (guix build make-bootstrap))
+           (make-stripped-libc (assoc-ref %outputs "out")
+                               (assoc-ref %build-inputs "libc")
+                               (assoc-ref %build-inputs "kernel-headers")))))
+      (inputs `(("kernel-headers"
+                 ,(if (or (and (%current-target-system)
+                               (hurd-triplet? (%current-target-system)))
+                          (string-suffix? "-hurd" (%current-system)))
+                      gnumach-headers
+                      linux-libre-headers))
+                ("libc" ,(let ((target (%current-target-system)))
                            (if target
                                (glibc-for-bootstrap
                                 (parameterize ((%current-target-system #f))
                                   (cross-libc target)))
-                               glibc)))
-                ("linux-headers" ,linux-libre-headers)))
+                               glibc)))))
 
       ;; Only one output.
       (outputs '("out")))))
@@ -641,9 +616,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
   ;; A tarball with the statically-linked Binutils programs.
   (tarball-package %binutils-static-stripped))
 
-(define %glibc-bootstrap-tarball
+(define (%glibc-bootstrap-tarball)
   ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
-  (tarball-package %glibc-stripped))
+  (tarball-package (%glibc-stripped)))
 
 (define %gcc-bootstrap-tarball
   ;; A tarball with a dynamic-linked GCC and its headers.
@@ -683,7 +658,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
               ("gcc-tarball" ,%gcc-bootstrap-tarball)
               ("binutils-tarball" ,%binutils-bootstrap-tarball)
-              ("glibc-tarball" ,%glibc-bootstrap-tarball)
+              ("glibc-tarball" ,(%glibc-bootstrap-tarball))
               ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
     (synopsis #f)
     (description #f)
diff --git a/guix/build/make-bootstrap.scm b/guix/build/make-bootstrap.scm
new file mode 100644
index 0000000..13669ba
--- /dev/null
+++ b/guix/build/make-bootstrap.scm
@@ -0,0 +1,77 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
+;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build make-bootstrap)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-19)
+  #:use-module (srfi srfi-26)
+  #:use-module (guix build utils)
+  #:export (make-stripped-libc))
+
+(define (make-stripped-libc output libc kernel-headers)
+  "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
+  when producing a bootstrap libc."
+
+  (define (copy-mach-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      (copy-recursively (string-append kernel-headers "/include/mach")
+                        (string-append incdir "/mach"))
+      #t))
+  
+  (define (copy-linux-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      ;; Copy some of the Linux-Libre headers that glibc headers
+      ;; refer to.
+      (mkdir (string-append incdir "/linux"))
+      (for-each (lambda (file)
+                  (copy-file (string-append kernel-headers "/include/linux/" file)
+                             (string-append incdir "/linux/"
+                                            (basename file))))
+                '("limits.h" "errno.h" "socket.h" "kernel.h"
+                  "sysctl.h" "param.h" "ioctl.h" "types.h"
+                  "posix_types.h" "stddef.h"))
+
+      (copy-recursively (string-append kernel-headers "/include/asm")
+                        (string-append incdir "/asm"))
+      (copy-recursively (string-append kernel-headers "/include/asm-generic")
+                        (string-append incdir "/asm-generic"))
+      #t))
+
+  (setvbuf (current-output-port) _IOLBF)
+  (let* ((libdir (string-append output "/lib")))
+    (mkdir-p libdir)
+    (for-each (lambda (file)
+                (let ((target (string-append libdir "/"
+                                             (basename file))))
+                  (copy-file file target)
+                  (remove-store-references target)))
+              (find-files (string-append libc "/lib")
+                          "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
+    #t)
+
+    (if (directory-exists? (string-append kernel-headers "/include/mach"))
+        (copy-mach-headers output kernel-headers)
+        (copy-linux-headers output kernel-headers)))
+
+
-- 
2.4.5


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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2015-07-01 21:50   ` Manolis Ragkousis
@ 2015-07-07 14:58     ` Ludovic Courtès
  2015-07-09  9:54       ` Manolis Ragkousis
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2015-07-07 14:58 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: Guix-devel

Manolis Ragkousis <manolis837@gmail.com> skribis:

> * gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
>   (%glibc-stripped): Make it a procedure and move the kernel specific part from
>   here to ...
> * guix/build/make-bootstrap.scm (make-stripped-libc): ... here. New file.
>
> Co-authored-by: Ludovic Courtès <ludo@gnu.org>

[...]

> +(define-module (guix build make-bootstrap)
> +  #:use-module (srfi srfi-1)
> +  #:use-module (srfi srfi-11)
> +  #:use-module (srfi srfi-19)
> +  #:use-module (srfi srfi-26)
> +  #:use-module (guix build utils)
> +  #:export (make-stripped-libc))

Please add a comment like:

;;; Commentary:
;;;
;;; This module provides facilities to build the bootstrap binaries.
;;;
;;; Code:

> +(define (make-stripped-libc output libc kernel-headers)
> +  "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
> +  when producing a bootstrap libc."
   ^
extra space

Make sure to add this new file to Makefile.am.

Otherwise LGTM.

Could you make sure that ‘guix build glibc-stripped-tarball’ still works
as expected?  (I assume you already tested with --target=i586-pc-gnu.)

If that passes, OK to commit to ‘master’ with the above changes.

Thanks!

Ludo’.

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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2015-07-07 14:58     ` Ludovic Courtès
@ 2015-07-09  9:54       ` Manolis Ragkousis
  2015-07-10 20:48         ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Manolis Ragkousis @ 2015-07-09  9:54 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel

Hey Ludo

On 7 July 2015 at 17:58, Ludovic Courtès <ludo@gnu.org> wrote:
> Could you make sure that ‘guix build glibc-stripped-tarball’ still works
> as expected?  (I assume you already tested with --target=i586-pc-gnu.)

All OK with the changes, but 'guix build glibc-stripped-tarball' does
not work anymore because
I have turned (%glibc-bootstrap-tarball) into a procedure. Unless I do
that, it will not evaluate
correctly. How can I export it correctly now?

Manolis

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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2015-07-09  9:54       ` Manolis Ragkousis
@ 2015-07-10 20:48         ` Ludovic Courtès
  2015-07-11  8:29           ` Manolis Ragkousis
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2015-07-10 20:48 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: Guix-devel

Manolis Ragkousis <manolis837@gmail.com> skribis:

> On 7 July 2015 at 17:58, Ludovic Courtès <ludo@gnu.org> wrote:
>> Could you make sure that ‘guix build glibc-stripped-tarball’ still works
>> as expected?  (I assume you already tested with --target=i586-pc-gnu.)
>
> All OK with the changes, but 'guix build glibc-stripped-tarball' does
> not work anymore because
> I have turned (%glibc-bootstrap-tarball) into a procedure.

I had overlooked that.

> Unless I do that, it will not evaluate correctly. How can I export it
> correctly now?

Uh.  But you can run ‘guix build bootstrap-tarballs’, can’t you?

Ludo’.

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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2015-07-10 20:48         ` Ludovic Courtès
@ 2015-07-11  8:29           ` Manolis Ragkousis
  2015-07-12 12:43             ` Manolis Ragkousis
  0 siblings, 1 reply; 15+ messages in thread
From: Manolis Ragkousis @ 2015-07-11  8:29 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel

On 10 July 2015 at 23:48, Ludovic Courtès <ludo@gnu.org> wrote:

> Uh.  But you can run ‘guix build bootstrap-tarballs’, can’t you?

Yes you can, and it works as expected :-)

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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2015-07-11  8:29           ` Manolis Ragkousis
@ 2015-07-12 12:43             ` Manolis Ragkousis
  2015-07-13 20:43               ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Manolis Ragkousis @ 2015-07-12 12:43 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: Guix-devel

[-- Attachment #1: Type: text/plain, Size: 253 bytes --]

Hey Ludo,

Here is the updated patch with a small modification at the regexp. Now
it copies all the .so and .a files,
needed on a hurd system, to the stripped glibc (libcrt_nonshared.a,
libmachuser.so, libhurduser.so).
Can I push it to master?

Manolis

[-- Attachment #2: 0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch --]
[-- Type: text/x-patch, Size: 10641 bytes --]

From 0b10ca72529d19816f5ceb566c72064f727a971c Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Tue, 30 Jun 2015 12:53:24 +0300
Subject: [PATCH] gnu: make-bootstrap: Produce the correct
 %glibc-bootstrap-tarball for Hurd systems.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
  (%glibc-stripped): Make it a procedure and move the kernel specific part from
  here to ...
* guix/build/make-bootstrap.scm (make-stripped-libc): ... here. New file.
* Makefile.am (MODULES): Add it.

Co-authored-by: Ludovic Courtès <ludo@gnu.org>
---
 Makefile.am                     |  1 +
 gnu/packages/make-bootstrap.scm | 71 +++++++++++-----------------------
 guix/build/make-bootstrap.scm   | 84 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+), 48 deletions(-)
 create mode 100644 guix/build/make-bootstrap.scm

diff --git a/Makefile.am b/Makefile.am
index ae694eb..67ef19b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -87,6 +87,7 @@ MODULES =					\
   guix/build/gremlin.scm			\
   guix/build/emacs-utils.scm			\
   guix/build/graft.scm				\
+  guix/build/make-bootstrap.scm			\
   guix/search-paths.scm				\
   guix/packages.scm				\
   guix/import/utils.scm				\
diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index 3d43421..852044d 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -33,6 +33,7 @@
   #:use-module (gnu packages guile)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages multiprecision)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
@@ -327,65 +328,39 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("binutils" ,%binutils-static)))))
 
-(define %glibc-stripped
+(define (%glibc-stripped)
   ;; GNU libc's essential shared libraries, dynamic linker, and headers,
   ;; with all references to store directories stripped.  As a result,
   ;; libc.so is unusable and need to be patched for proper relocation.
+  (define (hurd-triplet? triplet)
+    (and (string-suffix? "-gnu" triplet)
+         (not (string-contains triplet "linux"))))
+
   (let ((glibc (glibc-for-bootstrap)))
     (package (inherit glibc)
       (name "glibc-stripped")
       (build-system trivial-build-system)
       (arguments
-       `(#:modules ((guix build utils))
+       `(#:modules ((guix build utils)
+                    (guix build make-bootstrap))
          #:builder
          (begin
-           (use-modules (guix build utils))
-
-           (setvbuf (current-output-port) _IOLBF)
-           (let* ((out    (assoc-ref %outputs "out"))
-                  (libdir (string-append out "/lib"))
-                  (incdir (string-append out "/include"))
-                  (libc   (assoc-ref %build-inputs "libc"))
-                  (linux  (assoc-ref %build-inputs "linux-headers")))
-             (mkdir-p libdir)
-             (for-each (lambda (file)
-                         (let ((target (string-append libdir "/"
-                                                      (basename file))))
-                           (copy-file file target)
-                           (remove-store-references target)))
-                       (find-files (string-append libc "/lib")
-                                   "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
-             (copy-recursively (string-append libc "/include") incdir)
-
-             ;; Copy some of the Linux-Libre headers that glibc headers
-             ;; refer to.
-             (mkdir (string-append incdir "/linux"))
-             (for-each (lambda (file)
-                         (copy-file (string-append linux "/include/linux/" file)
-                                    (string-append incdir "/linux/"
-                                                   (basename file))))
-                       '("limits.h" "errno.h" "socket.h" "kernel.h"
-                         "sysctl.h" "param.h" "ioctl.h" "types.h"
-                         "posix_types.h" "stddef.h"))
-
-             (copy-recursively (string-append linux "/include/asm")
-                               (string-append incdir "/asm"))
-             (copy-recursively (string-append linux "/include/asm-generic")
-                               (string-append incdir "/asm-generic"))
-
-             ;; Remove the '.install' and '..install.cmd' files; the latter
-             ;; contains store paths, which prevents bit reproducibility.
-             (for-each delete-file (find-files incdir "\\.install"))
-
-             #t))))
-      (inputs `(("libc" ,(let ((target (%current-target-system)))
+           (use-modules (guix build make-bootstrap))
+           (make-stripped-libc (assoc-ref %outputs "out")
+                               (assoc-ref %build-inputs "libc")
+                               (assoc-ref %build-inputs "kernel-headers")))))
+      (inputs `(("kernel-headers"
+                 ,(if (or (and (%current-target-system)
+                               (hurd-triplet? (%current-target-system)))
+                          (string-suffix? "-hurd" (%current-system)))
+                      gnumach-headers
+                      linux-libre-headers))
+                ("libc" ,(let ((target (%current-target-system)))
                            (if target
                                (glibc-for-bootstrap
                                 (parameterize ((%current-target-system #f))
                                   (cross-libc target)))
-                               glibc)))
-                ("linux-headers" ,linux-libre-headers)))
+                               glibc)))))
 
       ;; Only one output.
       (outputs '("out")))))
@@ -641,9 +616,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
   ;; A tarball with the statically-linked Binutils programs.
   (tarball-package %binutils-static-stripped))
 
-(define %glibc-bootstrap-tarball
+(define (%glibc-bootstrap-tarball)
   ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
-  (tarball-package %glibc-stripped))
+  (tarball-package (%glibc-stripped)))
 
 (define %gcc-bootstrap-tarball
   ;; A tarball with a dynamic-linked GCC and its headers.
@@ -683,7 +658,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
               ("gcc-tarball" ,%gcc-bootstrap-tarball)
               ("binutils-tarball" ,%binutils-bootstrap-tarball)
-              ("glibc-tarball" ,%glibc-bootstrap-tarball)
+              ("glibc-tarball" ,(%glibc-bootstrap-tarball))
               ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
     (synopsis #f)
     (description #f)
diff --git a/guix/build/make-bootstrap.scm b/guix/build/make-bootstrap.scm
new file mode 100644
index 0000000..b1b0a53
--- /dev/null
+++ b/guix/build/make-bootstrap.scm
@@ -0,0 +1,84 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
+;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build make-bootstrap)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-19)
+  #:use-module (srfi srfi-26)
+  #:use-module (guix build utils)
+  #:export (make-stripped-libc))
+
+;; Commentary:
+;;
+;; This module provides facilities to build the bootstrap binaries.
+;;
+;; Code:
+
+(define (make-stripped-libc output libc kernel-headers)
+  "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
+   when producing a bootstrap libc."
+
+  (define (copy-mach-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      (copy-recursively (string-append kernel-headers "/include/mach")
+                        (string-append incdir "/mach"))
+      #t))
+  
+  (define (copy-linux-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      ;; Copy some of the Linux-Libre headers that glibc headers
+      ;; refer to.
+      (mkdir (string-append incdir "/linux"))
+      (for-each (lambda (file)
+                  (copy-file (string-append kernel-headers "/include/linux/" file)
+                             (string-append incdir "/linux/"
+                                            (basename file))))
+                '("limits.h" "errno.h" "socket.h" "kernel.h"
+                  "sysctl.h" "param.h" "ioctl.h" "types.h"
+                  "posix_types.h" "stddef.h"))
+
+      (copy-recursively (string-append kernel-headers "/include/asm")
+                        (string-append incdir "/asm"))
+      (copy-recursively (string-append kernel-headers "/include/asm-generic")
+                        (string-append incdir "/asm-generic"))
+      #t))
+
+  (setvbuf (current-output-port) _IOLBF)
+  (let* ((libdir (string-append output "/lib")))
+    (mkdir-p libdir)
+    (for-each (lambda (file)
+                (let ((target (string-append libdir "/"
+                                             (basename file))))
+                  (copy-file file target)
+                  (remove-store-references target)))
+              (find-files (string-append libc "/lib")
+                          "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util|machuser|
+hurduser).*\\.so(\\..*)?|libc(rt|)_nonshared\\.a)$"))
+    #t)
+
+    (if (directory-exists? (string-append kernel-headers "/include/mach"))
+        (copy-mach-headers output kernel-headers)
+        (copy-linux-headers output kernel-headers)))
+
+
-- 
2.4.5


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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2015-07-12 12:43             ` Manolis Ragkousis
@ 2015-07-13 20:43               ` Ludovic Courtès
  0 siblings, 0 replies; 15+ messages in thread
From: Ludovic Courtès @ 2015-07-13 20:43 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: Guix-devel

Manolis Ragkousis <manolis837@gmail.com> skribis:

> Here is the updated patch with a small modification at the regexp. Now
> it copies all the .so and .a files,
> needed on a hurd system, to the stripped glibc (libcrt_nonshared.a,
> libmachuser.so, libhurduser.so).

OK for copying lib{hurd,mach}user.so, of course.

However, I think the .a files should be omitted.  What was the
motivation?

Also, I think any non-trivial change should be in a subsequent patch, so
that it’s easy to distinguish between the refactoring (moving code from
one file to another) and the actual functional change.

> +                          "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util|machuser|
> +hurduser).*\\.so(\\..*)?|libc(rt|)_nonshared\\.a)$"))

There should be a backslash at the end of the first line so that
carriage return doesn’t appear literally in the regexp.

Thanks,
Ludo’.

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

* [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
@ 2016-06-17 16:09 Manolis Ragkousis
  2016-07-26 13:41 ` Manolis Ragkousis
  0 siblings, 1 reply; 15+ messages in thread
From: Manolis Ragkousis @ 2016-06-17 16:09 UTC (permalink / raw)
  To: guix-devel

[-- Attachment #1: Type: text/plain, Size: 102 bytes --]

Hello everyone,

This is a patch from wip-hurd modified to apply on core-updates.

Thank you,
Manolis

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch --]
[-- Type: text/x-patch; name="0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch", Size: 10612 bytes --]

From 255c32331d56862ea1148fcc0efb924b0f4b511c Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Fri, 17 Jun 2016 18:11:44 +0300
Subject: [PATCH] gnu: make-bootstrap: Produce the correct
 %glibc-bootstrap-tarball for Hurd systems.

* gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
  (%glibc-stripped): Make it a procedure and move the kernel specific part from
  here to ...
* guix/build/make-bootstrap.scm (make-stripped-libc): ... here. New file.
* Makefile.am (MODULES): Add it.
---
 Makefile.am                     |  1 +
 gnu/packages/make-bootstrap.scm | 67 +++++++++++---------------------
 guix/build/make-bootstrap.scm   | 84 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+), 44 deletions(-)
 create mode 100644 guix/build/make-bootstrap.scm

diff --git a/Makefile.am b/Makefile.am
index 44838d3..2ecb6ee 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -104,6 +104,7 @@ MODULES =					\
   guix/build/graft.scm				\
   guix/build/bournish.scm			\
   guix/build/cross-base.scm                     \
+  guix/build/make-bootstrap.scm                 \
   guix/search-paths.scm				\
   guix/packages.scm				\
   guix/import/utils.scm				\
diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index def9c23..45c09a4 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -33,6 +33,7 @@
   #:use-module (gnu packages guile)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages multiprecision)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
@@ -325,61 +326,39 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("binutils" ,%binutils-static)))))
 
-(define %glibc-stripped
+(define (%glibc-stripped)
   ;; GNU libc's essential shared libraries, dynamic linker, and headers,
   ;; with all references to store directories stripped.  As a result,
   ;; libc.so is unusable and need to be patched for proper relocation.
+  (define (hurd-triplet? triplet)
+    (and (string-suffix? "-gnu" triplet)
+         (not (string-contains triplet "linux"))))
+
   (let ((glibc (glibc-for-bootstrap)))
     (package (inherit glibc)
       (name "glibc-stripped")
       (build-system trivial-build-system)
       (arguments
-       `(#:modules ((guix build utils))
+       `(#:modules ((guix build utils)
+                    (guix build make-bootstrap))
          #:builder
          (begin
-           (use-modules (guix build utils))
-
-           (setvbuf (current-output-port) _IOLBF)
-           (let* ((out    (assoc-ref %outputs "out"))
-                  (libdir (string-append out "/lib"))
-                  (incdir (string-append out "/include"))
-                  (libc   (assoc-ref %build-inputs "libc"))
-                  (linux  (assoc-ref %build-inputs "kernel-headers")))
-             (mkdir-p libdir)
-             (for-each (lambda (file)
-                         (let ((target (string-append libdir "/"
-                                                      (basename file))))
-                           (copy-file file target)
-                           (remove-store-references target)))
-                       (find-files (string-append libc "/lib")
-                                   "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
-             (copy-recursively (string-append libc "/include") incdir)
-
-             ;; Copy some of the Linux-Libre headers that glibc headers
-             ;; refer to.
-             (mkdir (string-append incdir "/linux"))
-             (for-each (lambda (file)
-                         (copy-file (string-append linux "/include/linux/" file)
-                                    (string-append incdir "/linux/"
-                                                   (basename file))))
-                       '("limits.h" "errno.h" "socket.h" "kernel.h"
-                         "sysctl.h" "param.h" "ioctl.h" "types.h"
-                         "posix_types.h" "stddef.h"))
-
-             (copy-recursively (string-append linux "/include/asm")
-                               (string-append incdir "/asm"))
-             (copy-recursively (string-append linux "/include/asm-generic")
-                               (string-append incdir "/asm-generic"))
-
-             #t))))
-      (inputs `(("libc" ,(let ((target (%current-target-system)))
+           (use-modules (guix build make-bootstrap))
+           (make-stripped-libc (assoc-ref %outputs "out")
+                               (assoc-ref %build-inputs "libc")
+                               (assoc-ref %build-inputs "kernel-headers")))))
+      (inputs `(("kernel-headers"
+                 ,(if (or (and (%current-target-system)
+                               (hurd-triplet? (%current-target-system)))
+                          (string-suffix? "-hurd" (%current-system)))
+                      gnumach-headers
+                      linux-libre-headers))
+                ("libc" ,(let ((target (%current-target-system)))
                            (if target
                                (glibc-for-bootstrap
                                 (parameterize ((%current-target-system #f))
                                   (cross-libc target)))
-                               glibc)))
-                ("kernel-headers" ,linux-libre-headers)))
+                               glibc)))))
 
       ;; Only one output.
       (outputs '("out")))))
@@ -639,9 +618,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
   ;; A tarball with the statically-linked Binutils programs.
   (tarball-package %binutils-static-stripped))
 
-(define %glibc-bootstrap-tarball
+(define (%glibc-bootstrap-tarball)
   ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
-  (tarball-package %glibc-stripped))
+  (tarball-package (%glibc-stripped)))
 
 (define %gcc-bootstrap-tarball
   ;; A tarball with a dynamic-linked GCC and its headers.
@@ -681,7 +660,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
               ("gcc-tarball" ,%gcc-bootstrap-tarball)
               ("binutils-tarball" ,%binutils-bootstrap-tarball)
-              ("glibc-tarball" ,%glibc-bootstrap-tarball)
+              ("glibc-tarball" ,(%glibc-bootstrap-tarball))
               ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
     (synopsis "Tarballs containing all the bootstrap binaries")
     (description synopsis)
diff --git a/guix/build/make-bootstrap.scm b/guix/build/make-bootstrap.scm
new file mode 100644
index 0000000..283a13e
--- /dev/null
+++ b/guix/build/make-bootstrap.scm
@@ -0,0 +1,84 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
+;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build make-bootstrap)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-19)
+  #:use-module (srfi srfi-26)
+  #:use-module (guix build utils)
+  #:export (make-stripped-libc))
+
+;; Commentary:
+;;
+;; This module provides facilities to build the bootstrap binaries.
+;;
+;; Code:
+
+(define (make-stripped-libc output libc kernel-headers)
+  "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
+   when producing a bootstrap libc."
+
+  (define (copy-mach-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      (copy-recursively (string-append kernel-headers "/include/mach")
+                        (string-append incdir "/mach"))
+      #t))
+  
+  (define (copy-linux-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      ;; Copy some of the Linux-Libre headers that glibc headers
+      ;; refer to.
+      (mkdir (string-append incdir "/linux"))
+      (for-each (lambda (file)
+                  (copy-file (string-append kernel-headers "/include/linux/" file)
+                             (string-append incdir "/linux/"
+                                            (basename file))))
+                '("limits.h" "errno.h" "socket.h" "kernel.h"
+                  "sysctl.h" "param.h" "ioctl.h" "types.h"
+                  "posix_types.h" "stddef.h"))
+
+      (copy-recursively (string-append kernel-headers "/include/asm")
+                        (string-append incdir "/asm"))
+      (copy-recursively (string-append kernel-headers "/include/asm-generic")
+                        (string-append incdir "/asm-generic"))
+      #t))
+
+  (setvbuf (current-output-port) _IOLBF)
+  (let* ((libdir (string-append output "/lib")))
+    (mkdir-p libdir)
+    (for-each (lambda (file)
+                (let ((target (string-append libdir "/"
+                                             (basename file))))
+                  (copy-file file target)
+                  (remove-store-references target)))
+              (find-files (string-append libc "/lib")
+                          "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|\
+lib(machuser|hurduser).so.*|libc(rt|)_nonshared\\.a)$"))
+    #t)
+
+    (if (directory-exists? (string-append kernel-headers "/include/mach"))
+        (copy-mach-headers output kernel-headers)
+        (copy-linux-headers output kernel-headers)))
+
+
-- 
2.8.3


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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2016-06-17 16:09 [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems Manolis Ragkousis
@ 2016-07-26 13:41 ` Manolis Ragkousis
  2016-07-26 14:44   ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Manolis Ragkousis @ 2016-07-26 13:41 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 386 bytes --]

Hello everyone,

This is an updated version of the patch. There was a reference to
another patch of mine, so it couldn't apply cleanly on core-updates-next.

Ludo is it okay to push to core-updates-next?

On 06/17/16 19:09, Manolis Ragkousis wrote:
> Hello everyone,
> 
> This is a patch from wip-hurd modified to apply on core-updates.
> 
> Thank you,
> Manolis
> 

Thank you,
Manolis

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch --]
[-- Type: text/x-patch; name="0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch", Size: 10595 bytes --]

From a8541a554f9e1653c78b6b45f323426e330d5215 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Mon, 25 Jul 2016 16:53:40 +0300
Subject: [PATCH] gnu: make-bootstrap: Produce the correct
 %glibc-bootstrap-tarball for Hurd systems.

* gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
  (%glibc-stripped): Make it a procedure and move the kernel specific part from
  here to ...
* guix/build/make-bootstrap.scm (make-stripped-libc): ... here. New file.
* Makefile.am (MODULES): Add it.
---
 Makefile.am                     |  1 +
 gnu/packages/make-bootstrap.scm | 67 +++++++++++---------------------
 guix/build/make-bootstrap.scm   | 84 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 108 insertions(+), 44 deletions(-)
 create mode 100644 guix/build/make-bootstrap.scm

diff --git a/Makefile.am b/Makefile.am
index 0771447..fff2500 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -107,6 +107,7 @@ MODULES =					\
   guix/build/emacs-utils.scm			\
   guix/build/graft.scm				\
   guix/build/bournish.scm			\
+  guix/build/make-bootstrap.scm                 \
   guix/search-paths.scm				\
   guix/packages.scm				\
   guix/import/utils.scm				\
diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index def9c23..45c09a4 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -33,6 +33,7 @@
   #:use-module (gnu packages guile)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages multiprecision)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
@@ -325,61 +326,39 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("binutils" ,%binutils-static)))))
 
-(define %glibc-stripped
+(define (%glibc-stripped)
   ;; GNU libc's essential shared libraries, dynamic linker, and headers,
   ;; with all references to store directories stripped.  As a result,
   ;; libc.so is unusable and need to be patched for proper relocation.
+  (define (hurd-triplet? triplet)
+    (and (string-suffix? "-gnu" triplet)
+         (not (string-contains triplet "linux"))))
+
   (let ((glibc (glibc-for-bootstrap)))
     (package (inherit glibc)
       (name "glibc-stripped")
       (build-system trivial-build-system)
       (arguments
-       `(#:modules ((guix build utils))
+       `(#:modules ((guix build utils)
+                    (guix build make-bootstrap))
          #:builder
          (begin
-           (use-modules (guix build utils))
-
-           (setvbuf (current-output-port) _IOLBF)
-           (let* ((out    (assoc-ref %outputs "out"))
-                  (libdir (string-append out "/lib"))
-                  (incdir (string-append out "/include"))
-                  (libc   (assoc-ref %build-inputs "libc"))
-                  (linux  (assoc-ref %build-inputs "kernel-headers")))
-             (mkdir-p libdir)
-             (for-each (lambda (file)
-                         (let ((target (string-append libdir "/"
-                                                      (basename file))))
-                           (copy-file file target)
-                           (remove-store-references target)))
-                       (find-files (string-append libc "/lib")
-                                   "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
-             (copy-recursively (string-append libc "/include") incdir)
-
-             ;; Copy some of the Linux-Libre headers that glibc headers
-             ;; refer to.
-             (mkdir (string-append incdir "/linux"))
-             (for-each (lambda (file)
-                         (copy-file (string-append linux "/include/linux/" file)
-                                    (string-append incdir "/linux/"
-                                                   (basename file))))
-                       '("limits.h" "errno.h" "socket.h" "kernel.h"
-                         "sysctl.h" "param.h" "ioctl.h" "types.h"
-                         "posix_types.h" "stddef.h"))
-
-             (copy-recursively (string-append linux "/include/asm")
-                               (string-append incdir "/asm"))
-             (copy-recursively (string-append linux "/include/asm-generic")
-                               (string-append incdir "/asm-generic"))
-
-             #t))))
-      (inputs `(("libc" ,(let ((target (%current-target-system)))
+           (use-modules (guix build make-bootstrap))
+           (make-stripped-libc (assoc-ref %outputs "out")
+                               (assoc-ref %build-inputs "libc")
+                               (assoc-ref %build-inputs "kernel-headers")))))
+      (inputs `(("kernel-headers"
+                 ,(if (or (and (%current-target-system)
+                               (hurd-triplet? (%current-target-system)))
+                          (string-suffix? "-hurd" (%current-system)))
+                      gnumach-headers
+                      linux-libre-headers))
+                ("libc" ,(let ((target (%current-target-system)))
                            (if target
                                (glibc-for-bootstrap
                                 (parameterize ((%current-target-system #f))
                                   (cross-libc target)))
-                               glibc)))
-                ("kernel-headers" ,linux-libre-headers)))
+                               glibc)))))
 
       ;; Only one output.
       (outputs '("out")))))
@@ -639,9 +618,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
   ;; A tarball with the statically-linked Binutils programs.
   (tarball-package %binutils-static-stripped))
 
-(define %glibc-bootstrap-tarball
+(define (%glibc-bootstrap-tarball)
   ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
-  (tarball-package %glibc-stripped))
+  (tarball-package (%glibc-stripped)))
 
 (define %gcc-bootstrap-tarball
   ;; A tarball with a dynamic-linked GCC and its headers.
@@ -681,7 +660,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
               ("gcc-tarball" ,%gcc-bootstrap-tarball)
               ("binutils-tarball" ,%binutils-bootstrap-tarball)
-              ("glibc-tarball" ,%glibc-bootstrap-tarball)
+              ("glibc-tarball" ,(%glibc-bootstrap-tarball))
               ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
     (synopsis "Tarballs containing all the bootstrap binaries")
     (description synopsis)
diff --git a/guix/build/make-bootstrap.scm b/guix/build/make-bootstrap.scm
new file mode 100644
index 0000000..283a13e
--- /dev/null
+++ b/guix/build/make-bootstrap.scm
@@ -0,0 +1,84 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
+;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build make-bootstrap)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-19)
+  #:use-module (srfi srfi-26)
+  #:use-module (guix build utils)
+  #:export (make-stripped-libc))
+
+;; Commentary:
+;;
+;; This module provides facilities to build the bootstrap binaries.
+;;
+;; Code:
+
+(define (make-stripped-libc output libc kernel-headers)
+  "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
+   when producing a bootstrap libc."
+
+  (define (copy-mach-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      (copy-recursively (string-append kernel-headers "/include/mach")
+                        (string-append incdir "/mach"))
+      #t))
+  
+  (define (copy-linux-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      ;; Copy some of the Linux-Libre headers that glibc headers
+      ;; refer to.
+      (mkdir (string-append incdir "/linux"))
+      (for-each (lambda (file)
+                  (copy-file (string-append kernel-headers "/include/linux/" file)
+                             (string-append incdir "/linux/"
+                                            (basename file))))
+                '("limits.h" "errno.h" "socket.h" "kernel.h"
+                  "sysctl.h" "param.h" "ioctl.h" "types.h"
+                  "posix_types.h" "stddef.h"))
+
+      (copy-recursively (string-append kernel-headers "/include/asm")
+                        (string-append incdir "/asm"))
+      (copy-recursively (string-append kernel-headers "/include/asm-generic")
+                        (string-append incdir "/asm-generic"))
+      #t))
+
+  (setvbuf (current-output-port) _IOLBF)
+  (let* ((libdir (string-append output "/lib")))
+    (mkdir-p libdir)
+    (for-each (lambda (file)
+                (let ((target (string-append libdir "/"
+                                             (basename file))))
+                  (copy-file file target)
+                  (remove-store-references target)))
+              (find-files (string-append libc "/lib")
+                          "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|\
+lib(machuser|hurduser).so.*|libc(rt|)_nonshared\\.a)$"))
+    #t)
+
+    (if (directory-exists? (string-append kernel-headers "/include/mach"))
+        (copy-mach-headers output kernel-headers)
+        (copy-linux-headers output kernel-headers)))
+
+
-- 
2.9.0


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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2016-07-26 13:41 ` Manolis Ragkousis
@ 2016-07-26 14:44   ` Ludovic Courtès
  2016-12-07  9:55     ` Manolis Ragkousis
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2016-07-26 14:44 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: guix-devel

Hello!

Manolis Ragkousis <manolis837@gmail.com> skribis:

> From a8541a554f9e1653c78b6b45f323426e330d5215 Mon Sep 17 00:00:00 2001
> From: Manolis Ragkousis <manolis837@gmail.com>
> Date: Mon, 25 Jul 2016 16:53:40 +0300
> Subject: [PATCH] gnu: make-bootstrap: Produce the correct
>  %glibc-bootstrap-tarball for Hurd systems.
>
> * gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
>   (%glibc-stripped): Make it a procedure and move the kernel specific part from
>   here to ...
> * guix/build/make-bootstrap.scm (make-stripped-libc): ... here. New file.
> * Makefile.am (MODULES): Add it.

I like this new (guix build make-bootstrap) module!

It would be ideal if the part that introduces this module were a patch
separate from the Hurd part.  However, that’s too much of a trouble to
split the patch, it’s fine this way.

> +(define (make-stripped-libc output libc kernel-headers)
> +  "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
> +   when producing a bootstrap libc."
      ^
Please align to the left.

> +      (for-each (lambda (file)
> +                  (copy-file (string-append kernel-headers "/include/linux/" file)
> +                             (string-append incdir "/linux/"
> +                                            (basename file))))

This could be written as:

  (install-file (string-append kernel-headers "/include/linux/" file)
                (string-append incdir "/linux"))

> +              (find-files (string-append libc "/lib")
> +                          "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|\
> +lib(machuser|hurduser).so.*|libc(rt|)_nonshared\\.a)$"))

Maybe move the regexp to a separate variable for clarity, like:

  (define %libc-object-files-rx "^…")

Otherwise LGTM!

Thanks!

Ludo’.

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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2016-07-26 14:44   ` Ludovic Courtès
@ 2016-12-07  9:55     ` Manolis Ragkousis
  2016-12-07 10:50       ` Ludovic Courtès
  0 siblings, 1 reply; 15+ messages in thread
From: Manolis Ragkousis @ 2016-12-07  9:55 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

[-- Attachment #1: Type: text/plain, Size: 222 bytes --]

Hello Ludo,

This is an old patch which I had forgotten I hadn't pushed to
core-updates back then.

This is the updated version with your suggestions and checked that it
works with latest core-updates.

Thank you,
Manolis

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch --]
[-- Type: text/x-patch; name="0001-gnu-make-bootstrap-Produce-the-correct-glibc-bootstr.patch", Size: 10934 bytes --]

From 0e21f4484f67dfd6ed132e9e5b5934f3098c98b3 Mon Sep 17 00:00:00 2001
From: Manolis Ragkousis <manolis837@gmail.com>
Date: Wed, 30 Nov 2016 16:49:48 +0200
Subject: [PATCH] gnu: make-bootstrap: Produce the correct
 %glibc-bootstrap-tarball for Hurd systems.

* gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
  (%glibc-stripped): Make it a procedure and move the kernel specific part from
  here to ...
* guix/build/make-bootstrap.scm (make-stripped-libc): ... here. New file.
* Makefile.am (MODULES): Add it.
---
 Makefile.am                     |  1 +
 gnu/packages/make-bootstrap.scm | 69 ++++++++++++---------------------
 guix/build/make-bootstrap.scm   | 84 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 109 insertions(+), 45 deletions(-)
 create mode 100644 guix/build/make-bootstrap.scm

diff --git a/Makefile.am b/Makefile.am
index 9d62f48..0e3ddac 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -112,6 +112,7 @@ MODULES =					\
   guix/build/graft.scm				\
   guix/build/bournish.scm			\
   guix/build/qt-utils.scm			\
+  guix/build/make-bootstrap.scm			\
   guix/search-paths.scm				\
   guix/packages.scm				\
   guix/import/utils.scm				\
diff --git a/gnu/packages/make-bootstrap.scm b/gnu/packages/make-bootstrap.scm
index f31db6a..85f3231 100644
--- a/gnu/packages/make-bootstrap.scm
+++ b/gnu/packages/make-bootstrap.scm
@@ -32,6 +32,7 @@
   #:use-module (gnu packages guile)
   #:use-module (gnu packages bdw-gc)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages hurd)
   #:use-module (gnu packages multiprecision)
   #:use-module (ice-9 match)
   #:use-module (srfi srfi-1)
@@ -84,7 +85,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
        ;; `cross-libc' already returns a cross libc, so clear
        ;; %CURRENT-TARGET-SYSTEM.
        (parameterize ((%current-target-system #f))
-         (cross-libc target)))))
+         (cross-libc target )))))
 
   ;; Standard inputs with the above libc and corresponding GCC.
 
@@ -332,61 +333,39 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
            #t))))
     (inputs `(("binutils" ,%binutils-static)))))
 
-(define %glibc-stripped
+(define (%glibc-stripped)
   ;; GNU libc's essential shared libraries, dynamic linker, and headers,
   ;; with all references to store directories stripped.  As a result,
   ;; libc.so is unusable and need to be patched for proper relocation.
+  (define (hurd-triplet? triplet)
+    (and (string-suffix? "-gnu" triplet)
+         (not (string-contains triplet "linux"))))
+
   (let ((glibc (glibc-for-bootstrap)))
     (package (inherit glibc)
       (name "glibc-stripped")
       (build-system trivial-build-system)
       (arguments
-       `(#:modules ((guix build utils))
+       `(#:modules ((guix build utils)
+                    (guix build make-bootstrap))
          #:builder
          (begin
-           (use-modules (guix build utils))
-
-           (setvbuf (current-output-port) _IOLBF)
-           (let* ((out    (assoc-ref %outputs "out"))
-                  (libdir (string-append out "/lib"))
-                  (incdir (string-append out "/include"))
-                  (libc   (assoc-ref %build-inputs "libc"))
-                  (linux  (assoc-ref %build-inputs "kernel-headers")))
-             (mkdir-p libdir)
-             (for-each (lambda (file)
-                         (let ((target (string-append libdir "/"
-                                                      (basename file))))
-                           (copy-file file target)
-                           (remove-store-references target)))
-                       (find-files (string-append libc "/lib")
-                                   "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|util).*\\.so(\\..*)?|libc_nonshared\\.a)$"))
-
-             (copy-recursively (string-append libc "/include") incdir)
-
-             ;; Copy some of the Linux-Libre headers that glibc headers
-             ;; refer to.
-             (mkdir (string-append incdir "/linux"))
-             (for-each (lambda (file)
-                         (copy-file (string-append linux "/include/linux/" file)
-                                    (string-append incdir "/linux/"
-                                                   (basename file))))
-                       '("limits.h" "errno.h" "socket.h" "kernel.h"
-                         "sysctl.h" "param.h" "ioctl.h" "types.h"
-                         "posix_types.h" "stddef.h"))
-
-             (copy-recursively (string-append linux "/include/asm")
-                               (string-append incdir "/asm"))
-             (copy-recursively (string-append linux "/include/asm-generic")
-                               (string-append incdir "/asm-generic"))
-
-             #t))))
-      (inputs `(("libc" ,(let ((target (%current-target-system)))
+           (use-modules (guix build make-bootstrap))
+           (make-stripped-libc (assoc-ref %outputs "out")
+                               (assoc-ref %build-inputs "libc")
+                               (assoc-ref %build-inputs "kernel-headers")))))
+      (inputs `(("kernel-headers"
+                 ,(if (or (and (%current-target-system)
+                               (hurd-triplet? (%current-target-system)))
+                          (string-suffix? "-hurd" (%current-system)))
+                      gnumach-headers
+                      linux-libre-headers))
+                ("libc" ,(let ((target (%current-target-system)))
                            (if target
                                (glibc-for-bootstrap
                                 (parameterize ((%current-target-system #f))
                                   (cross-libc target)))
-                               glibc)))
-                ("kernel-headers" ,linux-libre-headers)))
+                               glibc)))))
 
       ;; Only one output.
       (outputs '("out")))))
@@ -647,9 +626,9 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
   ;; A tarball with the statically-linked Binutils programs.
   (tarball-package %binutils-static-stripped))
 
-(define %glibc-bootstrap-tarball
+(define (%glibc-bootstrap-tarball)
   ;; A tarball with GNU libc's shared libraries, dynamic linker, and headers.
-  (tarball-package %glibc-stripped))
+  (tarball-package (%glibc-stripped)))
 
 (define %gcc-bootstrap-tarball
   ;; A tarball with a dynamic-linked GCC and its headers.
@@ -689,7 +668,7 @@ for `sh' in $PATH, and without nscd, and with static NSS modules."
     (inputs `(("guile-tarball" ,%guile-bootstrap-tarball)
               ("gcc-tarball" ,%gcc-bootstrap-tarball)
               ("binutils-tarball" ,%binutils-bootstrap-tarball)
-              ("glibc-tarball" ,%glibc-bootstrap-tarball)
+              ("glibc-tarball" ,(%glibc-bootstrap-tarball))
               ("coreutils&co-tarball" ,%bootstrap-binaries-tarball)))
     (synopsis "Tarballs containing all the bootstrap binaries")
     (description synopsis)
diff --git a/guix/build/make-bootstrap.scm b/guix/build/make-bootstrap.scm
new file mode 100644
index 0000000..bc4c0e3
--- /dev/null
+++ b/guix/build/make-bootstrap.scm
@@ -0,0 +1,84 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2015 Manolis Fragkiskos Ragkousis <manolis837@gmail.com>
+;;; Copyright © 2015 Ludovic Courtès <ludo@gnu.org>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix build make-bootstrap)
+  #:use-module (srfi srfi-1)
+  #:use-module (srfi srfi-11)
+  #:use-module (srfi srfi-19)
+  #:use-module (srfi srfi-26)
+  #:use-module (guix build utils)
+  #:export (make-stripped-libc))
+
+;; Commentary:
+;;
+;; This module provides facilities to build the bootstrap binaries.
+;;
+;; Code:
+
+(define (make-stripped-libc output libc kernel-headers)
+  "Copy to OUTPUT the subset of LIBC and KERNEL-HEADERS that is needed
+when producing a bootstrap libc."
+
+  (define (copy-mach-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      (copy-recursively (string-append kernel-headers "/include/mach")
+                        (string-append incdir "/mach"))
+      #t))
+  
+  (define (copy-linux-headers output kernel-headers)
+    (let* ((incdir (string-append output "/include")))
+      (copy-recursively (string-append libc "/include") incdir)
+
+      ;; Copy some of the Linux-Libre headers that glibc headers
+      ;; refer to.
+      (mkdir (string-append incdir "/linux"))
+      (for-each (lambda (file)
+                  (install-file (string-append kernel-headers "/include/linux/" file)
+                                (string-append incdir "/linux")))
+                '("limits.h" "errno.h" "socket.h" "kernel.h"
+                  "sysctl.h" "param.h" "ioctl.h" "types.h"
+                  "posix_types.h" "stddef.h"))
+
+      (copy-recursively (string-append kernel-headers "/include/asm")
+                        (string-append incdir "/asm"))
+      (copy-recursively (string-append kernel-headers "/include/asm-generic")
+                        (string-append incdir "/asm-generic"))
+      #t))
+
+  (define %libc-object-files-rx "^(crt.*|ld.*|lib(c|m|dl|rt|pthread|nsl|\
+util).*\\.so(\\..*)?|lib(machuser|hurduser).so.*|libc(rt|)_nonshared\\.a)$")
+
+  (setvbuf (current-output-port) _IOLBF)
+  (let* ((libdir (string-append output "/lib")))
+    (mkdir-p libdir)
+    (for-each (lambda (file)
+                (let ((target (string-append libdir "/"
+                                             (basename file))))
+                  (copy-file file target)
+                  (remove-store-references target)))
+              (find-files (string-append libc "/lib") %libc-object-files-rx))
+    #t)
+
+    (if (directory-exists? (string-append kernel-headers "/include/mach"))
+        (copy-mach-headers output kernel-headers)
+        (copy-linux-headers output kernel-headers)))
+
+
-- 
2.10.2


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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2016-12-07  9:55     ` Manolis Ragkousis
@ 2016-12-07 10:50       ` Ludovic Courtès
  2016-12-07 11:01         ` Manolis Ragkousis
  0 siblings, 1 reply; 15+ messages in thread
From: Ludovic Courtès @ 2016-12-07 10:50 UTC (permalink / raw)
  To: Manolis Ragkousis; +Cc: guix-devel

Hello Manolis!

Manolis Ragkousis <manolis837@gmail.com> skribis:

> This is an old patch which I had forgotten I hadn't pushed to
> core-updates back then.
>
> This is the updated version with your suggestions and checked that it
> works with latest core-updates.

I believe it can go to master since it does not trigger rebuilds.

> From 0e21f4484f67dfd6ed132e9e5b5934f3098c98b3 Mon Sep 17 00:00:00 2001
> From: Manolis Ragkousis <manolis837@gmail.com>
> Date: Wed, 30 Nov 2016 16:49:48 +0200
> Subject: [PATCH] gnu: make-bootstrap: Produce the correct
>  %glibc-bootstrap-tarball for Hurd systems.
>
> * gnu/packages/make-bootstrap.scm (%glibc-bootstrap-tarball): Make it a procedure.
>   (%glibc-stripped): Make it a procedure and move the kernel specific part from
>   here to ...
> * guix/build/make-bootstrap.scm (make-stripped-libc): ... here. New file.
> * Makefile.am (MODULES): Add it.

[...]

>         ;; `cross-libc' already returns a cross libc, so clear
>         ;; %CURRENT-TARGET-SYSTEM.
>         (parameterize ((%current-target-system #f))
> -         (cross-libc target)))))
> +         (cross-libc target )))))

Nope.  :-)

Apart from that it LGTM!

Thank you,
Ludo’.

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

* Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
  2016-12-07 10:50       ` Ludovic Courtès
@ 2016-12-07 11:01         ` Manolis Ragkousis
  0 siblings, 0 replies; 15+ messages in thread
From: Manolis Ragkousis @ 2016-12-07 11:01 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: guix-devel

Hello Ludo,

> 
>>         ;; `cross-libc' already returns a cross libc, so clear
>>         ;; %CURRENT-TARGET-SYSTEM.
>>         (parameterize ((%current-target-system #f))
>> -         (cross-libc target)))))
>> +         (cross-libc target )))))
> 
> Nope.  :-)

Oops :-).

Fixed and pushed to master.

Thank you,
Manolis

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

end of thread, other threads:[~2016-12-07 11:03 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-06-17 16:09 [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems Manolis Ragkousis
2016-07-26 13:41 ` Manolis Ragkousis
2016-07-26 14:44   ` Ludovic Courtès
2016-12-07  9:55     ` Manolis Ragkousis
2016-12-07 10:50       ` Ludovic Courtès
2016-12-07 11:01         ` Manolis Ragkousis
  -- strict thread matches above, loose matches on Subject: below --
2015-06-30 10:14 Manolis Ragkousis
2015-06-30 19:56 ` Ludovic Courtès
2015-07-01 21:50   ` Manolis Ragkousis
2015-07-07 14:58     ` Ludovic Courtès
2015-07-09  9:54       ` Manolis Ragkousis
2015-07-10 20:48         ` Ludovic Courtès
2015-07-11  8:29           ` Manolis Ragkousis
2015-07-12 12:43             ` Manolis Ragkousis
2015-07-13 20:43               ` 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).