From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 28 15:53:26 2020 Received: (at submit) by debbugs.gnu.org; 28 Sep 2020 19:53:26 +0000 Received: from localhost ([127.0.0.1]:54066 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzDB-0002q6-O6 for submit@debbugs.gnu.org; Mon, 28 Sep 2020 15:53:25 -0400 Received: from lists.gnu.org ([209.51.188.17]:43158) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzD9-0002py-FX for submit@debbugs.gnu.org; Mon, 28 Sep 2020 15:53:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kMzD9-00022S-6f for guix-patches@gnu.org; Mon, 28 Sep 2020 15:53:23 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51101) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMzD7-0004rn-SZ; Mon, 28 Sep 2020 15:53:21 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43764 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMzD6-0002Fm-Jd; Mon, 28 Sep 2020 15:53:21 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: guix-patches@gnu.org Subject: [PATCH 0/5] Add '--with-toolchain' package transformation option Date: Mon, 28 Sep 2020 21:53:05 +0200 Message-Id: <20200928195305.30096-1-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: submit Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) From: Ludovic Courtès Hello! This patch series adds the ‘--with-toolchain’ option. I’ve tested it with gcc-toolchain@10 and clang-toolchain, and I can say it works as advertised. :-) One thing I wasn’t entirely sure about: ‘--with-toolchain’ changes the toolchain of the specified package, not that of its dependents. This assumes that the toolchains all follow the same ABI. This is the case for C, apparently, maybe not for C++. Should it instead change to toolchain of the package’s dependents as well? Something like: guix build guile --with-toolchain=guile@3.0.4=clang-toolchain generates working code. Another issue is that since we use ‘package-input-rewriting/spec’, we can’t change the toolchain of core packages like Guile or Perl without rebuilding the world. For example, if we omit “@3.0.4” in the example above, we rebuild a “guile” package deep down and everything that follows (aka. “the world”). Another option I considered was to graft the package that ‘--with-toolchain’ targets instead of rebuilding its dependents. Again that’d only work if the resulting binaries are ABI-compatible, but maybe that’s a reasonable assumption. It would definitely save build time. Should it be grafted, or should there be a separate option to do that? Thoughts? Last, when doing ‘--with-toolchain=foo=gcc-toolchain’, I noticed that ‘foo’ would keep a reference to ‘gcc-toolchain’ for some obscure reasons: --8<---------------cut here---------------start------------->8--- $ ./pre-inst-env guix build hello --with-toolchain=hello=gcc-toolchain /gnu/store/qi7pqqsxhbwmy75hl43j7l0aw1xr7r42-hello-2.10 $ grep -r $(guix build gcc-toolchain | head -2 |tail -1) /gnu/store/qi7pqqsxhbwmy75hl43j7l0aw1xr7r42-hello-2.10 Duuma dosiero /gnu/store/qi7pqqsxhbwmy75hl43j7l0aw1xr7r42-hello-2.10/bin/hello kongruas $ strings /gnu/store/qi7pqqsxhbwmy75hl43j7l0aw1xr7r42-hello-2.10/bin/hello | grep $(guix build gcc-toolchain | head -2 |tail -1) /gnu/store/fa6wj5bxkj5ll1d7292a70knmyl7a0cr-glibc-2.31/lib:/gnu/store/qj38f3vi4q1d7z30hkpaxyajv49rwamb-gcc-10.2.0-lib/lib:/gnu/store/qj38f3vi4q1d7z30hkpaxyajv49rwamb-gcc-10.2.0-lib/lib/gcc/x86_64-unknown-linux-gnu/10.2.0/../../..:/gnu/store/pknm43xsza6nlc7bn27djip8fis92akd-gcc-toolchain-10.2.0/lib --8<---------------cut here---------------end--------------->8--- Not a showstopper but would be nice to address. Feedback welcome! Ludo’. Ludovic Courtès (5): gnu: gcc-toolchain: Add 'GUIX_LOCPATH' to the search paths. gnu: clang-toolchain: Add 'GUIX_LOCPATH' to the search paths. gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. packages: Add 'package-with-toolchain'. guix build: Add '--with-toolchain'. doc/guix.texi | 61 +++++++++++++++++++++++++++++++++++ gnu/packages/commencement.scm | 8 +++-- gnu/packages/llvm.scm | 12 ++++++- guix/build-system.scm | 35 ++++++++++++++++++-- guix/packages.scm | 9 ++++++ guix/scripts/build.scm | 40 +++++++++++++++++++++++ tests/packages.scm | 20 ++++++++++++ tests/scripts-build.scm | 30 +++++++++++++++++ 8 files changed, 210 insertions(+), 5 deletions(-) -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 28 15:57:03 2020 Received: (at 43679) by debbugs.gnu.org; 28 Sep 2020 19:57:03 +0000 Received: from localhost ([127.0.0.1]:54072 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGh-0002w6-9V for submit@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:03 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55274) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGe-0002vL-Jw for 43679@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:01 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51183) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMzGZ-0005aC-8v; Mon, 28 Sep 2020 15:56:55 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43782 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMzGX-0003Ee-SE; Mon, 28 Sep 2020 15:56:54 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH 1/5] gnu: gcc-toolchain: Add 'GUIX_LOCPATH' to the search paths. Date: Mon, 28 Sep 2020 21:56:44 +0200 Message-Id: <20200928195648.30256-1-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This allows 'gcc-toolchain' to be used as a drop-in replacement for the default tool chain through '--with-toolchain=gcc-toolchain'. * gnu/packages/commencement.scm (make-gcc-toolchain)[native-search-paths] [search-paths]: Append LIBC's search paths. --- gnu/packages/commencement.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index 4041d5bb89..0938bc3d46 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -3856,8 +3856,12 @@ COREUTILS-FINAL vs. COREUTILS, etc." "libc-static"))) #t)))) - (native-search-paths (package-native-search-paths gcc)) - (search-paths (package-search-paths gcc)) + (native-search-paths + (append (package-native-search-paths gcc) + (package-native-search-paths libc))) ;GUIX_LOCPATH + (search-paths + (append (package-search-paths gcc) + (package-search-paths libc))) (license (package-license gcc)) (synopsis "Complete GCC tool chain for C/C++ development") -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 28 15:57:07 2020 Received: (at 43679) by debbugs.gnu.org; 28 Sep 2020 19:57:07 +0000 Received: from localhost ([127.0.0.1]:54077 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGl-0002wW-KO for submit@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGi-0002vY-Pk for 43679@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51184) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMzGd-0005bO-2q; Mon, 28 Sep 2020 15:56:59 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43782 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMzGZ-0003Ee-Ju; Mon, 28 Sep 2020 15:56:58 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH 2/5] gnu: clang-toolchain: Add 'GUIX_LOCPATH' to the search paths. Date: Mon, 28 Sep 2020 21:56:45 +0200 Message-Id: <20200928195648.30256-2-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928195648.30256-1-ludo@gnu.org> References: <20200928195648.30256-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) From: Ludovic Courtès * gnu/packages/llvm.scm (make-clang-toolchain)[native-search-paths]: Add 'GUIX_LOCPATH'. --- gnu/packages/llvm.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 15078a1168..4b42c4921a 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -484,7 +484,11 @@ code analysis tools.") "libc-static"))) #t)))) - (native-search-paths (package-native-search-paths clang)) + (native-search-paths + (append (package-native-search-paths clang) + (list (search-path-specification ;copied from glibc + (variable "GUIX_LOCPATH") + (files '("lib/locale")))))) (search-paths (package-search-paths clang)) (license (package-license clang)) -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 28 15:57:08 2020 Received: (at 43679) by debbugs.gnu.org; 28 Sep 2020 19:57:08 +0000 Received: from localhost ([127.0.0.1]:54079 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGl-0002wY-RR for submit@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55308) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGj-0002vd-RB for 43679@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51186) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMzGe-0005bo-Gd; Mon, 28 Sep 2020 15:57:00 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43782 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMzGd-0003Ee-9n; Mon, 28 Sep 2020 15:56:59 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH 3/5] gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. Date: Mon, 28 Sep 2020 21:56:46 +0200 Message-Id: <20200928195648.30256-3-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928195648.30256-1-ludo@gnu.org> References: <20200928195648.30256-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) From: Ludovic Courtès * gnu/packages/llvm.scm (make-clang-toolchain)[arguments]: Create 'cc' and 'c++' symlinks. --- gnu/packages/llvm.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 4b42c4921a..361b39710b 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -476,6 +476,12 @@ code analysis tools.") (((names . directories) ...) (union-build out directories))) + ;; Create 'cc' and 'c++' so that one can use it as a + ;; drop-in replacement for the default tool chain and + ;; have configure scripts find the compiler. + (symlink "clang" (string-append out "/bin/cc")) + (symlink "clang++" (string-append out "/bin/c++")) + (union-build (assoc-ref %outputs "debug") (list (assoc-ref %build-inputs "libc-debug"))) -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 28 15:57:14 2020 Received: (at 43679) by debbugs.gnu.org; 28 Sep 2020 19:57:14 +0000 Received: from localhost ([127.0.0.1]:54082 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGs-0002wy-4P for submit@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55326) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGk-0002w3-Vh for 43679@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:07 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51189) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMzGf-0005by-L3; Mon, 28 Sep 2020 15:57:01 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43782 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMzGe-0003Ee-SD; Mon, 28 Sep 2020 15:57:01 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH 4/5] packages: Add 'package-with-toolchain'. Date: Mon, 28 Sep 2020 21:56:47 +0200 Message-Id: <20200928195648.30256-4-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928195648.30256-1-ludo@gnu.org> References: <20200928195648.30256-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * guix/build-system.scm (build-system-with-toolchain): New procedure. * guix/packages.scm (package-with-toolchain): New procedure. * tests/packages.scm ("package-with-toolchain"): New test. * doc/guix.texi (package Reference): Document 'package-with-toolchain'. (Build Systems): Mention it. --- doc/guix.texi | 32 ++++++++++++++++++++++++++++++++ guix/build-system.scm | 35 +++++++++++++++++++++++++++++++++-- guix/packages.scm | 9 +++++++++ tests/packages.scm | 20 ++++++++++++++++++++ 4 files changed, 94 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index c600d577ac..03836bbf7b 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6506,6 +6506,35 @@ cross-compiling: It is an error to refer to @code{this-package} outside a package definition. @end deffn +Because packages are regular Scheme objects that capture a complete +dependency graph and associated build procedures, it is often useful to +write procedures that take a package and return a modified version +thereof according to some parameters. Below are a few examples. + +@cindex tool chain, choosing a package's tool chain +@deffn {Scheme Procedure} package-with-toolchain @var{package} @var{toolchain} +Return a variant of @var{package} that uses @var{toolchain} instead of +the default GNU toolchain. @var{toolchain} must be a list of inputs +(label/package tuples) providing equivalent functionality, such as the +@code{gcc-toolchain} package. + +The example below returns a variant of the @code{hello} package built +with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the +GNU C Library) instead of the default tool chain: + +@lisp +(let ((toolchain (specification->package "gcc-toolchain@@10"))) + (package-with-toolchain hello `(("toolchain" ,toolchain)))) +@end lisp + +The build tool chain is part of the @dfn{implicit inputs} of +packages---it's usually not listed as part of the various ``inputs'' +fields and is instead pulled in by the build system. Consequently, this +procedure works by changing the build system of @var{package} so that it +pulls in @var{toolchain} instead of the defaults. @ref{Build Systems}, +for more on build systems. +@end deffn + @node origin Reference @subsection @code{origin} Reference @@ -6642,6 +6671,9 @@ ornamentation---in other words, a bag is a lower-level representation of a package, which includes all the inputs of that package, including some that were implicitly added by the build system. This intermediate representation is then compiled to a derivation (@pxref{Derivations}). +The @code{package-with-toolchain} is an example of a way to change the +implicit inputs that a package's build system pulls in (@pxref{package +Reference, @code{package-with-toolchain}}). Build systems accept an optional list of @dfn{arguments}. In package definitions, these are passed @i{via} the @code{arguments} field diff --git a/guix/build-system.scm b/guix/build-system.scm index 4174972b98..0b33b91aa0 100644 --- a/guix/build-system.scm +++ b/guix/build-system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014 Ludovic Courtès +;;; Copyright © 2012, 2013, 2014, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,6 +18,7 @@ (define-module (guix build-system) #:use-module (guix records) + #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (build-system build-system? @@ -37,7 +38,9 @@ bag-arguments bag-build - make-bag)) + make-bag + + build-system-with-toolchain)) (define-record-type* build-system make-build-system build-system? @@ -98,3 +101,31 @@ intermediate representation just above derivations." #:outputs outputs #:target target arguments)))) + +(define (build-system-with-toolchain bs toolchain) + "Return a variant of BS, a build system, that uses TOOLCHAIN instead of the +default GNU toolchain. TOOLCHAIN must be a list of inputs (label/package +tuples) providing equivalent functionality, such as the 'gcc-toolchain' +package." + (define lower + (build-system-lower bs)) + + (define toolchain-packages + ;; These are the GNU toolchain packages pulled in by GNU-BUILD-SYSTEM and + ;; all the build systems that inherit from it. Keep the list in sync with + ;; 'standard-packages' in (guix build-system gnu). + '("gcc" "binutils" "libc" "libc:static" "ld-wrapper")) + + (define (lower* . args) + (let ((lowered (apply lower args))) + (bag + (inherit lowered) + (build-inputs + (append (fold alist-delete + (bag-build-inputs lowered) + toolchain-packages) + toolchain))))) + + (build-system + (inherit bs) + (lower lower*))) diff --git a/guix/packages.scm b/guix/packages.scm index 4f2bb432be..4764461949 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -124,6 +124,7 @@ package-patched-vulnerabilities package-with-patches package-with-extra-patches + package-with-toolchain package/inherit transitive-input-references @@ -790,6 +791,14 @@ specifies modules in scope when evaluating SNIPPET." (append (origin-patches (package-source original)) patches))) +(define (package-with-toolchain package toolchain) + "Return a variant of PACKAGE that uses TOOLCHAIN instead of the default GNU +toolchain. TOOLCHAIN must be a list of inputs (label/package tuples) +providing equivalent functionality, such as the 'gcc-toolchain' package." + (let ((bs (package-build-system package))) + (package/inherit package + (build-system (build-system-with-toolchain bs toolchain))))) + (define (transitive-inputs inputs) "Return the closure of INPUTS when considering the 'propagated-inputs' edges. Omit duplicate inputs, except for those already present in INPUTS diff --git a/tests/packages.scm b/tests/packages.scm index af8941c2e2..0d032005f5 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1407,6 +1407,26 @@ (derivation-file-name (package-derivation %store coreutils)))))))) +(test-assert "package-with-toolchain" + (let* ((dep (dummy-package "chbouib" + (build-system gnu-build-system) + (native-inputs `(("x" ,grep))))) + (p0 (dummy-package "thingie" + (build-system gnu-build-system) + (inputs `(("foo" ,grep) + ("bar" ,dep))))) + (tc (dummy-package "my-toolchain")) + (p1 (package-with-toolchain p0 `(("toolchain" ,tc))))) + (define toolchain-packages + '("gcc" "binutils" "glibc" "ld-wrapper")) + + (match (bag-build-inputs (package->bag p1)) + ((("foo" foo) ("bar" bar) (_ (= package-name packages) . _) ...) + (and (not (any (cut member <> packages) toolchain-packages)) + (member "my-toolchain" packages) + (eq? foo grep) + (eq? bar dep)))))) + (test-equal "package-patched-vulnerabilities" '(("CVE-2015-1234") ("CVE-2016-1234" "CVE-2018-4567") -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Sep 28 15:57:15 2020 Received: (at 43679) by debbugs.gnu.org; 28 Sep 2020 19:57:15 +0000 Received: from localhost ([127.0.0.1]:54084 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGs-0002x0-I0 for submit@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:55338) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kMzGm-0002w5-3w for 43679@debbugs.gnu.org; Mon, 28 Sep 2020 15:57:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:51206) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kMzGg-0005cA-Pg; Mon, 28 Sep 2020 15:57:02 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=43782 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kMzGg-0003Ee-0K; Mon, 28 Sep 2020 15:57:02 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH 5/5] guix build: Add '--with-toolchain'. Date: Mon, 28 Sep 2020 21:56:48 +0200 Message-Id: <20200928195648.30256-5-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200928195648.30256-1-ludo@gnu.org> References: <20200928195648.30256-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) From: Ludovic Courtès * guix/scripts/build.scm (transform-package-toolchain): New procedure. (%transformations): Add it. (%transformation-options, show-transformation-options-help): Add '--with-toolchain'. * tests/scripts-build.scm ("options->transformation, with-toolchain"): New test. * doc/guix.texi (Package Transformation Options): Document it. --- doc/guix.texi | 29 +++++++++++++++++++++++++++++ guix/scripts/build.scm | 40 ++++++++++++++++++++++++++++++++++++++++ tests/scripts-build.scm | 30 ++++++++++++++++++++++++++++++ 3 files changed, 99 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 03836bbf7b..049958b55f 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9310,6 +9310,35 @@ must be compatible. If @var{replacement} is somehow incompatible with @var{package}, then the resulting package may be unusable. Use with care! +@cindex tool chain, changing the build tool chain of a package +@item --with-toolchain=@var{package}=@var{toolchain} +This option changes @var{package} so that it gets built with +@var{toolchain} instead of the default GNU tool chain for C/C++. + +Consider this example: + +@example +guix build octave-cli \ + --with-toolchain=fftw=gcc-toolchain@@10 \ + --with-toolchain=fftwf=gcc-toolchain@@10 +@end example + +The command above builds a variant of the @code{fftw} and @code{fftwf} +packages using version 10 of @code{gcc-toolchain} instead of the default +tool chain, and then builds a variant of the GNU@tie{}Octave +command-line interface using them. GNU@tie{}Octave itself is built +using the default tool chain. + +This other example builds the Hardware Locality (@code{hwloc}) library +with the Clang C compiler, and then builds its dependents up to +@code{intel-mpi-benchmarks} using the default tool chain, but linking +them against the Clang-built @code{hwloc}: + +@example +guix build --with-toolchain=hwloc=clang-toolchain \ + intel-mpi-benchmarks +@end example + @item --with-git-url=@var{package}=@var{url} @cindex Git, using the latest commit @cindex latest commit, building diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index f238e9b876..290046a808 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -393,6 +393,40 @@ a checkout of the Git repository at the given URL." (rewrite obj) obj))) +(define (transform-package-toolchain replacement-specs) + "Return a procedure that, when passed a package, changes its toolchain or +that of its dependencies according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is +a list of strings like \"fftw=gcc-toolchain@10\" meaning that the package to +the left of the equal sign must be built with the toolchain to the right of +the equal sign." + (define split-on-commas + (cute string-tokenize <> (char-set-complement (char-set #\,)))) + + (define (specification->input spec) + (let ((package (specification->package spec))) + (list (package-name package) package))) + + (define replacements + (map (lambda (spec) + (match (string-tokenize spec %not-equal) + ((spec (= split-on-commas toolchain)) + (cons spec + (lambda (old) + (let ((toolchain (map specification->input toolchain))) + (package-with-toolchain old toolchain))))) + (_ + (leave (G_ "~a: invalid toolchain replacement specification~%") + spec)))) + replacement-specs)) + + (define rewrite + (package-input-rewriting/spec replacements)) + + (lambda (store obj) + (if (package? obj) + (rewrite obj) + obj))) + (define (transform-package-tests specs) "Return a procedure that, when passed a package, sets #:tests? #f in its 'arguments' field." @@ -423,6 +457,7 @@ a checkout of the Git repository at the given URL." (with-branch . ,transform-package-source-branch) (with-commit . ,transform-package-source-commit) (with-git-url . ,transform-package-source-git-url) + (with-toolchain . ,transform-package-toolchain) (without-tests . ,transform-package-tests))) (define %transformation-options @@ -444,6 +479,8 @@ a checkout of the Git repository at the given URL." (parser 'with-commit)) (option '("with-git-url") #t #f (parser 'with-git-url)) + (option '("with-toolchain") #t #f + (parser 'with-toolchain)) (option '("without-tests") #t #f (parser 'without-tests))))) @@ -466,6 +503,9 @@ a checkout of the Git repository at the given URL." (display (G_ " --with-git-url=PACKAGE=URL build PACKAGE from the repository at URL")) + (display (G_ " + --with-toolchain=PACKAGE=TOOLCHAIN + build package with TOOLCHAIN")) (display (G_ " --without-tests=PACKAGE build PACKAGE without running its tests"))) diff --git a/tests/scripts-build.scm b/tests/scripts-build.scm index 5f91360953..2dd1315722 100644 --- a/tests/scripts-build.scm +++ b/tests/scripts-build.scm @@ -22,6 +22,8 @@ #:use-module (guix derivations) #:use-module (guix packages) #:use-module (guix git-download) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) #:use-module (guix scripts build) #:use-module (guix ui) #:use-module (guix utils) @@ -30,6 +32,8 @@ #:use-module (gnu packages base) #:use-module (gnu packages busybox) #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-64)) @@ -270,6 +274,32 @@ ((("x" dep3)) (map package-source (list dep1 dep3)))))))))))) +(test-equal "options->transformation, with-toolchain" + '("gcc-toolchain") + (let* ((p (dummy-package "thingie" + (build-system gnu-build-system) + (inputs `(("foo" ,grep) + ("bar" ,(dummy-package "chbouib" + (build-system gnu-build-system) + (native-inputs `(("x" ,grep))))))))) + (t (options->transformation '((with-toolchain + . "chbouib=gcc-toolchain"))))) + (define toolchain-packages + '("gcc" "binutils" "glibc" "ld-wrapper")) + + (with-store store + (let ((new (t store p))) + (match (bag-build-inputs (package->bag new)) + ((("foo" _) ("bar" dep) (_ (= package-name packages) . _) ...) + (and (every (cut member <> packages) + toolchain-packages) + (match (bag-build-inputs (package->bag dep)) + ((("x" dep0) (_ (= package-name packages) . _) ...) + (and (eq? dep0 grep) ;this one is unchanged + (not (any (cut member <> packages) + toolchain-packages)) + (member "gcc-toolchain" packages))))))))))) + (test-assert "options->transformation, without-tests" (let* ((dep (dummy-package "dep")) (p (dummy-package "foo" -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 29 01:42:53 2020 Received: (at 43679) by debbugs.gnu.org; 29 Sep 2020 05:42:53 +0000 Received: from localhost ([127.0.0.1]:54645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kN8Pd-0000CP-0Y for submit@debbugs.gnu.org; Tue, 29 Sep 2020 01:42:53 -0400 Received: from flashner.co.il ([178.62.234.194]:43166) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kN8Pa-0000CC-SZ for 43679@debbugs.gnu.org; Tue, 29 Sep 2020 01:42:51 -0400 Received: from localhost (unknown [31.210.181.177]) by flashner.co.il (Postfix) with ESMTPSA id F0C004016D; Tue, 29 Sep 2020 05:42:44 +0000 (UTC) Date: Tue, 29 Sep 2020 08:42:12 +0300 From: Efraim Flashner To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#43679] [PATCH 3/5] gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. Message-ID: <20200929054212.GH1386@E5400> References: <20200928195648.30256-1-ludo@gnu.org> <20200928195648.30256-3-ludo@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="54u2kuW9sGWg/X+X" Content-Disposition: inline In-Reply-To: <20200928195648.30256-3-ludo@gnu.org> X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 43679 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= , 43679@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --54u2kuW9sGWg/X+X Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Sep 28, 2020 at 09:56:46PM +0200, Ludovic Court=C3=A8s wrote: > From: Ludovic Court=C3=A8s >=20 > * gnu/packages/llvm.scm (make-clang-toolchain)[arguments]: Create 'cc' > and 'c++' symlinks. > --- > gnu/packages/llvm.scm | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm > index 4b42c4921a..361b39710b 100644 > --- a/gnu/packages/llvm.scm > +++ b/gnu/packages/llvm.scm > @@ -476,6 +476,12 @@ code analysis tools.") > (((names . directories) ...) > (union-build out directories))) > =20 > + ;; Create 'cc' and 'c++' so that one can use it as a > + ;; drop-in replacement for the default tool chain a= nd > + ;; have configure scripts find the compiler. > + (symlink "clang" (string-append out "/bin/cc")) > + (symlink "clang++" (string-append out "/bin/c++")) > + > (union-build (assoc-ref %outputs "debug") > (list (assoc-ref %build-inputs > "libc-debug"))) > --=20 > 2.28.0 Isn't this something we've turned down patches for in the past with gcc? --=20 Efraim Flashner =D7=90=D7=A4=D7=A8=D7=99=D7=9D = =D7=A4=D7=9C=D7=A9=D7=A0=D7=A8 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --54u2kuW9sGWg/X+X Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl9yyTQACgkQQarn3Mo9 g1HDbBAAogELOIkWA4I6sY7bhOHm31gUMpGtDMrjLQla0yYt1pRPYsljRuj1ohaO pwzEYmwhSfgCCsJnvmvKwdhd3luxcd0eaCfrxpSAj1n9XIhx8pzo5+aQJdBKhV4c ntkwSicfFqMZLCqX83C7EY6CjUH00qovy7ELMuyVTOyG7urjUMOgIMNL4QQVpmya Ry0bT+xGjt4XHOknXvXOv0B7ymKQODKv6A1NKesc/DY5BvfrAK2CDw6YZ0YxAdbl +p/7LZ7iNpCKcMipBYHev/AC0KOEWlopWD5sYlcoyg7GYxuH3Ijt2YcndxLS996t 1CnwS7iZUmvXCBPrZabZXN/fpiazXivLVAwFcGAihLRDRnsXIdp7UyIDgvdVbp79 pX5hRiQ+lasYskGriTeDBRo4WosMjSdPOJ76O92Ppv/RzMCjo+MOGMA6J+U1ZVbq uDtkOW9C2Cy4N4Lb7/ymTMfgxZn4hH01BgmdCT9ziVk4aRhqNm6ae0Yh9/vOBHSW diE9HL8kc1rrGg0UpDtWNKrRp8wWRi5bIut0KkCINCglpUWSnkiww36PltJ4ZxKx ynf46B3HqHBL2iuJaHNYUGn3fkFnp9mLQ6je9rhE7jpbH1yycA/3UP9vBerovydG 3RYXKFCRTefiDasKd/TBrykz2Z8XCOV9HLBZlQczELVIJMoNN3Y= =wOuN -----END PGP SIGNATURE----- --54u2kuW9sGWg/X+X-- From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 29 03:53:27 2020 Received: (at 43679) by debbugs.gnu.org; 29 Sep 2020 07:53:27 +0000 Received: from localhost ([127.0.0.1]:54885 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNARz-0003Wz-9N for submit@debbugs.gnu.org; Tue, 29 Sep 2020 03:53:27 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:1509) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNARw-0003Wk-W4 for 43679@debbugs.gnu.org; Tue, 29 Sep 2020 03:53:26 -0400 X-IronPort-AV: E=Sophos;i="5.77,317,1596492000"; d="scan'208";a="469988204" Received: from unknown (HELO ribbon) ([193.50.110.247]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 29 Sep 2020 09:53:18 +0200 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Efraim Flashner Subject: Re: [bug#43679] [PATCH 3/5] gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. References: <20200928195648.30256-1-ludo@gnu.org> <20200928195648.30256-3-ludo@gnu.org> <20200929054212.GH1386@E5400> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 8 =?utf-8?Q?Vend=C3=A9miaire?= an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Tue, 29 Sep 2020 09:53:18 +0200 In-Reply-To: <20200929054212.GH1386@E5400> (Efraim Flashner's message of "Tue, 29 Sep 2020 08:42:12 +0300") Message-ID: <874knh9fyp.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 43679 Cc: 43679@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hi Efraim, Efraim Flashner skribis: > On Mon, Sep 28, 2020 at 09:56:46PM +0200, Ludovic Court=C3=A8s wrote: >> From: Ludovic Court=C3=A8s >>=20 >> * gnu/packages/llvm.scm (make-clang-toolchain)[arguments]: Create 'cc' >> and 'c++' symlinks. >> --- >> gnu/packages/llvm.scm | 6 ++++++ >> 1 file changed, 6 insertions(+) >>=20 >> diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm >> index 4b42c4921a..361b39710b 100644 >> --- a/gnu/packages/llvm.scm >> +++ b/gnu/packages/llvm.scm >> @@ -476,6 +476,12 @@ code analysis tools.") >> (((names . directories) ...) >> (union-build out directories))) >>=20=20 >> + ;; Create 'cc' and 'c++' so that one can use it as= a >> + ;; drop-in replacement for the default tool chain = and >> + ;; have configure scripts find the compiler. >> + (symlink "clang" (string-append out "/bin/cc")) >> + (symlink "clang++" (string-append out "/bin/c++")) >> + >> (union-build (assoc-ref %outputs "debug") >> (list (assoc-ref %build-inputs >> "libc-debug"))) >> --=20 >> 2.28.0 > > Isn't this something we've turned down patches for in the past with gcc? That is true, and, ahem, I even know a person who was against it. But! I think it=E2=80=99s a bit different here: (1) we=E2=80=99re only cha= nging =E2=80=98clang-toolchain=E2=80=99, not =E2=80=98clang=E2=80=99, (2) while m= ost build systems look for =E2=80=98gcc=E2=80=99 in addition to =E2=80=98cc=E2=80=99, few of them look= for =E2=80=98clang=E2=80=99. =E2=80=98--with-toolchain=E2=80=99 is useful even if =E2=80=98clang-toolcha= in=E2=80=99 cannot be dropped in (it allows you to try out different GCC versions, for instance), but I think it=E2=80=99s more useful if one can use it to build their code with= a different free tool chain. One use case that comes to mind is portability testing for C/C++ developers. WDYT? Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Tue Sep 29 06:45:07 2020 Received: (at 43679) by debbugs.gnu.org; 29 Sep 2020 10:45:07 +0000 Received: from localhost ([127.0.0.1]:55014 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kND86-0001Pc-TG for submit@debbugs.gnu.org; Tue, 29 Sep 2020 06:45:07 -0400 Received: from mail-wr1-f67.google.com ([209.85.221.67]:39527) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kND83-0001Ol-P2 for 43679@debbugs.gnu.org; Tue, 29 Sep 2020 06:45:05 -0400 Received: by mail-wr1-f67.google.com with SMTP id k10so4819046wru.6 for <43679@debbugs.gnu.org>; Tue, 29 Sep 2020 03:45:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version:content-transfer-encoding; bh=djqWYKtce7hZd0JhSpNqV4zTJ0qwEc5ua4ck8PDIWfA=; b=S/5pDw/h642Nj9PIxbz4zi853tgbAsIBrmON/NnEg/evAvMlK/+wPSXOR2u8/wF/2Q +IwxF35oup4j9lJcMLuJGwxhYxMyqRfpgJ7JTK7een1azMm8LSp3sKzJY7V35bhFTch0 c9SEXJP7yhJZzL1DENDdWgp1N6VmZvMGhzjZCKW/ErAbNn98dSDXJciiVJmUExX2GHOG LRFgTxatO8flUrXSHgaojhbCQ8Nd4Y99WzVYa+K2RADlETHgGs7bV8NeVB9uwymO4voN lNtYQ4X2W2AM1Px+nR/FXOhVjCSymH5ZgHTalD4DP1ExAXznibWU/F12/4vXxHm95tAT /pUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:in-reply-to:references:date :message-id:mime-version:content-transfer-encoding; bh=djqWYKtce7hZd0JhSpNqV4zTJ0qwEc5ua4ck8PDIWfA=; b=hGV0+Sy6TSuz9owccn0Seuim/PQvr4xo5s5zkhf8yL2bVm/CFYPP/hn3LJRY7fENjW 2w0YUsbrOaY+pftbqjigUcGCB5dT2EgVIs0xsiBP/AWfwA1Yh0zDZcq/gknWWy0GWxRm aePWijBw4T8CG+6NXOBYFoZgH+69JKtEvRo2S6TnvyidUehhhSredzd2tu+JBdUGSvXZ J/1rSAZUJjs769XjqK6fjITQyl1GsopL76AOVQKDAQsNAMg/lcUkiJbs6endriIxTRUV AKiHPT5skqChJliqJXiF1epHaUjuZQzyg0ee8dx9q7KwRSBvu70OYjymPEq5jLe5s6vR GUcQ== X-Gm-Message-State: AOAM533I5HrcYHWA+/obqGS4xv06TzDh+92RKA7H9ToKeO7sox5dk2HB WJAf2BHdAU6GLy83stLZXLE= X-Google-Smtp-Source: ABdhPJwo/saJtw1alp5feSo03+h24unnrztZbz9Vf+P5s5qZfY67baPhKGcOAkSYB/Kgx4ATusI0Dg== X-Received: by 2002:adf:ec45:: with SMTP id w5mr3734254wrn.357.1601376297777; Tue, 29 Sep 2020 03:44:57 -0700 (PDT) Received: from lili ([2a01:e0a:59b:9120:65d2:2476:f637:db1e]) by smtp.gmail.com with ESMTPSA id i33sm6035815wri.79.2020.09.29.03.44.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 03:44:57 -0700 (PDT) From: zimoun To: Ludovic =?utf-8?Q?Court=C3=A8s?= , 43679@debbugs.gnu.org Subject: Re: [bug#43679] [PATCH 0/5] Add '--with-toolchain' package transformation option In-Reply-To: <20200928195305.30096-1-ludo@gnu.org> References: <20200928195305.30096-1-ludo@gnu.org> Date: Tue, 29 Sep 2020 12:44:55 +0200 Message-ID: <865z7wuajc.fsf@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.6 (/) X-Debbugs-Envelope-To: 43679 Cc: Ludovic =?utf-8?Q?Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.6 (-) Hi, On Mon, 28 Sep 2020 at 21:53, Ludovic Court=C3=A8s wrote: > From: Ludovic Court=C3=A8s > One thing I wasn=E2=80=99t entirely sure about: =E2=80=98--with-toolchain= =E2=80=99 changes > the toolchain of the specified package, not that of its dependents. > This assumes that the toolchains all follow the same ABI. This is > the case for C, apparently, maybe not for C++. Should it instead > change to toolchain of the package=E2=80=99s dependents as well? > > Something like: > > guix build guile --with-toolchain=3Dguile@3.0.4=3Dclang-toolchain=20 > > generates working code. Really cool! Playing yesterday with the new =E2=80=99package-mapping=E2=80= =99 & co. (checking =E2=80=99package-with-explicit-ocaml=E2=80=99), a kind of new =E2=80=99=E2=80=93with-toolchain=E2=80=99 option was my conclusion. :-) However, =E2=80=99=E2=80=93with-toolchain=E2=80=99 can be misleading since = it is =E2=80=99gnu-build-system=E2=80=99 and C/C++ software specific. I mean, th= e patch #4 adding =E2=80=99build-system-with-toolchain=E2=80=99 contains: --8<---------------cut here---------------start------------->8--- + (define toolchain-packages + ;; These are the GNU toolchain packages pulled in by GNU-BUILD-SYSTEM = and + ;; all the build systems that inherit from it. Keep the list in sync = with + ;; 'standard-packages' in (guix build-system gnu). + '("gcc" "binutils" "libc" "libc:static" "ld-wrapper")) + + (define (lower* . args) + (let ((lowered (apply lower args))) + (bag + (inherit lowered) + (build-inputs + (append (fold alist-delete + (bag-build-inputs lowered) + toolchain-packages) + toolchain))))) --8<---------------cut here---------------end--------------->8--- And for example, it will not remove =E2=80=99default-ocaml=E2=80=99 and =E2=80=99default-findlib=E2=80=99 in the =E2=80=99ocaml-build-system=E2=80= =99. Even if it would be easy to specify the options =E2=80=9C=E2=80=93with-input=3Docaml=3Docaml-variant =E2=80=93with-input=3Dfindlib=3Dfindlib-variant=E2=80=9D. But for the =E2=80=99clojure-build-system=E2=80=99 it is 3 packages. Another example a bit out-of-scope is to rebuild all the Emacs stack using the package =E2=80=99emacs-next=E2=80=99 instead of =E2=80=99emacs=E2= =80=99. The =E2=80=99emacs-build-system=E2=80=99 depends on =E2=80=99emacs-minimal=E2= =80=99 but some packages (see =E2=80=99emacs-magit=E2=80=99) rewrite that using instead =E2=80=99emacs-no= -x=E2=80=99. It could be nice to be able to write: guix build -m manifest.m --with-toolchain=3Demacs-next-toolchain In summary, does it make sense, either: - change the =E2=80=99=E2=80=93with-toolchain=E2=80=99 to =E2=80=99=E2=80= =93with-gcc-toolchain=E2=80=99 or - tweak =E2=80=99build-system-with-toolchain=E2=80=99 to pass =E2=80=99to= olchain-packages=E2=80=99 as parameter somehow and be able to run: =20=20 guix build coq --with-toolchain=3Dcoq=3Docaml-toolchain4.07 =20=20=20=20=20 ?=20=20=20=20=20 > Another issue is that since we use =E2=80=98package-input-rewriting/spec= =E2=80=99, > we can=E2=80=99t change the toolchain of core packages like Guile or Perl > without rebuilding the world. For example, if we omit =E2=80=9C@3.0.4=E2= =80=9D > in the example above, we rebuild a =E2=80=9Cguile=E2=80=9D package deep d= own and > everything that follows (aka. =E2=80=9Cthe world=E2=80=9D). Yeah but that=E2=80=99s maybe what people want: rebuild the world with anot= her toolchain, probably optimized for some specific machine (HPC cluster). > Another option I considered was to graft the package that > =E2=80=98--with-toolchain=E2=80=99 targets instead of rebuilding its depe= ndents. > Again that=E2=80=99d only work if the resulting binaries are ABI-compatib= le, > but maybe that=E2=80=99s a reasonable assumption. It would definitely sa= ve > build time. Should it be grafted, or should there be a separate > option to do that? Thoughts? >From my perspective, it should be another option. For example, I imagine people want to rebuild all the stack with Name-It=C2=A9 compiler. = Or the Name-It=C2=A9 compiler could be not-ABI compatible. All the best, simon From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 30 04:46:41 2020 Received: (at 43679) by debbugs.gnu.org; 30 Sep 2020 08:46:41 +0000 Received: from localhost ([127.0.0.1]:58096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNXl3-0005I5-4k for submit@debbugs.gnu.org; Wed, 30 Sep 2020 04:46:41 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:48304) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNXl0-0005Hq-UI for 43679@debbugs.gnu.org; Wed, 30 Sep 2020 04:46:39 -0400 X-IronPort-AV: E=Sophos;i="5.77,321,1596492000"; d="scan'208";a="470204157" Received: from 91-160-117-201.subs.proxad.net (HELO ribbon) ([91.160.117.201]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Sep 2020 10:46:30 +0200 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: [bug#43679] [PATCH 0/5] Add '--with-toolchain' package transformation option References: <20200928195305.30096-1-ludo@gnu.org> <865z7wuajc.fsf@gmail.com> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 9 =?utf-8?Q?Vend=C3=A9miaire?= an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 30 Sep 2020 10:46:29 +0200 In-Reply-To: <865z7wuajc.fsf@gmail.com> (zimoun's message of "Tue, 29 Sep 2020 12:44:55 +0200") Message-ID: <871rij4pp6.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 43679 Cc: 43679@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hi, zimoun skribis: > On Mon, 28 Sep 2020 at 21:53, Ludovic Court=C3=A8s wrote: >> From: Ludovic Court=C3=A8s > >> One thing I wasn=E2=80=99t entirely sure about: =E2=80=98--with-toolchai= n=E2=80=99 changes >> the toolchain of the specified package, not that of its dependents. >> This assumes that the toolchains all follow the same ABI. This is >> the case for C, apparently, maybe not for C++. Should it instead >> change to toolchain of the package=E2=80=99s dependents as well? >> >> Something like: >> >> guix build guile --with-toolchain=3Dguile@3.0.4=3Dclang-toolchain=20 >> >> generates working code. [...] > However, =E2=80=99=E2=80=93with-toolchain=E2=80=99 can be misleading sinc= e it is > =E2=80=99gnu-build-system=E2=80=99 and C/C++ software specific. I mean, = the patch #4 > adding =E2=80=99build-system-with-toolchain=E2=80=99 contains: > > + (define toolchain-packages > + ;; These are the GNU toolchain packages pulled in by GNU-BUILD-SYSTE= M and > + ;; all the build systems that inherit from it. Keep the list in syn= c with > + ;; 'standard-packages' in (guix build-system gnu). > + '("gcc" "binutils" "libc" "libc:static" "ld-wrapper")) > + > + (define (lower* . args) > + (let ((lowered (apply lower args))) > + (bag > + (inherit lowered) > + (build-inputs > + (append (fold alist-delete > + (bag-build-inputs lowered) > + toolchain-packages) > + toolchain))))) Yeah this option is meant for C/C++ as I wrote above and (I think) in the documentation. > Another example a bit out-of-scope is to rebuild all the Emacs stack > using the package =E2=80=99emacs-next=E2=80=99 instead of =E2=80=99emacs= =E2=80=99. The > =E2=80=99emacs-build-system=E2=80=99 depends on =E2=80=99emacs-minimal=E2= =80=99 but some packages (see > =E2=80=99emacs-magit=E2=80=99) rewrite that using instead =E2=80=99emacs-= no-x=E2=80=99. It could be > nice to be able to write: > > guix build -m manifest.m --with-toolchain=3Demacs-next-toolchain Here you=E2=80=99d use =E2=80=98--with-input=E2=80=99, though package trans= formation options have no effect when using a manifest. > In summary, does it make sense, either: > > - change the =E2=80=99=E2=80=93with-toolchain=E2=80=99 to =E2=80=99=E2= =80=93with-gcc-toolchain=E2=80=99 =E2=80=98--with-gcc-toolchain=3Dclang-toolchain=E2=80=99 would look strange= . :-) > - tweak =E2=80=99build-system-with-toolchain=E2=80=99 to pass =E2=80=99= toolchain-packages=E2=80=99 as > parameter somehow and be able to run: >=20=20=20 > guix build coq --with-toolchain=3Dcoq=3Docaml-toolchain4.07 Can=E2=80=99t you use =E2=80=98--with-input=3DocamlX.Y=3DocamlA.B=E2=80=99 = in this case? If not, we could devise a separate option rather than overload this one. >> Another issue is that since we use =E2=80=98package-input-rewriting/spec= =E2=80=99, >> we can=E2=80=99t change the toolchain of core packages like Guile or Perl >> without rebuilding the world. For example, if we omit =E2=80=9C@3.0.4= =E2=80=9D >> in the example above, we rebuild a =E2=80=9Cguile=E2=80=9D package deep = down and >> everything that follows (aka. =E2=80=9Cthe world=E2=80=9D). > > Yeah but that=E2=80=99s maybe what people want: rebuild the world with an= other > toolchain, probably optimized for some specific machine (HPC cluster). Yes, though it doesn=E2=80=99t necessarily make sense. :-) But yeah, perhaps rebuilding everything above the given package would be more in line with what people expect. >> Another option I considered was to graft the package that >> =E2=80=98--with-toolchain=E2=80=99 targets instead of rebuilding its dep= endents. >> Again that=E2=80=99d only work if the resulting binaries are ABI-compati= ble, >> but maybe that=E2=80=99s a reasonable assumption. It would definitely s= ave >> build time. Should it be grafted, or should there be a separate >> option to do that? Thoughts? > > From my perspective, it should be another option. For example, I > imagine people want to rebuild all the stack with Name-It=C2=A9 compiler.= Or > the Name-It=C2=A9 compiler could be not-ABI compatible. I=E2=80=99m not interested in proprietary compilers if that=E2=80=99s what = you have in mind. Besides, the SysV ABI is defined for C, so normally all C compilers produce ABI-compatible code. There are exceptions such as OpenMP (Clang is moving to their own libomp, I think, whereas GCC has libgomp.) Thanks for your feedback! Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 30 09:33:04 2020 Received: (at 43679) by debbugs.gnu.org; 30 Sep 2020 13:33:04 +0000 Received: from localhost ([127.0.0.1]:58645 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNcEC-0008N9-9k for submit@debbugs.gnu.org; Wed, 30 Sep 2020 09:33:04 -0400 Received: from mail-qk1-f193.google.com ([209.85.222.193]:42983) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNcEA-0008Me-1w for 43679@debbugs.gnu.org; Wed, 30 Sep 2020 09:33:02 -0400 Received: by mail-qk1-f193.google.com with SMTP id v123so1335118qkd.9 for <43679@debbugs.gnu.org>; Wed, 30 Sep 2020 06:33:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=ICGbIZDhJaH3eAJRc3IqfnAakCDpTclAu7AGZmsZdcw=; b=d8FdEDjCyIn/bnib1lMwLAZwsrGjk9BsTsUrulXhWhbNZC1K3dboXYj4YnhSurN2aV AlFgIcLxn8++DI3qxrMoJ1uYP5Tyzyfnidm4pA/Nx1rHBpu+p7qmxx7IsIHpmkcu4XUM 1c7eQJGDw0ZTtXwCDrccnwTRCtuSjeAkzChY6wI7bZbNcoQD+AUvuh4qQ5MrU+3ttbyu x/qvmHNMM0ro5Z7fAydWR4a8qFs3PoQ4loLNqZMwNNGJPJ4gQVMIq+XCFC3VIPL21P/O Lru8FJJC68Q/L9j8UJZq6EnGgdD2UnrUJR5mtsYuIUYAAhhkmOtGz3glwPjLcPTB6Y+O xlQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=ICGbIZDhJaH3eAJRc3IqfnAakCDpTclAu7AGZmsZdcw=; b=UQNqk0ET7Tz7liB6Gzs494W6Bw2yQTsi0UsXbQGiIhI3JsZ+vorln5xQgcC6EKhYM4 y4nHdGRirFkNdm7ypUhcKn0pvDEL2vGFD9VHLzyQw3nUDzQv2lX4S5gvNTEQ0YZSCK58 pgvI6H0JSPP71oqfTl6Ji/u+NZPseUsuniATNQ0Td/YVbXJWGpZDY24/6T1JsGXHrdwp Jz+hI8Cy5fEdERS5Zl/WlYLYM41wevqZtKnaPzHGCIfJkl9yzce2q3d62LGnX0lNtKg9 7Kz238MzfY08n3r/SQabReIaY46scv/LKgI+SfHlVwZAapb0Ah2sS9wlZKOVwhDPTjIF XiyA== X-Gm-Message-State: AOAM5326o2wQsZtSboP9qw6wQhsIxjkmCmuhX2SnRqulx3kkSoGg41gn nMwtFq9IPGiENpHipgsO2xwbr2Pt5RifxI1llkw= X-Google-Smtp-Source: ABdhPJy0N5Bn5tkY4nrI5htm2WC9/M5v2HXDuZFGecMoS8ywIOrJ11W2dVWz4IWmKXi3+AsEpkwrGVUYqCWevZpZxlo= X-Received: by 2002:a37:7c2:: with SMTP id 185mr2389306qkh.304.1601472776356; Wed, 30 Sep 2020 06:32:56 -0700 (PDT) MIME-Version: 1.0 References: <20200928195305.30096-1-ludo@gnu.org> <865z7wuajc.fsf@gmail.com> <871rij4pp6.fsf@gnu.org> In-Reply-To: <871rij4pp6.fsf@gnu.org> From: zimoun Date: Wed, 30 Sep 2020 15:32:45 +0200 Message-ID: Subject: Re: [bug#43679] [PATCH 0/5] Add '--with-toolchain' package transformation option To: =?UTF-8?Q?Ludovic_Court=C3=A8s?= Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -0.4 (/) X-Debbugs-Envelope-To: 43679 Cc: 43679@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.4 (-) Hi, On Wed, 30 Sep 2020 at 10:46, Ludovic Court=C3=A8s wrote: > > However, =E2=80=99=E2=80=93with-toolchain=E2=80=99 can be misleading si= nce it is > > =E2=80=99gnu-build-system=E2=80=99 and C/C++ software specific. I mean= , the patch #4 > > adding =E2=80=99build-system-with-toolchain=E2=80=99 contains: [...] > Yeah this option is meant for C/C++ as I wrote above and (I think) in > the documentation. Yes in the manual, not in the command line helper. Without bikeshedding, I find '--with-toolchain' a bad name since it is only 'gnu-build-system' related. And from my point of view, it is also a bad name for the procedures 'build-system-with-toolchain' and 'package-with-toolchain' -- but it does not matter since they are not written in stone, contrary to command line options harder to change. > > - change the =E2=80=99=E2=80=93with-toolchain=E2=80=99 to =E2=80=99= =E2=80=93with-gcc-toolchain=E2=80=99 > > =E2=80=98--with-gcc-toolchain=3Dclang-toolchain=E2=80=99 would look stran= ge. :-) Why not? :-) My point is: '--with-toolchain' is not specific enough. Maybe '--with-gnu-toolchain'? > > - tweak =E2=80=99build-system-with-toolchain=E2=80=99 to pass =E2=80= =99toolchain-packages=E2=80=99 as > > parameter somehow and be able to run: > > > > guix build coq --with-toolchain=3Dcoq=3Docaml-toolchain4.07 > > Can=E2=80=99t you use =E2=80=98--with-input=3DocamlX.Y=3DocamlA.B=E2=80= =99 in this case? If not, we > could devise a separate option rather than overload this one. No, in this case one should use: guix build coq \ --with-input=3Docaml=3Docaml@4.07 \ --with-input=3Docaml-findlib=3Docaml4.07-findlib to recompile the package 'coq' with the 4.07 'ocaml-build-system'. For the 'clojure-build-system', there are 3 inputs to specify. (I have not checked all the build systems :-)). And note it works only if the tools used by the build system are not hidden. For consistency, it appears to me easier to have one "toolchain" per build system, say ocaml-toolchain, gcc-toolchain, haskell-toolchain, and then provides this toolchain to the option '--with-toolchain'. However, it is complicated to remove the 'build-inputs' since they are not hard coded -- as it is the case in 'build-system-with-toolchain'. Or another option is to have one command line option per build system: --with-gnu-toolchain, --with-ocaml-toolchain, --with-cargo-toolchain, etc.. > > Yeah but that=E2=80=99s maybe what people want: rebuild the world with = another > > toolchain, probably optimized for some specific machine (HPC cluster). > > Yes, though it doesn=E2=80=99t necessarily make sense. :-) Sadly! > But yeah, perhaps rebuilding everything above the given package would be > more in line with what people expect. Yeah...maybe providing "what people expect" could reduce the gap in the HPC community. > >> Another option I considered was to graft the package that > >> =E2=80=98--with-toolchain=E2=80=99 targets instead of rebuilding its d= ependents. > >> Again that=E2=80=99d only work if the resulting binaries are ABI-compa= tible, > >> but maybe that=E2=80=99s a reasonable assumption. It would definitely= save > >> build time. Should it be grafted, or should there be a separate > >> option to do that? Thoughts? > > > > From my perspective, it should be another option. For example, I > > imagine people want to rebuild all the stack with Name-It=C2=A9 compile= r. Or > > the Name-It=C2=A9 compiler could be not-ABI compatible. > > I=E2=80=99m not interested in proprietary compilers if that=E2=80=99s wha= t you have in > mind. Besides, the SysV ABI is defined for C, so normally all C > compilers produce ABI-compatible code. There are exceptions such as > OpenMP (Clang is moving to their own libomp, I think, whereas GCC has > libgomp.) It was what I have in mind. :-) But do the exceptions you point not imply another option? All the best, simon From debbugs-submit-bounces@debbugs.gnu.org Wed Sep 30 12:58:21 2020 Received: (at 43679) by debbugs.gnu.org; 30 Sep 2020 16:58:21 +0000 Received: from localhost ([127.0.0.1]:32928 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNfQr-0001Yo-0Y for submit@debbugs.gnu.org; Wed, 30 Sep 2020 12:58:21 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:53745) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kNfQo-0001Ya-PF for 43679@debbugs.gnu.org; Wed, 30 Sep 2020 12:58:19 -0400 X-IronPort-AV: E=Sophos;i="5.77,322,1596492000"; d="scan'208";a="360484327" Received: from 91-160-117-201.subs.proxad.net (HELO ribbon) ([91.160.117.201]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Sep 2020 18:58:05 +0200 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: zimoun Subject: Re: [bug#43679] [PATCH 0/5] Add '--with-toolchain' package transformation option References: <20200928195305.30096-1-ludo@gnu.org> <865z7wuajc.fsf@gmail.com> <871rij4pp6.fsf@gnu.org> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 9 =?utf-8?Q?Vend=C3=A9miaire?= an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Wed, 30 Sep 2020 18:58:04 +0200 In-Reply-To: (zimoun's message of "Wed, 30 Sep 2020 15:32:45 +0200") Message-ID: <87mu17yzfn.fsf@inria.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 43679 Cc: 43679@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) zimoun skribis: > On Wed, 30 Sep 2020 at 10:46, Ludovic Court=C3=A8s wrote: > >> > However, =E2=80=99=E2=80=93with-toolchain=E2=80=99 can be misleading s= ince it is >> > =E2=80=99gnu-build-system=E2=80=99 and C/C++ software specific. I mea= n, the patch #4 >> > adding =E2=80=99build-system-with-toolchain=E2=80=99 contains: > > [...] > >> Yeah this option is meant for C/C++ as I wrote above and (I think) in >> the documentation. > > Yes in the manual, not in the command line helper. > > Without bikeshedding, I find '--with-toolchain' a bad name since it is > only 'gnu-build-system' related. And from my point of view, it is > also a bad name for the procedures 'build-system-with-toolchain' and > 'package-with-toolchain' -- but it does not matter since they are not > written in stone, contrary to command line options harder to change. I agree that C/C++ don=E2=80=99t have a monopoly on tool chains, no argument here. The term =E2=80=9Ctool chain=E2=80=9D is widely used for C/C++ thoug= h, much less for other languages (often the =E2=80=9Ctool chain=E2=80=9D is a single pac= kage for other languages). We could change the name to =E2=80=98--with-c-toolchain=E2=80=99 maybe? Th= en someone might come and suggest that this doesn=E2=80=99t account for C++, Objective= -C, and FORTRAN. >> Can=E2=80=99t you use =E2=80=98--with-input=3DocamlX.Y=3DocamlA.B=E2=80= =99 in this case? If not, we >> could devise a separate option rather than overload this one. > > No, in this case one should use: > > guix build coq \ > --with-input=3Docaml=3Docaml@4.07 \ > --with-input=3Docaml-findlib=3Docaml4.07-findlib Hmm I think the second one is unnecessary since =E2=80=98--with-input=3Docaml=3Docaml@4.07=E2=80=99 effectively gives an = =E2=80=98ocaml-findlib=E2=80=99 built against OCaml 4.07. Anyway, we=E2=80=99re drifting off-topic; let=E2=80=99s address OCaml separ= ately if something needs to be addressed. > For consistency, it appears to me easier to have one "toolchain" per > build system, say ocaml-toolchain, gcc-toolchain, haskell-toolchain, > and then provides this toolchain to the option '--with-toolchain'. > However, it is complicated to remove the 'build-inputs' since they are > not hard coded -- as it is the case in 'build-system-with-toolchain'. > Or another option is to have one command line option per build system: > --with-gnu-toolchain, --with-ocaml-toolchain, --with-cargo-toolchain, > etc.. If there=E2=80=99s a need for that, yes. We=E2=80=99ll see! >> I=E2=80=99m not interested in proprietary compilers if that=E2=80=99s wh= at you have in >> mind. Besides, the SysV ABI is defined for C, so normally all C >> compilers produce ABI-compatible code. There are exceptions such as >> OpenMP (Clang is moving to their own libomp, I think, whereas GCC has >> libgomp.) > > It was what I have in mind. :-) > But do the exceptions you point not imply another option? We can=E2=80=99t completely prevent people from shooting themselves in the = foot with transformations, but yeah, maybe we should rebuild everything higher in the stack with the same toolchain. Thanks, Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 05 08:15:00 2020 Received: (at 43679) by debbugs.gnu.org; 5 Oct 2020 12:15:00 +0000 Received: from localhost ([127.0.0.1]:48195 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kPPOO-0008Q5-KU for submit@debbugs.gnu.org; Mon, 05 Oct 2020 08:15:00 -0400 Received: from flashner.co.il ([178.62.234.194]:58816) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kPPON-0008Ps-9o for 43679@debbugs.gnu.org; Mon, 05 Oct 2020 08:14:59 -0400 Received: from localhost (unknown [31.210.181.177]) by flashner.co.il (Postfix) with ESMTPSA id B9A2E40216; Mon, 5 Oct 2020 12:14:52 +0000 (UTC) Date: Mon, 5 Oct 2020 15:14:16 +0300 From: Efraim Flashner To: Ludovic =?utf-8?Q?Court=C3=A8s?= Subject: Re: [bug#43679] [PATCH 3/5] gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. Message-ID: <20201005121416.GK2958@E5400> References: <20200928195648.30256-1-ludo@gnu.org> <20200928195648.30256-3-ludo@gnu.org> <20200929054212.GH1386@E5400> <874knh9fyp.fsf@gnu.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="kkRamCq5m5VQq0L6" Content-Disposition: inline In-Reply-To: <874knh9fyp.fsf@gnu.org> X-PGP-Key-ID: 0x41AAE7DCCA3D8351 X-PGP-Key: https://flashner.co.il/~efraim/efraim_flashner.asc X-PGP-Fingerprint: A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 43679 Cc: 43679@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --kkRamCq5m5VQq0L6 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Sep 29, 2020 at 09:53:18AM +0200, Ludovic Court=C3=A8s wrote: > Hi Efraim, >=20 > Efraim Flashner skribis: >=20 > > On Mon, Sep 28, 2020 at 09:56:46PM +0200, Ludovic Court=C3=A8s wrote: > >> From: Ludovic Court=C3=A8s > >>=20 > >> * gnu/packages/llvm.scm (make-clang-toolchain)[arguments]: Create 'cc' > >> and 'c++' symlinks. > >> --- > >> gnu/packages/llvm.scm | 6 ++++++ > >> 1 file changed, 6 insertions(+) > >>=20 > >> diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm > >> index 4b42c4921a..361b39710b 100644 > >> --- a/gnu/packages/llvm.scm > >> +++ b/gnu/packages/llvm.scm > >> @@ -476,6 +476,12 @@ code analysis tools.") > >> (((names . directories) ...) > >> (union-build out directories))) > >> =20 > >> + ;; Create 'cc' and 'c++' so that one can use it = as a > >> + ;; drop-in replacement for the default tool chai= n and > >> + ;; have configure scripts find the compiler. > >> + (symlink "clang" (string-append out "/bin/cc")) > >> + (symlink "clang++" (string-append out "/bin/c++"= )) > >> + > >> (union-build (assoc-ref %outputs "debug") > >> (list (assoc-ref %build-inputs > >> "libc-debug"))) > >> --=20 > >> 2.28.0 > > > > Isn't this something we've turned down patches for in the past with gcc? >=20 > That is true, and, ahem, I even know a person who was against it. >=20 > But! I think it=E2=80=99s a bit different here: (1) we=E2=80=99re only c= hanging > =E2=80=98clang-toolchain=E2=80=99, not =E2=80=98clang=E2=80=99, (2) while= most build systems look for > =E2=80=98gcc=E2=80=99 in addition to =E2=80=98cc=E2=80=99, few of them lo= ok for =E2=80=98clang=E2=80=99. >=20 > =E2=80=98--with-toolchain=E2=80=99 is useful even if =E2=80=98clang-toolc= hain=E2=80=99 cannot be dropped > in (it allows you to try out different GCC versions, for instance), but > I think it=E2=80=99s more useful if one can use it to build their code wi= th a > different free tool chain. One use case that comes to mind is > portability testing for C/C++ developers. >=20 > WDYT? Do we want to have gcc-toolchain provide a cc binary then too? It seems like it would also help people who have a project they want to build by hand which has the compiler set as cc and they install the gcc-toolchain. >=20 > Thanks, > Ludo=E2=80=99. --=20 Efraim Flashner =D7=90=D7=A4=D7=A8=D7=99=D7=9D = =D7=A4=D7=9C=D7=A9=D7=A0=D7=A8 GPG key =3D A28B F40C 3E55 1372 662D 14F7 41AA E7DC CA3D 8351 Confidentiality cannot be guaranteed on emails sent or received unencrypted --kkRamCq5m5VQq0L6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEoov0DD5VE3JmLRT3Qarn3Mo9g1EFAl97DhQACgkQQarn3Mo9 g1GmgQ//dJTSXtcjcB9dT32PRJiYgkwYjwFxIRuL+F1wFcv2EQFulsRowDzcOwIA 904YzfxZdYCOjyYExxKBxolKnqzU4jV6Xj/6MUoqCTO1s2ppVD1lOLrcdnjd70ty 0vt/7TRZmqigYVxbO/9wY7Z0td3rUDAfvvSMp9ABn1UFkf1nr3KaWr9+zQf6wsMq cluZoCquAgvb33Ng0PTALUdKco6bjqgV5UixKcXHLj1Wje2UeWCa1Nt0KhhawzrQ uovca5nrkffJc0xlRiAQ3Es1yEQd8mLzeov6IKrAL95raL7LDeA3epMLgpntfIhO eVVZHswwr0zyAFDdFD7NMPEAJWuLIEkHHrWe39skSpkn5Yy482JSYi7hIW/7wUYG NZbNwRmhwse9pgwJ7wqRHPKPoF7nvMZ4No561SRoaeo3ovvaleoLN1MnQMDqxJyj 6v1Ni5eV7iYP8g04k/HDOpjy7r8aMZhtosytK+hFN4egSvGNhLXgKZI7APXlzS5r 6JiXATGB7H9/RWGhxnxt9o6fNYULNkqOSzOUoQAgdMMYJkln051+LGTcqMmvj8LY 3JdVxCSGWgfjPTiw2DxClmlFVFtMGtTtDwvmgDMTD4D5kK0y1EjspenJ59lB/ca9 3k6tOmGv40e4rxQF5SkgVKrAgwlbGFdaXMuCUgEqYAvaRMDs+/8= =jIxx -----END PGP SIGNATURE----- --kkRamCq5m5VQq0L6-- From debbugs-submit-bounces@debbugs.gnu.org Thu Oct 08 03:04:36 2020 Received: (at 43679) by debbugs.gnu.org; 8 Oct 2020 07:04:36 +0000 Received: from localhost ([127.0.0.1]:58554 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQPyd-0002AB-VD for submit@debbugs.gnu.org; Thu, 08 Oct 2020 03:04:36 -0400 Received: from mail3-relais-sop.national.inria.fr ([192.134.164.104]:43597) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQPyc-00029u-D0 for 43679@debbugs.gnu.org; Thu, 08 Oct 2020 03:04:34 -0400 X-IronPort-AV: E=Sophos;i="5.77,350,1596492000"; d="scan'208";a="361182838" Received: from 91-160-117-201.subs.proxad.net (HELO ribbon) ([91.160.117.201]) by mail3-relais-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Oct 2020 09:04:26 +0200 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: Efraim Flashner Subject: Re: [bug#43679] [PATCH 3/5] gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. References: <20200928195648.30256-1-ludo@gnu.org> <20200928195648.30256-3-ludo@gnu.org> <20200929054212.GH1386@E5400> <874knh9fyp.fsf@gnu.org> <20201005121416.GK2958@E5400> X-URL: http://www.fdn.fr/~lcourtes/ X-Revolutionary-Date: 17 =?utf-8?Q?Vend=C3=A9miaire?= an 229 de la =?utf-8?Q?R=C3=A9volution?= X-PGP-Key-ID: 0x090B11993D9AEBB5 X-PGP-Key: http://www.fdn.fr/~lcourtes/ludovic.asc X-PGP-Fingerprint: 3CE4 6455 8A84 FDC6 9DB4 0CFB 090B 1199 3D9A EBB5 X-OS: x86_64-pc-linux-gnu Date: Thu, 08 Oct 2020 09:04:26 +0200 In-Reply-To: <20201005121416.GK2958@E5400> (Efraim Flashner's message of "Mon, 5 Oct 2020 15:14:16 +0300") Message-ID: <87h7r5ryf9.fsf@inria.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 43679 Cc: 43679@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hi, Efraim Flashner skribis: > On Tue, Sep 29, 2020 at 09:53:18AM +0200, Ludovic Court=C3=A8s wrote: [...] >> >> + ;; Create 'cc' and 'c++' so that one can use it= as a >> >> + ;; drop-in replacement for the default tool cha= in and >> >> + ;; have configure scripts find the compiler. >> >> + (symlink "clang" (string-append out "/bin/cc")) >> >> + (symlink "clang++" (string-append out "/bin/c++= ")) >> >> + >> >> (union-build (assoc-ref %outputs "debug") >> >> (list (assoc-ref %build-inputs >> >> "libc-debug"))) >> >> --=20 >> >> 2.28.0 >> > >> > Isn't this something we've turned down patches for in the past with gc= c? >>=20 >> That is true, and, ahem, I even know a person who was against it. >>=20 >> But! I think it=E2=80=99s a bit different here: (1) we=E2=80=99re only = changing >> =E2=80=98clang-toolchain=E2=80=99, not =E2=80=98clang=E2=80=99, (2) whil= e most build systems look for >> =E2=80=98gcc=E2=80=99 in addition to =E2=80=98cc=E2=80=99, few of them l= ook for =E2=80=98clang=E2=80=99. >>=20 >> =E2=80=98--with-toolchain=E2=80=99 is useful even if =E2=80=98clang-tool= chain=E2=80=99 cannot be dropped >> in (it allows you to try out different GCC versions, for instance), but >> I think it=E2=80=99s more useful if one can use it to build their code w= ith a >> different free tool chain. One use case that comes to mind is >> portability testing for C/C++ developers. >>=20 >> WDYT? > > Do we want to have gcc-toolchain provide a cc binary then too? It seems > like it would also help people who have a project they want to build by > hand which has the compiler set as cc and they install the > gcc-toolchain. I=E2=80=99m not enthusiastic (I think it=E2=80=99s good that build systems = and tools keep referring to =E2=80=98gcc=E2=80=99) but I guess I=E2=80=99ll have a mo= re difficult time arguing against it now=E2=80=A6 Ludo=E2=80=99. From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 09 05:13:05 2020 Received: (at 43679) by debbugs.gnu.org; 9 Oct 2020 09:13:05 +0000 Received: from localhost ([127.0.0.1]:34101 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSW-000464-Mx for submit@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:04 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48812) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSU-00045R-GL for 43679@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57148) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQoSP-0001jj-9f; Fri, 09 Oct 2020 05:12:57 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56284 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kQoSO-0001o4-0C; Fri, 09 Oct 2020 05:12:56 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH v2 1/5] gnu: gcc-toolchain: Add 'GUIX_LOCPATH' to the search paths. Date: Fri, 9 Oct 2020 11:12:27 +0200 Message-Id: <20201009091231.26287-2-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009091231.26287-1-ludo@gnu.org> References: <87mu17yzfn.fsf@inria.fr> <20201009091231.26287-1-ludo@gnu.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) This allows 'gcc-toolchain' to be used as a drop-in replacement for the default tool chain through '--with-toolchain=gcc-toolchain'. * gnu/packages/commencement.scm (make-gcc-toolchain)[native-search-paths] [search-paths]: Append LIBC's search paths. --- gnu/packages/commencement.scm | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gnu/packages/commencement.scm b/gnu/packages/commencement.scm index 4041d5bb89..0938bc3d46 100644 --- a/gnu/packages/commencement.scm +++ b/gnu/packages/commencement.scm @@ -3856,8 +3856,12 @@ COREUTILS-FINAL vs. COREUTILS, etc." "libc-static"))) #t)))) - (native-search-paths (package-native-search-paths gcc)) - (search-paths (package-search-paths gcc)) + (native-search-paths + (append (package-native-search-paths gcc) + (package-native-search-paths libc))) ;GUIX_LOCPATH + (search-paths + (append (package-search-paths gcc) + (package-search-paths libc))) (license (package-license gcc)) (synopsis "Complete GCC tool chain for C/C++ development") -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 09 05:13:05 2020 Received: (at 43679) by debbugs.gnu.org; 9 Oct 2020 09:13:05 +0000 Received: from localhost ([127.0.0.1]:34103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSX-00046C-1J for submit@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:05 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48808) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoST-00045P-CR for 43679@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:03 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57145) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQoSN-0001jX-RF; Fri, 09 Oct 2020 05:12:55 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56284 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kQoSL-0001o4-AL; Fri, 09 Oct 2020 05:12:53 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH v2 0/5] Add '--with-c-toolchain' Date: Fri, 9 Oct 2020 11:12:26 +0200 Message-Id: <20201009091231.26287-1-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <87mu17yzfn.fsf@inria.fr> References: <87mu17yzfn.fsf@inria.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Hi! This is v2 of this patch, with these changes: 1. ‘with-toolchain’ is replaced by ‘with-c-toolchain’ everywhere, with the understanding that it’s about the C/C++ toolchain in practice. In the end I’m sympathetic with the argument that C/C++ don’t have a monopoly on toolchains. ;-) 2. ‘--with-c-toolchain=PACKAGE=TOOLCHAIN’ rebuilds not just PACKAGE with TOOLCHAIN, but also everything above PACKAGE with TOOLCHAIN (in v1, only PACKAGE was rebuilt with TOOLCHAIN but everything above it had to be rebuilt anyway.) The main motivation here is to reduce the changes that we’re introducing ABI incompatibilities that users would have to work around by passing on ‘--with-c-toolchain’ for each package in the chain. I think it also more closely matches user expectations: when you see things are being rebuilt, you’re likely to think that’s because they’re rebuilt with the new toolchain, not the default one. Feedback welcome! Ludo’. Ludovic Courtès (5): gnu: gcc-toolchain: Add 'GUIX_LOCPATH' to the search paths. gnu: clang-toolchain: Add 'GUIX_LOCPATH' to the search paths. gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. packages: Add 'package-with-c-toolchain'. guix build: Add '--with-c-toolchain'. doc/guix.texi | 70 +++++++++++++++++++++++++++++ gnu/packages/commencement.scm | 8 +++- gnu/packages/llvm.scm | 12 ++++- guix/build-system.scm | 35 ++++++++++++++- guix/packages.scm | 9 ++++ guix/scripts/build.scm | 84 +++++++++++++++++++++++++++++++++++ tests/packages.scm | 20 +++++++++ tests/scripts-build.scm | 82 ++++++++++++++++++++++++++++++++++ 8 files changed, 315 insertions(+), 5 deletions(-) -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 09 05:13:07 2020 Received: (at 43679) by debbugs.gnu.org; 9 Oct 2020 09:13:07 +0000 Received: from localhost ([127.0.0.1]:34108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSZ-00046a-Eo for submit@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:07 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48816) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSW-00045U-CO for 43679@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:04 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57150) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQoSQ-0001jr-DC; Fri, 09 Oct 2020 05:12:58 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56284 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kQoSP-0001o4-JY; Fri, 09 Oct 2020 05:12:57 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH v2 2/5] gnu: clang-toolchain: Add 'GUIX_LOCPATH' to the search paths. Date: Fri, 9 Oct 2020 11:12:28 +0200 Message-Id: <20201009091231.26287-3-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009091231.26287-1-ludo@gnu.org> References: <87mu17yzfn.fsf@inria.fr> <20201009091231.26287-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) From: Ludovic Courtès * gnu/packages/llvm.scm (make-clang-toolchain)[native-search-paths]: Add 'GUIX_LOCPATH'. --- gnu/packages/llvm.scm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 15078a1168..4b42c4921a 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -484,7 +484,11 @@ code analysis tools.") "libc-static"))) #t)))) - (native-search-paths (package-native-search-paths clang)) + (native-search-paths + (append (package-native-search-paths clang) + (list (search-path-specification ;copied from glibc + (variable "GUIX_LOCPATH") + (files '("lib/locale")))))) (search-paths (package-search-paths clang)) (license (package-license clang)) -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 09 05:13:08 2020 Received: (at 43679) by debbugs.gnu.org; 9 Oct 2020 09:13:08 +0000 Received: from localhost ([127.0.0.1]:34110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSZ-00046c-Oz for submit@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48828) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSX-00045V-5t for 43679@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:05 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57152) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQoSR-0001jx-JN; Fri, 09 Oct 2020 05:12:59 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56284 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kQoSQ-0001o4-NX; Fri, 09 Oct 2020 05:12:59 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH v2 3/5] gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. Date: Fri, 9 Oct 2020 11:12:29 +0200 Message-Id: <20201009091231.26287-4-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009091231.26287-1-ludo@gnu.org> References: <87mu17yzfn.fsf@inria.fr> <20201009091231.26287-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) From: Ludovic Courtès * gnu/packages/llvm.scm (make-clang-toolchain)[arguments]: Create 'cc' and 'c++' symlinks. --- gnu/packages/llvm.scm | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gnu/packages/llvm.scm b/gnu/packages/llvm.scm index 4b42c4921a..361b39710b 100644 --- a/gnu/packages/llvm.scm +++ b/gnu/packages/llvm.scm @@ -476,6 +476,12 @@ code analysis tools.") (((names . directories) ...) (union-build out directories))) + ;; Create 'cc' and 'c++' so that one can use it as a + ;; drop-in replacement for the default tool chain and + ;; have configure scripts find the compiler. + (symlink "clang" (string-append out "/bin/cc")) + (symlink "clang++" (string-append out "/bin/c++")) + (union-build (assoc-ref %outputs "debug") (list (assoc-ref %build-inputs "libc-debug"))) -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 09 05:13:09 2020 Received: (at 43679) by debbugs.gnu.org; 9 Oct 2020 09:13:09 +0000 Received: from localhost ([127.0.0.1]:34112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSa-00046k-1i for submit@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:09 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48834) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSX-00045X-Kr for 43679@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:06 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57154) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQoSS-0001k3-ES; Fri, 09 Oct 2020 05:13:00 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56284 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kQoSR-0001o4-Te; Fri, 09 Oct 2020 05:13:00 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH v2 4/5] packages: Add 'package-with-c-toolchain'. Date: Fri, 9 Oct 2020 11:12:30 +0200 Message-Id: <20201009091231.26287-5-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009091231.26287-1-ludo@gnu.org> References: <87mu17yzfn.fsf@inria.fr> <20201009091231.26287-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) * guix/build-system.scm (build-system-with-c-toolchain): New procedure. * guix/packages.scm (package-with-c-toolchain): New procedure. * tests/packages.scm ("package-with-c-toolchain"): New test. * doc/guix.texi (package Reference): Document 'package-with-c-toolchain'. (Build Systems): Mention it. --- doc/guix.texi | 32 ++++++++++++++++++++++++++++++++ guix/build-system.scm | 35 +++++++++++++++++++++++++++++++++-- guix/packages.scm | 9 +++++++++ tests/packages.scm | 20 ++++++++++++++++++++ 4 files changed, 94 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index a6260a12aa..38a8e5d4a6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -6530,6 +6530,35 @@ cross-compiling: It is an error to refer to @code{this-package} outside a package definition. @end deffn +Because packages are regular Scheme objects that capture a complete +dependency graph and associated build procedures, it is often useful to +write procedures that take a package and return a modified version +thereof according to some parameters. Below are a few examples. + +@cindex tool chain, choosing a package's tool chain +@deffn {Scheme Procedure} package-with-c-toolchain @var{package} @var{toolchain} +Return a variant of @var{package} that uses @var{toolchain} instead of +the default GNU C/C++ toolchain. @var{toolchain} must be a list of +inputs (label/package tuples) providing equivalent functionality, such +as the @code{gcc-toolchain} package. + +The example below returns a variant of the @code{hello} package built +with GCC@tie{}10.x and the rest of the GNU tool chain (Binutils and the +GNU C Library) instead of the default tool chain: + +@lisp +(let ((toolchain (specification->package "gcc-toolchain@@10"))) + (package-with-c-toolchain hello `(("toolchain" ,toolchain)))) +@end lisp + +The build tool chain is part of the @dfn{implicit inputs} of +packages---it's usually not listed as part of the various ``inputs'' +fields and is instead pulled in by the build system. Consequently, this +procedure works by changing the build system of @var{package} so that it +pulls in @var{toolchain} instead of the defaults. @ref{Build Systems}, +for more on build systems. +@end deffn + @node origin Reference @subsection @code{origin} Reference @@ -6666,6 +6695,9 @@ ornamentation---in other words, a bag is a lower-level representation of a package, which includes all the inputs of that package, including some that were implicitly added by the build system. This intermediate representation is then compiled to a derivation (@pxref{Derivations}). +The @code{package-with-c-toolchain} is an example of a way to change the +implicit inputs that a package's build system pulls in (@pxref{package +Reference, @code{package-with-c-toolchain}}). Build systems accept an optional list of @dfn{arguments}. In package definitions, these are passed @i{via} the @code{arguments} field diff --git a/guix/build-system.scm b/guix/build-system.scm index 4174972b98..76d670995c 100644 --- a/guix/build-system.scm +++ b/guix/build-system.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2012, 2013, 2014 Ludovic Courtès +;;; Copyright © 2012, 2013, 2014, 2020 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -18,6 +18,7 @@ (define-module (guix build-system) #:use-module (guix records) + #:use-module (srfi srfi-1) #:use-module (ice-9 match) #:export (build-system build-system? @@ -37,7 +38,9 @@ bag-arguments bag-build - make-bag)) + make-bag + + build-system-with-c-toolchain)) (define-record-type* build-system make-build-system build-system? @@ -98,3 +101,31 @@ intermediate representation just above derivations." #:outputs outputs #:target target arguments)))) + +(define (build-system-with-c-toolchain bs toolchain) + "Return a variant of BS, a build system, that uses TOOLCHAIN instead of the +default GNU C/C++ toolchain. TOOLCHAIN must be a list of +inputs (label/package tuples) providing equivalent functionality, such as the +'gcc-toolchain' package." + (define lower + (build-system-lower bs)) + + (define toolchain-packages + ;; These are the GNU toolchain packages pulled in by GNU-BUILD-SYSTEM and + ;; all the build systems that inherit from it. Keep the list in sync with + ;; 'standard-packages' in (guix build-system gnu). + '("gcc" "binutils" "libc" "libc:static" "ld-wrapper")) + + (define (lower* . args) + (let ((lowered (apply lower args))) + (bag + (inherit lowered) + (build-inputs + (append (fold alist-delete + (bag-build-inputs lowered) + toolchain-packages) + toolchain))))) + + (build-system + (inherit bs) + (lower lower*))) diff --git a/guix/packages.scm b/guix/packages.scm index 4f2bb432be..24d6417065 100644 --- a/guix/packages.scm +++ b/guix/packages.scm @@ -124,6 +124,7 @@ package-patched-vulnerabilities package-with-patches package-with-extra-patches + package-with-c-toolchain package/inherit transitive-input-references @@ -790,6 +791,14 @@ specifies modules in scope when evaluating SNIPPET." (append (origin-patches (package-source original)) patches))) +(define (package-with-c-toolchain package toolchain) + "Return a variant of PACKAGE that uses TOOLCHAIN instead of the default GNU +C/C++ toolchain. TOOLCHAIN must be a list of inputs (label/package tuples) +providing equivalent functionality, such as the 'gcc-toolchain' package." + (let ((bs (package-build-system package))) + (package/inherit package + (build-system (build-system-with-c-toolchain bs toolchain))))) + (define (transitive-inputs inputs) "Return the closure of INPUTS when considering the 'propagated-inputs' edges. Omit duplicate inputs, except for those already present in INPUTS diff --git a/tests/packages.scm b/tests/packages.scm index 5d5abcbd76..2d13d91344 100644 --- a/tests/packages.scm +++ b/tests/packages.scm @@ -1430,6 +1430,26 @@ (derivation-file-name (package-derivation %store coreutils)))))))) +(test-assert "package-with-c-toolchain" + (let* ((dep (dummy-package "chbouib" + (build-system gnu-build-system) + (native-inputs `(("x" ,grep))))) + (p0 (dummy-package "thingie" + (build-system gnu-build-system) + (inputs `(("foo" ,grep) + ("bar" ,dep))))) + (tc (dummy-package "my-toolchain")) + (p1 (package-with-c-toolchain p0 `(("toolchain" ,tc))))) + (define toolchain-packages + '("gcc" "binutils" "glibc" "ld-wrapper")) + + (match (bag-build-inputs (package->bag p1)) + ((("foo" foo) ("bar" bar) (_ (= package-name packages) . _) ...) + (and (not (any (cut member <> packages) toolchain-packages)) + (member "my-toolchain" packages) + (eq? foo grep) + (eq? bar dep)))))) + (test-equal "package-patched-vulnerabilities" '(("CVE-2015-1234") ("CVE-2016-1234" "CVE-2018-4567") -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Fri Oct 09 05:13:14 2020 Received: (at 43679) by debbugs.gnu.org; 9 Oct 2020 09:13:14 +0000 Received: from localhost ([127.0.0.1]:34114 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSf-000478-SR for submit@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:14 -0400 Received: from eggs.gnu.org ([209.51.188.92]:48842) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kQoSZ-00045f-5F for 43679@debbugs.gnu.org; Fri, 09 Oct 2020 05:13:08 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]:57157) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kQoST-0001kG-VL; Fri, 09 Oct 2020 05:13:01 -0400 Received: from [2a01:e0a:1d:7270:af76:b9b:ca24:c465] (port=56284 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.82) (envelope-from ) id 1kQoSS-0001o4-Ob; Fri, 09 Oct 2020 05:13:01 -0400 From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= To: 43679@debbugs.gnu.org Subject: [PATCH v2 5/5] guix build: Add '--with-c-toolchain'. Date: Fri, 9 Oct 2020 11:12:31 +0200 Message-Id: <20201009091231.26287-6-ludo@gnu.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201009091231.26287-1-ludo@gnu.org> References: <87mu17yzfn.fsf@inria.fr> <20201009091231.26287-1-ludo@gnu.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 43679 Cc: =?UTF-8?q?Ludovic=20Court=C3=A8s?= X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) From: Ludovic Courtès * guix/scripts/build.scm (package-dependents/spec) (package-toolchain-rewriting, transform-package-toolchain): New procedures. (%transformations): Add it. (%transformation-options, show-transformation-options-help): Add '--with-c-toolchain'. * tests/scripts-build.scm (depends-on-toolchain?): New procedure. ("options->transformation, with-c-toolchain") ("options->transformation, with-c-toolchain twice") New test. ("options->transformation, with-c-toolchain, no effect"): New tests. * doc/guix.texi (Package Transformation Options): Document it. --- doc/guix.texi | 38 +++++++++++++++++++ guix/scripts/build.scm | 84 +++++++++++++++++++++++++++++++++++++++++ tests/scripts-build.scm | 82 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 204 insertions(+) diff --git a/doc/guix.texi b/doc/guix.texi index 38a8e5d4a6..c955041c61 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -9338,6 +9338,44 @@ must be compatible. If @var{replacement} is somehow incompatible with @var{package}, then the resulting package may be unusable. Use with care! +@cindex tool chain, changing the build tool chain of a package +@item --with-c-toolchain=@var{package}=@var{toolchain} +This option changes the compilation of @var{package} and everything that +depends on it so that they get built with @var{toolchain} instead of the +default GNU tool chain for C/C++. + +Consider this example: + +@example +guix build octave-cli \ + --with-c-toolchain=fftw=gcc-toolchain@@10 \ + --with-c-toolchain=fftwf=gcc-toolchain@@10 +@end example + +The command above builds a variant of the @code{fftw} and @code{fftwf} +packages using version 10 of @code{gcc-toolchain} instead of the default +tool chain, and then builds a variant of the GNU@tie{}Octave +command-line interface using them. GNU@tie{}Octave itself is also built +with @code{gcc-toolchain@@10}. + +This other example builds the Hardware Locality (@code{hwloc}) library +and its dependents up to @code{intel-mpi-benchmarks} with the Clang C +compiler: + +@example +guix build --with-c-toolchain=hwloc=clang-toolchain \ + intel-mpi-benchmarks +@end example + +@quotation Note +There can be application binary interface (ABI) incompatibilities among +tool chains. This is particularly true of the C++ standard library and +run-time support libraries such as that of OpenMP. By rebuilding all +dependents with the same tool chain, @option{--with-c-toolchain} minimizes +the risks of incompatibility but cannot entirely eliminate them. Choose +@var{package} wisely. +@end quotation + @item --with-git-url=@var{package}=@var{url} @cindex Git, using the latest commit @cindex latest commit, building diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm index 72a5d46347..e59e0ee67f 100644 --- a/guix/scripts/build.scm +++ b/guix/scripts/build.scm @@ -26,6 +26,7 @@ #:use-module (guix store) #:use-module (guix derivations) #:use-module (guix packages) + #:use-module (guix memoization) #:use-module (guix grafts) #:use-module (guix utils) @@ -396,6 +397,83 @@ a checkout of the Git repository at the given URL." (rewrite obj) obj))) +(define (package-dependents/spec top bottom) + "Return the list of dependents of BOTTOM, a spec string, that are also +dependencies of TOP, a package." + (define-values (name version) + (package-name->name+version bottom)) + + (define dependent? + (mlambda (p) + (and (package? p) + (or (and (string=? name (package-name p)) + (or (not version) + (version-prefix? version (package-version p)))) + (match (bag-direct-inputs (package->bag p)) + (((labels dependencies . _) ...) + (any dependent? dependencies))))))) + + (filter dependent? (package-closure (list top)))) + +(define (package-toolchain-rewriting p bottom toolchain) + "Return a procedure that, when passed a package that's either BOTTOM or one +of its dependents up to P so, changes it so it is built with TOOLCHAIN. +TOOLCHAIN must be an input list." + (define rewriting-property + (gensym " package-toolchain-rewriting")) + + (match (package-dependents/spec p bottom) + (() ;P does not depend on BOTTOM + identity) + (set + ;; SET is the list of packages "between" P and BOTTOM (included) whose + ;; toolchain needs to be changed. + (package-mapping (lambda (p) + (if (or (assq rewriting-property + (package-properties p)) + (not (memq p set))) + p + (let ((p (package-with-c-toolchain p toolchain))) + (package/inherit p + (properties `((,rewriting-property . #t) + ,@(package-properties p))))))) + (lambda (p) + (or (assq rewriting-property (package-properties p)) + (not (memq p set)))) + #:deep? #t)))) + +(define (transform-package-toolchain replacement-specs) + "Return a procedure that, when passed a package, changes its toolchain or +that of its dependencies according to REPLACEMENT-SPECS. REPLACEMENT-SPECS is +a list of strings like \"fftw=gcc-toolchain@10\" meaning that the package to +the left of the equal sign must be built with the toolchain to the right of +the equal sign." + (define split-on-commas + (cute string-tokenize <> (char-set-complement (char-set #\,)))) + + (define (specification->input spec) + (let ((package (specification->package spec))) + (list (package-name package) package))) + + (define replacements + (map (lambda (spec) + (match (string-tokenize spec %not-equal) + ((spec (= split-on-commas toolchain)) + (cons spec (map specification->input toolchain))) + (_ + (leave (G_ "~a: invalid toolchain replacement specification~%") + spec)))) + replacement-specs)) + + (lambda (store obj) + (if (package? obj) + (or (any (match-lambda + ((bottom . toolchain) + ((package-toolchain-rewriting obj bottom toolchain) obj))) + replacements) + obj) + obj))) + (define (transform-package-tests specs) "Return a procedure that, when passed a package, sets #:tests? #f in its 'arguments' field." @@ -426,6 +504,7 @@ a checkout of the Git repository at the given URL." (with-branch . ,transform-package-source-branch) (with-commit . ,transform-package-source-commit) (with-git-url . ,transform-package-source-git-url) + (with-c-toolchain . ,transform-package-toolchain) (without-tests . ,transform-package-tests))) (define (transformation-procedure key) @@ -455,6 +534,8 @@ a checkout of the Git repository at the given URL." (parser 'with-commit)) (option '("with-git-url") #t #f (parser 'with-git-url)) + (option '("with-c-toolchain") #t #f + (parser 'with-c-toolchain)) (option '("without-tests") #t #f (parser 'without-tests))))) @@ -477,6 +558,9 @@ a checkout of the Git repository at the given URL." (display (G_ " --with-git-url=PACKAGE=URL build PACKAGE from the repository at URL")) + (display (G_ " + --with-c-toolchain=PACKAGE=TOOLCHAIN + build PACKAGE and its dependents with TOOLCHAIN")) (display (G_ " --without-tests=PACKAGE build PACKAGE without running its tests"))) diff --git a/tests/scripts-build.scm b/tests/scripts-build.scm index 5f91360953..6925374baa 100644 --- a/tests/scripts-build.scm +++ b/tests/scripts-build.scm @@ -22,6 +22,8 @@ #:use-module (guix derivations) #:use-module (guix packages) #:use-module (guix git-download) + #:use-module (guix build-system) + #:use-module (guix build-system gnu) #:use-module (guix scripts build) #:use-module (guix ui) #:use-module (guix utils) @@ -30,6 +32,8 @@ #:use-module (gnu packages base) #:use-module (gnu packages busybox) #:use-module (ice-9 match) + #:use-module (srfi srfi-1) + #:use-module (srfi srfi-26) #:use-module (srfi srfi-64)) @@ -270,6 +274,80 @@ ((("x" dep3)) (map package-source (list dep1 dep3)))))))))))) +(define* (depends-on-toolchain? p #:optional (toolchain "gcc-toolchain")) + "Return true if P depends on TOOLCHAIN instead of the default tool chain." + (define toolchain-packages + '("gcc" "binutils" "glibc" "ld-wrapper")) + + (define (package-name* obj) + (and (package? obj) (package-name obj))) + + (match (bag-build-inputs (package->bag p)) + (((_ (= package-name* packages) . _) ...) + (and (not (any (cut member <> packages) toolchain-packages)) + (member toolchain packages))))) + +(test-assert "options->transformation, with-c-toolchain" + (let* ((dep0 (dummy-package "chbouib" + (build-system gnu-build-system) + (native-inputs `(("y" ,grep))))) + (dep1 (dummy-package "stuff" + (native-inputs `(("x" ,dep0))))) + (p (dummy-package "thingie" + (build-system gnu-build-system) + (inputs `(("foo" ,grep) + ("bar" ,dep1))))) + (t (options->transformation + '((with-c-toolchain . "chbouib=gcc-toolchain"))))) + ;; Here we check that the transformation applies to DEP0 and all its + ;; dependents: DEP0 must use GCC-TOOLCHAIN, DEP1 must use GCC-TOOLCHAIN + ;; and the DEP0 that uses GCC-TOOLCHAIN, and so on. + (with-store store + (let ((new (t store p))) + (and (depends-on-toolchain? new "gcc-toolchain") + (match (bag-build-inputs (package->bag new)) + ((("foo" dep0) ("bar" dep1) _ ...) + (and (depends-on-toolchain? dep1 "gcc-toolchain") + (not (depends-on-toolchain? dep0 "gcc-toolchain")) + (string=? (package-full-name dep0) + (package-full-name grep)) + (match (bag-build-inputs (package->bag dep1)) + ((("x" dep) _ ...) + (and (depends-on-toolchain? dep "gcc-toolchain") + (match (bag-build-inputs (package->bag dep)) + ((("y" dep) _ ...) ;this one is unchanged + (eq? dep grep)))))))))))))) + +(test-equal "options->transformation, with-c-toolchain twice" + (package-full-name grep) + (let* ((dep0 (dummy-package "chbouib")) + (dep1 (dummy-package "stuff")) + (p (dummy-package "thingie" + (build-system gnu-build-system) + (inputs `(("foo" ,dep0) + ("bar" ,dep1) + ("baz" ,grep))))) + (t (options->transformation + '((with-c-toolchain . "chbouib=clang-toolchain") + (with-c-toolchain . "stuff=clang-toolchain"))))) + (with-store store + (let ((new (t store p))) + (and (depends-on-toolchain? new "clang-toolchain") + (match (bag-build-inputs (package->bag new)) + ((("foo" dep0) ("bar" dep1) ("baz" dep2) _ ...) + (and (depends-on-toolchain? dep0 "clang-toolchain") + (depends-on-toolchain? dep1 "clang-toolchain") + (not (depends-on-toolchain? dep2 "clang-toolchain")) + (package-full-name dep2))))))))) + +(test-assert "options->transformation, with-c-toolchain, no effect" + (let ((p (dummy-package "thingie")) + (t (options->transformation + '((with-c-toolchain . "does-not-exist=gcc-toolchain"))))) + ;; When it has no effect, '--with-c-toolchain' returns P. + (with-store store + (eq? (t store p) p)))) + (test-assert "options->transformation, without-tests" (let* ((dep (dummy-package "dep")) (p (dummy-package "foo" @@ -286,3 +364,7 @@ '(#:tests? #f)))))))) (test-end) + +;;; Local Variables: +;;; eval: (put 'dummy-package 'scheme-indent-function 1) +;;; End: -- 2.28.0 From debbugs-submit-bounces@debbugs.gnu.org Mon Oct 12 12:28:05 2020 Received: (at 43679-done) by debbugs.gnu.org; 12 Oct 2020 16:28:05 +0000 Received: from localhost ([127.0.0.1]:43778 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kS0g8-0003Bc-UI for submit@debbugs.gnu.org; Mon, 12 Oct 2020 12:28:05 -0400 Received: from mail2-relais-roc.national.inria.fr ([192.134.164.83]:57660) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kS0g7-0003B8-3P for 43679-done@debbugs.gnu.org; Mon, 12 Oct 2020 12:28:04 -0400 X-IronPort-AV: E=Sophos;i="5.77,367,1596492000"; d="scan'208";a="472218472" Received: from 91-160-117-201.subs.proxad.net (HELO ribbon) ([91.160.117.201]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Oct 2020 18:27:56 +0200 From: =?utf-8?Q?Ludovic_Court=C3=A8s?= To: 43679-done@debbugs.gnu.org Subject: Re: [bug#43679] [PATCH v2 0/5] Add '--with-c-toolchain' References: <87mu17yzfn.fsf@inria.fr> <20201009091231.26287-1-ludo@gnu.org> Date: Mon, 12 Oct 2020 18:27:55 +0200 In-Reply-To: <20201009091231.26287-1-ludo@gnu.org> ("Ludovic =?utf-8?Q?Cou?= =?utf-8?Q?rt=C3=A8s=22's?= message of "Fri, 9 Oct 2020 11:12:26 +0200") Message-ID: <871ri3pfxw.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -5.0 (-----) X-Debbugs-Envelope-To: 43679-done X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -6.0 (------) Hi! Ludovic Court=C3=A8s skribis: > This is v2 of this patch, with these changes: > > 1. =E2=80=98with-toolchain=E2=80=99 is replaced by =E2=80=98with-c-tool= chain=E2=80=99 everywhere, > with the understanding that it=E2=80=99s about the C/C++ toolchain > in practice. In the end I=E2=80=99m sympathetic with the argument > that C/C++ don=E2=80=99t have a monopoly on toolchains. ;-) > > 2. =E2=80=98--with-c-toolchain=3DPACKAGE=3DTOOLCHAIN=E2=80=99 rebuilds = not just > PACKAGE with TOOLCHAIN, but also everything above PACKAGE > with TOOLCHAIN (in v1, only PACKAGE was rebuilt with TOOLCHAIN > but everything above it had to be rebuilt anyway.) > > The main motivation here is to reduce the changes that we=E2=80=99re > introducing ABI incompatibilities that users would have to work > around by passing on =E2=80=98--with-c-toolchain=E2=80=99 for each p= ackage in > the chain. I think it also more closely matches user > expectations: when you see things are being rebuilt, you=E2=80=99re > likely to think that=E2=80=99s because they=E2=80=99re rebuilt with = the new > toolchain, not the default one. > > Feedback welcome! > > Ludo=E2=80=99. > > Ludovic Court=C3=A8s (5): > gnu: gcc-toolchain: Add 'GUIX_LOCPATH' to the search paths. > gnu: clang-toolchain: Add 'GUIX_LOCPATH' to the search paths. > gnu: clang-toolchain: Create 'cc' and 'c++' symlinks. > packages: Add 'package-with-c-toolchain'. > guix build: Add '--with-c-toolchain'. Pushed as a2ed00f79fd5bf69c6cca3fa7bdc62726bf848fa! Ludo=E2=80=99. From unknown Sat Aug 16 16:15:41 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Tue, 10 Nov 2020 12:24:10 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator