unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#36346] [PATCH] gnu: Allow building toolchain with non-default libc.
@ 2019-06-23 20:15 Carl Dong
  2019-07-05 22:46 ` Marius Bakke
  2019-07-08 19:41 ` Carl Dong
  0 siblings, 2 replies; 5+ messages in thread
From: Carl Dong @ 2019-06-23 20:15 UTC (permalink / raw)
  To: 36346; +Cc: Carl Dong

From: Carl Dong <accounts@carldong.me>

* gnu/packages/base.scm (make-gcc-libc): Make public.
* gnu/packages/commencement.scm (make-gcc-toolchain): Add 'libc'
  optional argument to specify using a non-default glibc package, also
  make public.
---
 gnu/packages/base.scm         |   2 +-
 gnu/packages/commencement.scm | 103 ++++++++++++++++++----------------
 2 files changed, 55 insertions(+), 50 deletions(-)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 15f35009a9..e40b40681b 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -1009,7 +1009,7 @@ with the Linux kernel.")
                   (("/bin/pwd") "pwd"))
                 #t))))))))
 
-(define (make-gcc-libc base-gcc libc)
+(define-public (make-gcc-libc base-gcc libc)
   "Return a GCC that targets LIBC."
   (package (inherit base-gcc)
            (name (string-append (package-name base-gcc) "-"
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index a8ec677cee..13912f1352 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -54,7 +54,8 @@
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
-  #:use-module (ice-9 regex))
+  #:use-module (ice-9 regex)
+  #:export (make-gcc-toolchain))
 
 ;;; Commentary:
 ;;;
@@ -1014,55 +1015,59 @@ COREUTILS-FINAL vs. COREUTILS, etc."
 ;;; GCC toolchain.
 ;;;
 
-(define (make-gcc-toolchain gcc)
+(define* (make-gcc-toolchain gcc
+                            #:optional
+                            (libc #f))
   "Return a complete toolchain for GCC."
-  (package
-    (name "gcc-toolchain")
-    (version (package-version gcc))
-    (source #f)
-    (build-system trivial-build-system)
-    (arguments
-     '(#:modules ((guix build union))
-       #:builder (begin
-                   (use-modules (ice-9 match)
-                                (srfi srfi-26)
-                                (guix build union))
-
-                   (let ((out (assoc-ref %outputs "out")))
-
-                     (match %build-inputs
-                       (((names . directories) ...)
-                        (union-build out directories)))
-
-                     (union-build (assoc-ref %outputs "debug")
-                                  (list (assoc-ref %build-inputs
-                                                   "libc-debug")))
-                     (union-build (assoc-ref %outputs "static")
-                                  (list (assoc-ref %build-inputs
-                                                   "libc-static")))
-                     #t))))
-
-    (native-search-paths (package-native-search-paths gcc))
-    (search-paths (package-search-paths gcc))
-
-    (license (package-license gcc))
-    (synopsis "Complete GCC tool chain for C/C++ development")
-    (description
-     "This package provides a complete GCC tool chain for C/C++ development to
-be installed in user profiles.  This includes GCC, as well as libc (headers
-and binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
-    (home-page "https://gcc.gnu.org/")
-    (outputs '("out" "debug" "static"))
-
-    ;; The main raison d'être of this "meta-package" is (1) to conveniently
-    ;; install everything that we need, and (2) to make sure ld-wrapper comes
-    ;; before Binutils' ld in the user's profile.
-    (inputs `(("gcc" ,gcc)
-              ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
-              ("binutils" ,binutils-final)
-              ("libc" ,glibc-final)
-              ("libc-debug" ,glibc-final "debug")
-              ("libc-static" ,glibc-final "static")))))
+  (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
+        (libc (if libc libc gcc-final)))
+    (package
+      (name (string-append (package-name gcc) "-toolchain"))
+      (version (package-version gcc))
+      (source #f)
+      (build-system trivial-build-system)
+      (arguments
+       '(#:modules ((guix build union))
+         #:builder (begin
+                     (use-modules (ice-9 match)
+                                  (srfi srfi-26)
+                                  (guix build union))
+
+                     (let ((out (assoc-ref %outputs "out")))
+
+                       (match %build-inputs
+                         (((names . directories) ...)
+                          (union-build out directories)))
+
+                       (union-build (assoc-ref %outputs "debug")
+                                    (list (assoc-ref %build-inputs
+                                                     "libc-debug")))
+                       (union-build (assoc-ref %outputs "static")
+                                    (list (assoc-ref %build-inputs
+                                                     "libc-static")))
+                       #t))))
+
+      (native-search-paths (package-native-search-paths gcc))
+      (search-paths (package-search-paths gcc))
+
+      (license (package-license gcc))
+      (synopsis "Complete GCC tool chain for C/C++ development")
+      (description
+       "This package provides a complete GCC tool chain for C/C++ development to
+be   installed in user profiles.  This includes GCC, as well as libc (headers
+an  d binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
+      (home-page "https://gcc.gnu.org/")
+      (outputs '("out" "debug" "static"))
+
+      ;; The main raison d'être of this "meta-package" is (1) to conveniently
+      ;; install everything that we need, and (2) to make sure ld-wrapper comes
+      ;; before Binutils' ld in the user's profile.
+      (inputs `(("gcc" ,gcc)
+                ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
+                ("binutils" ,binutils-final)
+                ("libc" ,libc)
+                ("libc-debug" ,libc "debug")
+                ("libc-static" ,libc "static"))))))
 
 (define-public gcc-toolchain-4.8
   (make-gcc-toolchain gcc-4.8))
-- 
2.22.0

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

* [bug#36346] [PATCH] gnu: Allow building toolchain with non-default libc.
  2019-06-23 20:15 [bug#36346] [PATCH] gnu: Allow building toolchain with non-default libc Carl Dong
@ 2019-07-05 22:46 ` Marius Bakke
  2019-07-07 14:42   ` Carl Dong
  2019-07-08 19:41 ` Carl Dong
  1 sibling, 1 reply; 5+ messages in thread
From: Marius Bakke @ 2019-07-05 22:46 UTC (permalink / raw)
  To: Carl Dong, 36346; +Cc: Carl Dong

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

Carl Dong <contact@carldong.me> writes:

> From: Carl Dong <accounts@carldong.me>
>
> * gnu/packages/base.scm (make-gcc-libc): Make public.
> * gnu/packages/commencement.scm (make-gcc-toolchain): Add 'libc'
>   optional argument to specify using a non-default glibc package, also
>   make public.

It would be easier to digest this patch if it came with an actual user
of this change.  Right now it complicates a very simple procedure for no
apparent reason.  Can you elaborate a bit on the use case?

Guix excels at creating bespoke toolchains like these.  It is easy to
express this change as a new 'make-gcc-toolchain-with-custom-libc'
procedure.  So I'm not sure if it's worth changing 'make-gcc-toolchain',
which serves a fairly specific use case.

I would expect any reasonably complex toolchain to need further tweaks,
and we cannot possibly support all such configuration inside
'make-gcc-toolchain'.

Does that make sense?

It does sound useful to make these procedures more generally accessible
however.  Perhaps 'make-gcc-toolchain' could be implemented in terms of
a more generic 'make-toolchain' interface?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

* [bug#36346] [PATCH] gnu: Allow building toolchain with non-default libc.
  2019-07-05 22:46 ` Marius Bakke
@ 2019-07-07 14:42   ` Carl Dong
  2019-07-08 15:34     ` Marius Bakke
  0 siblings, 1 reply; 5+ messages in thread
From: Carl Dong @ 2019-07-07 14:42 UTC (permalink / raw)
  To: Marius Bakke; +Cc: 36346@debbugs.gnu.org

Hi Marius!

> It would be easier to digest this patch if it came with an actual user of this
> change. Right now it complicates a very simple procedure for no apparent
> reason. Can you elaborate a bit on the use case?

Ah! This change is motivated by the work I've been doing in shifting the Bitcoin
release process to a Guix-based one. The binaries we produce aim to be
compatible with GLIBC_2_11, and we have glibc compat wrappers
(https://github.com/bitcoin/bitcoin/blob/f373beebbcc0c7d1160e02dc638a00b3e6831d98/src/compat/glibc_compat.cpp)
all the way up to 2.27 (since we need RISCV support). With Guix, I hope that we
don't have to keep updating compat wrappers anymore, and pin our toolchain glibc
version to a fixed one. See here for how I use this:
https://github.com/bitcoin/bitcoin/blob/e8dd4da0b287e0fe252c99bb4a7cb26c2e947b71/contrib/guix/packages/gcc-bitcoin.scm#L91

> Guix excels at creating bespoke toolchains like these. It is easy to express
> this change as a new 'make-gcc-toolchain-with-custom-libc' procedure. So I'm
> not sure if it's worth changing 'make-gcc-toolchain', which serves a fairly
> specific use case.
>
> I would expect any reasonably complex toolchain to need further tweaks, and we
> cannot possibly support all such configuration inside 'make-gcc-toolchain'.
>
> It does sound useful to make these procedures more generally accessible
> however. Perhaps 'make-gcc-toolchain' could be implemented in terms of a more
> generic 'make-toolchain' interface?

That all sound like promising solutions. My thought process comes from porting
riscv64 to Guix, where I realized that I had to override the default gcc version
(riscv64 requires gcc 7.1), glibc version (2.27), and kernel headers version
(4.15). That makes me think that the sensible list of things to be overridable
for a toolchain would be those three, in case of future architectures. I've
submitted previous patches to cross-base.scm that added the ability to
parameterize these three, and this patch was simply doing the same for
gcc-toolchain.

Anyway, please let me know which approach you'd prefer, and I'd be very happy to
implement and change. :-)


Cheers,
Carl Dong
contact@carldong.me
"I fight for the users"

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

* [bug#36346] [PATCH] gnu: Allow building toolchain with non-default libc.
  2019-07-07 14:42   ` Carl Dong
@ 2019-07-08 15:34     ` Marius Bakke
  0 siblings, 0 replies; 5+ messages in thread
From: Marius Bakke @ 2019-07-08 15:34 UTC (permalink / raw)
  To: Carl Dong; +Cc: 36346@debbugs.gnu.org

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

Carl Dong <contact@carldong.me> writes:

> Hi Marius!
>
>> It would be easier to digest this patch if it came with an actual user of this
>> change. Right now it complicates a very simple procedure for no apparent
>> reason. Can you elaborate a bit on the use case?
>
> Ah! This change is motivated by the work I've been doing in shifting the Bitcoin
> release process to a Guix-based one. The binaries we produce aim to be
> compatible with GLIBC_2_11, and we have glibc compat wrappers
> (https://github.com/bitcoin/bitcoin/blob/f373beebbcc0c7d1160e02dc638a00b3e6831d98/src/compat/glibc_compat.cpp)
> all the way up to 2.27 (since we need RISCV support). With Guix, I hope that we
> don't have to keep updating compat wrappers anymore, and pin our toolchain glibc
> version to a fixed one. See here for how I use this:
> https://github.com/bitcoin/bitcoin/blob/e8dd4da0b287e0fe252c99bb4a7cb26c2e947b71/contrib/guix/packages/gcc-bitcoin.scm#L91

I see, thanks for the links.

>> Guix excels at creating bespoke toolchains like these. It is easy to express
>> this change as a new 'make-gcc-toolchain-with-custom-libc' procedure. So I'm
>> not sure if it's worth changing 'make-gcc-toolchain', which serves a fairly
>> specific use case.
>>
>> I would expect any reasonably complex toolchain to need further tweaks, and we
>> cannot possibly support all such configuration inside 'make-gcc-toolchain'.
>>
>> It does sound useful to make these procedures more generally accessible
>> however. Perhaps 'make-gcc-toolchain' could be implemented in terms of a more
>> generic 'make-toolchain' interface?
>
> That all sound like promising solutions. My thought process comes from porting
> riscv64 to Guix, where I realized that I had to override the default gcc version
> (riscv64 requires gcc 7.1), glibc version (2.27), and kernel headers version
> (4.15). That makes me think that the sensible list of things to be overridable
> for a toolchain would be those three, in case of future architectures. I've
> submitted previous patches to cross-base.scm that added the ability to
> parameterize these three, and this patch was simply doing the same for
> gcc-toolchain.
>
> Anyway, please let me know which approach you'd prefer, and I'd be very happy to
> implement and change. :-)

I feel better about this patch now that I've seen its uses.  It would be
great if you could leave some comments at the top of the definition
about what the libc argument is for, and maybe even a usage example.

Otherwise it LGTM.  Let's hold it for a couple of days in case others
have additional suggestions.

Thanks!

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

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

* [bug#36346] [PATCH] gnu: Allow building toolchain with non-default libc.
  2019-06-23 20:15 [bug#36346] [PATCH] gnu: Allow building toolchain with non-default libc Carl Dong
  2019-07-05 22:46 ` Marius Bakke
@ 2019-07-08 19:41 ` Carl Dong
  1 sibling, 0 replies; 5+ messages in thread
From: Carl Dong @ 2019-07-08 19:41 UTC (permalink / raw)
  To: 36346; +Cc: Carl Dong

From: Carl Dong <accounts@carldong.me>

Here's the updated patch, with the clarifications requested.

* gnu/packages/base.scm (make-gcc-libc): Make public.
* gnu/packages/commencement.scm (make-gcc-toolchain): Add 'libc'
  optional argument to specify using a non-default glibc package, also
  make public.
---
 gnu/packages/base.scm         |   2 +-
 gnu/packages/commencement.scm | 111 +++++++++++++++++++---------------
 2 files changed, 62 insertions(+), 51 deletions(-)

diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index 15f35009a9..e40b40681b 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -1009,7 +1009,7 @@ with the Linux kernel.")
                   (("/bin/pwd") "pwd"))
                 #t))))))))
 
-(define (make-gcc-libc base-gcc libc)
+(define-public (make-gcc-libc base-gcc libc)
   "Return a GCC that targets LIBC."
   (package (inherit base-gcc)
            (name (string-append (package-name base-gcc) "-"
diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm
index a8ec677cee..4a41e2abf3 100644
--- a/gnu/packages/commencement.scm
+++ b/gnu/packages/commencement.scm
@@ -54,7 +54,8 @@
   #:use-module (srfi srfi-26)
   #:use-module (ice-9 vlist)
   #:use-module (ice-9 match)
-  #:use-module (ice-9 regex))
+  #:use-module (ice-9 regex)
+  #:export (make-gcc-toolchain))
 
 ;;; Commentary:
 ;;;
@@ -1014,55 +1015,65 @@ COREUTILS-FINAL vs. COREUTILS, etc."
 ;;; GCC toolchain.
 ;;;
 
-(define (make-gcc-toolchain gcc)
-  "Return a complete toolchain for GCC."
-  (package
-    (name "gcc-toolchain")
-    (version (package-version gcc))
-    (source #f)
-    (build-system trivial-build-system)
-    (arguments
-     '(#:modules ((guix build union))
-       #:builder (begin
-                   (use-modules (ice-9 match)
-                                (srfi srfi-26)
-                                (guix build union))
-
-                   (let ((out (assoc-ref %outputs "out")))
-
-                     (match %build-inputs
-                       (((names . directories) ...)
-                        (union-build out directories)))
-
-                     (union-build (assoc-ref %outputs "debug")
-                                  (list (assoc-ref %build-inputs
-                                                   "libc-debug")))
-                     (union-build (assoc-ref %outputs "static")
-                                  (list (assoc-ref %build-inputs
-                                                   "libc-static")))
-                     #t))))
-
-    (native-search-paths (package-native-search-paths gcc))
-    (search-paths (package-search-paths gcc))
-
-    (license (package-license gcc))
-    (synopsis "Complete GCC tool chain for C/C++ development")
-    (description
-     "This package provides a complete GCC tool chain for C/C++ development to
-be installed in user profiles.  This includes GCC, as well as libc (headers
-and binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
-    (home-page "https://gcc.gnu.org/")
-    (outputs '("out" "debug" "static"))
-
-    ;; The main raison d'être of this "meta-package" is (1) to conveniently
-    ;; install everything that we need, and (2) to make sure ld-wrapper comes
-    ;; before Binutils' ld in the user's profile.
-    (inputs `(("gcc" ,gcc)
-              ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
-              ("binutils" ,binutils-final)
-              ("libc" ,glibc-final)
-              ("libc-debug" ,glibc-final "debug")
-              ("libc-static" ,glibc-final "static")))))
+;; Using the following procedure, a gcc toolchain targeting glibc-2.27 can be
+;; instantiated like this:
+;;
+;; (define-public gcc-glibc-2.27-toolchain
+;;   (make-gcc-toolchain gcc glibc-2.27))
+
+(define* (make-gcc-toolchain gcc
+                            #:optional
+                            (libc #f))
+  "Return a complete toolchain for GCC. If LIBC is specified, target that libc."
+  (let ((gcc (if libc (make-gcc-libc gcc libc) gcc))
+        (libc (if libc libc glibc-final)))
+    (package
+      (name (string-append (package-name gcc) "-toolchain"))
+      (version (package-version gcc))
+      (source #f)
+      (build-system trivial-build-system)
+      (arguments
+       '(#:modules ((guix build union))
+         #:builder (begin
+                     (use-modules (ice-9 match)
+                                  (srfi srfi-26)
+                                  (guix build union))
+
+                     (let ((out (assoc-ref %outputs "out")))
+
+                       (match %build-inputs
+                         (((names . directories) ...)
+                          (union-build out directories)))
+
+                       (union-build (assoc-ref %outputs "debug")
+                                    (list (assoc-ref %build-inputs
+                                                     "libc-debug")))
+                       (union-build (assoc-ref %outputs "static")
+                                    (list (assoc-ref %build-inputs
+                                                     "libc-static")))
+                       #t))))
+
+      (native-search-paths (package-native-search-paths gcc))
+      (search-paths (package-search-paths gcc))
+
+      (license (package-license gcc))
+      (synopsis "Complete GCC tool chain for C/C++ development")
+      (description
+       "This package provides a complete GCC tool chain for C/C++ development to
+be   installed in user profiles.  This includes GCC, as well as libc (headers
+an  d binaries, plus debugging symbols in the @code{debug} output), and Binutils.")
+      (home-page "https://gcc.gnu.org/")
+      (outputs '("out" "debug" "static"))
+
+      ;; The main raison d'être of this "meta-package" is (1) to conveniently
+      ;; install everything that we need, and (2) to make sure ld-wrapper comes
+      ;; before Binutils' ld in the user's profile.
+      (inputs `(("gcc" ,gcc)
+                ("ld-wrapper" ,(car (assoc-ref %final-inputs "ld-wrapper")))
+                ("binutils" ,binutils-final)
+                ("libc" ,libc)
+                ("libc-debug" ,libc "debug")
+                ("libc-static" ,libc "static"))))))
 
 (define-public gcc-toolchain-4.8
   (make-gcc-toolchain gcc-4.8))
-- 
2.22.0

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

end of thread, other threads:[~2019-07-08 19:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-23 20:15 [bug#36346] [PATCH] gnu: Allow building toolchain with non-default libc Carl Dong
2019-07-05 22:46 ` Marius Bakke
2019-07-07 14:42   ` Carl Dong
2019-07-08 15:34     ` Marius Bakke
2019-07-08 19:41 ` Carl Dong

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