all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: ludo@gnu.org (Ludovic Courtès)
To: Manolis Ragkousis <manolis837@gmail.com>
Cc: Guix-devel <Guix-devel@gnu.org>
Subject: Re: [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems.
Date: Tue, 30 Jun 2015 21:56:59 +0200	[thread overview]
Message-ID: <87egktynp0.fsf@gnu.org> (raw)
In-Reply-To: <CAFtzXzPhSU4YjmVAN4TqTK_wvPTbKmuGdoO1Aj97bpmLSvsbjg@mail.gmail.com> (Manolis Ragkousis's message of "Tue, 30 Jun 2015 13:14:58 +0300")

Γειά σας!

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

  reply	other threads:[~2015-06-30 19:57 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-30 10:14 [PATCH] gnu: make-bootstrap: Produce the correct %glibc-bootstrap-tarball for Hurd systems Manolis Ragkousis
2015-06-30 19:56 ` Ludovic Courtès [this message]
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
  -- strict thread matches above, loose matches on Subject: below --
2016-06-17 16:09 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87egktynp0.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=Guix-devel@gnu.org \
    --cc=manolis837@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.