Message ID | fwHqadVUPH-92wbCcmXEdA_4oFs1qI2MdeQOVljG4DcOQDwq16MlQpcw0vaAqX1dwRSbrGA5Qej3MOCn_6vIj8G9FOk-CYMEVZezH1ysoG8=@carldong.me |
---|---|
State | Accepted |
Headers | show |
Series | [bug#36346] gnu: Allow building toolchain with non-default libc. | expand |
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?
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"
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!
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))
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(-)