GNU bug report logs - #35611
[PATCH 1/2] gnu: cross-base: Allow using non-default glibc.

Previous Next

Package: guix-patches;

Reported by: Carl Dong <accounts <at> carldong.me>

Date: Mon, 6 May 2019 22:23:01 UTC

Severity: normal

Tags: patch

Done: Ludovic Courtès <ludo <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 35611 in the body.
You can then email your comments to 35611 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#35611; Package guix-patches. (Mon, 06 May 2019 22:23:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Carl Dong <accounts <at> carldong.me>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 06 May 2019 22:23:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <accounts <at> carldong.me>
To: guix-patches <at> gnu.org
Cc: Carl Dong <accounts <at> carldong.me>
Subject: [PATCH 1/2] gnu: cross-base: Allow using non-default glibc.
Date: Mon, 06 May 2019 22:21:43 +0000
* gnu/packages/cross-base.scm (cross-libc, native-libc, cross-newlib?):
  Add xlibc optional argument to specify using a non-default glibc
  package.
---
 gnu/packages/cross-base.scm | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm
index 25caacb723..51e9e2962a 100644
--- a/gnu/packages/cross-base.scm
+++ b/gnu/packages/cross-base.scm
@@ -422,14 +422,15 @@ target that libc."
 
 (define* (cross-libc target
                      #:optional
+                     (xlibc glibc)
                      (xgcc (cross-gcc target))
                      (xbinutils (cross-binutils target))
                      (xheaders (cross-kernel-headers target)))
-  "Return a libc cross-built for TARGET, a GNU triplet.  Use XGCC and
-XBINUTILS and the cross tool chain."
-  (if (cross-newlib? target)
-      (native-libc target)
-      (let ((libc glibc))
+  "Return XLIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
+and the cross tool chain."
+  (if (cross-newlib? target xlibc)
+      (native-libc target xlibc)
+      (let ((libc xlibc))
         (package (inherit libc)
           (name (string-append "glibc-cross-" target))
           (arguments
@@ -502,13 +503,17 @@ XBINUTILS and the cross tool chain."
                            ,@(package-inputs libc)     ;FIXME: static-bash
                            ,@(package-native-inputs libc)))))))
 
-(define (native-libc target)
+(define* (native-libc target
+                     #:optional
+                     (xlibc glibc))
   (if (target-mingw? target)
       mingw-w64
-      glibc))
+      xlibc))
 
-(define (cross-newlib? target)
-  (not (eq? (native-libc target) glibc)))
+(define* (cross-newlib? target
+                       #:optional
+                       (xlibc glibc))
+  (not (eq? (native-libc target xlibc) xlibc)))
 
 
 ;;; Concrete cross tool chains are instantiated like this:
-- 
2.21.0






Information forwarded to guix-patches <at> gnu.org:
bug#35611; Package guix-patches. (Mon, 06 May 2019 22:35:02 GMT) Full text and rfc822 format available.

Message #8 received at 35611 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <contact <at> carldong.me>
To: "35611 <at> debbugs.gnu.org" <35611 <at> debbugs.gnu.org>
Subject: [PATCH 2/2] gnu: Allow building gcc with non-default libc.
Date: Mon, 06 May 2019 22:34:15 +0000
* gnu/packages/base.scm (make-gcc-libc): New procedure, returns a gcc
  that targets a specified libc.
  (gcc-glibc-2.26, gcc-glibc-2.27): New public variables.
---
 gnu/packages/base.scm | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index e33e3c52c8..5c0cd36c14 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -1009,6 +1009,35 @@ with the Linux kernel.")
                   (("/bin/pwd") "pwd"))
                 #t))))))))

+(define (make-gcc-libc base-gcc libc)
+  "Return a GCC that targets LIBC."
+  (package (inherit base-gcc)
+           (name (string-append (package-name base-gcc) "-"
+                                (package-name libc) "-"
+                                (package-version libc)))
+           (arguments
+            (substitute-keyword-arguments
+             (ensure-keyword-arguments (package-arguments base-gcc)
+                                       '(#:implicit-inputs? #f))
+             ((#:make-flags flags)
+              `(let ((libc (assoc-ref %build-inputs "libc")))
+                 ;; FLAGS_FOR_TARGET are needed for the target libraries to receive
+                 ;; the -Bxxx for the startfiles.
+                 (cons (string-append "FLAGS_FOR_TARGET=-B" libc "/lib")
+                       ,flags)))))
+           (native-inputs
+            `(("libc" ,libc)
+              ("libc:static" ,libc "static")
+              ,@(append (package-inputs base-gcc)
+                        (fold alist-delete (%final-inputs) '("libc" "libc:static")))))
+           (inputs '())))
+
+(define-public gcc-glibc-2.27
+  (make-gcc-libc gcc glibc-2.27))
+
+(define-public gcc-glibc-2.26
+  (make-gcc-libc gcc glibc-2.26))
+
 (define-public (make-glibc-locales glibc)
   (package
     (inherit glibc)
--
2.21.0






Information forwarded to guix-patches <at> gnu.org:
bug#35611; Package guix-patches. (Sun, 12 May 2019 21:41:01 GMT) Full text and rfc822 format available.

Message #11 received at 35611 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <accounts <at> carldong.me>
Cc: 35611 <at> debbugs.gnu.org
Subject: Re: [bug#35611] [PATCH 1/2] gnu: cross-base: Allow using non-default
 glibc.
Date: Sun, 12 May 2019 23:40:23 +0200
Hi Carl,

Carl Dong <accounts <at> carldong.me> skribis:

> * gnu/packages/cross-base.scm (cross-libc, native-libc, cross-newlib?):
>   Add xlibc optional argument to specify using a non-default glibc
>   package.

[...]

>  (define* (cross-libc target
>                       #:optional
> +                     (xlibc glibc)
>                       (xgcc (cross-gcc target))
>                       (xbinutils (cross-binutils target))
>                       (xheaders (cross-kernel-headers target)))
> -  "Return a libc cross-built for TARGET, a GNU triplet.  Use XGCC and
> -XBINUTILS and the cross tool chain."
> -  (if (cross-newlib? target)
> -      (native-libc target)
> -      (let ((libc glibc))
> +  "Return XLIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS
> +and the cross tool chain."

Really a detail, but for clarity I would change “xlibc” to “libc”,
because this argument denotes a C library, not a cross-compiled C
library.

Ditto in other places.

You can send an updated patch or I can make this change on your behalf
if you prefer, let me know!

> -(define (native-libc target)
> +(define* (native-libc target
> +                     #:optional
> +                     (xlibc glibc))
>    (if (target-mingw? target)
>        mingw-w64
> -      glibc))
> +      xlibc))

This procedure is starting to look weird.  :-)  I wonder if we should
inline it at the call sites, but we can look into it later.

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#35611; Package guix-patches. (Sun, 12 May 2019 21:42:02 GMT) Full text and rfc822 format available.

Message #14 received at 35611 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <contact <at> carldong.me>
Cc: "35611 <at> debbugs.gnu.org" <35611 <at> debbugs.gnu.org>
Subject: Re: [bug#35611] [PATCH 2/2] gnu: Allow building gcc with non-default
 libc.
Date: Sun, 12 May 2019 23:41:19 +0200
Carl Dong <contact <at> carldong.me> skribis:

> * gnu/packages/base.scm (make-gcc-libc): New procedure, returns a gcc
>   that targets a specified libc.
>   (gcc-glibc-2.26, gcc-glibc-2.27): New public variables.

Nice, LGTM!

(I’ll push it along with patch #1.)




Information forwarded to guix-patches <at> gnu.org:
bug#35611; Package guix-patches. (Mon, 13 May 2019 02:47:01 GMT) Full text and rfc822 format available.

Message #17 received at 35611 <at> debbugs.gnu.org (full text, mbox):

From: Carl Dong <accounts <at> carldong.me>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: "35611 <at> debbugs.gnu.org" <35611 <at> debbugs.gnu.org>
Subject: Re: [bug#35611] [PATCH 1/2] gnu: cross-base: Allow using non-default
 glibc.
Date: Mon, 13 May 2019 02:46:39 +0000
Hi Ludovic,

> Really a detail, but for clarity I would change “xlibc” to “libc”, because
> this argument denotes a C library, not a cross-compiled C library.
>
> Ditto in other places.
>
> You can send an updated patch or I can make this change on your behalf if you
> prefer, let me know!

Ah yes! That does make it more clear. Could you make this change for me? Thanks!

> This procedure is starting to look weird. :-) I wonder if we should inline it
> at the call sites, but we can look into it later.

Haha that's what I thought too... Inlining would probably make the most sense.
I'll submit another patch to this effect at some point!

Thank you so much for your help. Have an excellent day!

Cheers,
Carl Dong
accounts <at> carldong.me
"I fight for the users"





Reply sent to Ludovic Courtès <ludo <at> gnu.org>:
You have taken responsibility. (Mon, 13 May 2019 07:47:02 GMT) Full text and rfc822 format available.

Notification sent to Carl Dong <accounts <at> carldong.me>:
bug acknowledged by developer. (Mon, 13 May 2019 07:47:03 GMT) Full text and rfc822 format available.

Message #22 received at 35611-done <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <accounts <at> carldong.me>
Cc: "35611 <at> debbugs.gnu.org" <35611-done <at> debbugs.gnu.org>
Subject: Re: [bug#35611] [PATCH 1/2] gnu: cross-base: Allow using non-default
 glibc.
Date: Mon, 13 May 2019 09:45:56 +0200
Hi Carl,

Carl Dong <accounts <at> carldong.me> skribis:

>> Really a detail, but for clarity I would change “xlibc” to “libc”, because
>> this argument denotes a C library, not a cross-compiled C library.
>>
>> Ditto in other places.
>>
>> You can send an updated patch or I can make this change on your behalf if you
>> prefer, let me know!
>
> Ah yes! That does make it more clear. Could you make this change for me? Thanks!

Done!

>> This procedure is starting to look weird. :-) I wonder if we should inline it
>> at the call sites, but we can look into it later.
>
> Haha that's what I thought too... Inlining would probably make the most sense.
> I'll submit another patch to this effect at some point!

Awesome.  :-)

Thank you!

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#35611; Package guix-patches. (Mon, 13 May 2019 10:10:03 GMT) Full text and rfc822 format available.

Message #25 received at 35611 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Carl Dong <accounts <at> carldong.me>
Cc: "35611 <at> debbugs.gnu.org" <35611 <at> debbugs.gnu.org>
Subject: Re: [bug#35611] [PATCH 1/2] gnu: cross-base: Allow using non-default
 glibc.
Date: Mon, 13 May 2019 12:09:49 +0200
Carl Dong <accounts <at> carldong.me> skribis:

>> Really a detail, but for clarity I would change “xlibc” to “libc”, because
>> this argument denotes a C library, not a cross-compiled C library.
>>
>> Ditto in other places.
>>
>> You can send an updated patch or I can make this change on your behalf if you
>> prefer, let me know!
>
> Ah yes! That does make it more clear. Could you make this change for me? Thanks!

In commit 04a3ecc79ec01242acd0928f89bf982f50c866df, I had to remove the
pre-defined uses of ‘make-gcc-libc’ because of the circular top-level
references they introduced.

I suppose they were here mostly for illustrative purposes though, so
hopefully that’s OK.  Let me know!

Ludo’.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 10 Jun 2019 11:24:06 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 292 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.