diff mbox series

[bug#35611,1/2] gnu: cross-base: Allow using non-defaultglibc.

Message ID lIPG7Aip1kvx4dmDzDQOSQ8OGS0G9_f3COv4CgIvX_FKd56k9096gjgd2FrXPGXcO4scp8HrRHMpEipnDtjOGI0MwCep2Vi3r-utcOX2eG8=@carldong.me
State Accepted
Headers show
Series [bug#35611,1/2] gnu: cross-base: Allow using non-defaultglibc. | expand

Checks

Context Check Description
cbaines/applying patch success Successfully applied

Commit Message

Carl Dong May 6, 2019, 10:21 p.m. UTC
* 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(-)

Comments

Ludovic Courtès May 12, 2019, 9:40 p.m. UTC | #1
Hi Carl,

Carl Dong <accounts@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’.
Carl Dong May 13, 2019, 2:46 a.m. UTC | #2
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@carldong.me
"I fight for the users"
Ludovic Courtès May 13, 2019, 7:45 a.m. UTC | #3
Hi Carl,

Carl Dong <accounts@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’.
Ludovic Courtès May 13, 2019, 10:09 a.m. UTC | #4
Carl Dong <accounts@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’.
diff mbox series

Patch

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: