From debbugs-submit-bounces@debbugs.gnu.org Wed Dec 14 22:23:55 2022 Received: (at 60056) by debbugs.gnu.org; 15 Dec 2022 03:23:55 +0000 Received: from localhost ([127.0.0.1]:42271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5eqg-0004og-94 for submit@debbugs.gnu.org; Wed, 14 Dec 2022 22:23:54 -0500 Received: from mail-qt1-f178.google.com ([209.85.160.178]:35821) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p5eqc-0004o8-BV for 60056@debbugs.gnu.org; Wed, 14 Dec 2022 22:23:50 -0500 Received: by mail-qt1-f178.google.com with SMTP id h16so4244486qtu.2 for <60056@debbugs.gnu.org>; Wed, 14 Dec 2022 19:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ozyqNrJ2qFMoaVJQ/rclsTGhEMJp3k6oT0BanlCT0nI=; b=TrAFOU5zKtCXPoqq6w0Xv0YBo2z7z/PPrLBDAhwwlekUIyDbChD70MhPS2qMG6oZPi 9c+0diG22h/j3IJlzG2Fh74Yk4TbQF12Y5VF1iFZV35Xpp2Qfd/8qYVTA3lSh8vElU8P IT91qqTpkLI/vqHNBWPclE6NqZC87rOAKtGOJbv2FQ3g6tW0uOIje4IWKB95ikyGvfIk 3RrKbILsbKIhQRYrvmFR89/9H3yVI7ellmaP572OqkP6P/NagRC5mZ1baaRdfD52XxH8 JCoJYMUsDhxamXXGarp4Wd43dmqcN7BSriAiHJJfe9aeQKXcx1/yiqseAxBUQ/C86WwZ tCTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ozyqNrJ2qFMoaVJQ/rclsTGhEMJp3k6oT0BanlCT0nI=; b=Vz5qGKvIW2IMb6OZLONCiRR1DVqOGTb/hZm+NBDc41uiF4HXbmcn2z++3aBmgFhsmd 8qzpHLDtAQuTCMRabagamTfWfOGTLxsJ5fLWIajmeGN0QDD69X8LUlLsbIOyniTGetJR JeKMoAvGqNUl5UKIyXvuajK4A6MNfYI7hP+li3/a1qJC/PpL+OMnwN7zTMTqkOYMjuuf PatrQgRPHquJWuBRTAopXJpqrszo8G5LDdc/Mq8V/0a0VR343Wa2fyQTWHDOgKU349i0 Pukf1Db4aYiwiXEb/hUI+jwUAq74Z7g9zZS04Xz71t86gu1SlKqYgoRe8qq32fPBU4CF BRGg== X-Gm-Message-State: ANoB5pla2Niwd2cp4Cv5YZgkr0d6NUJa6x/E+YQJWVaMfOTnoWcr4alw rOtJ01k8qTwOKs+R7qbYt+je2zI0RXjCDfp3 X-Google-Smtp-Source: AA0mqf7rmYovBusOEZwhyAjfkzcYH7Bfjlltf6cd/U042KO/WcG6rjO9j092H+bvcUF8wt49bOmNwA== X-Received: by 2002:ac8:741a:0:b0:3a8:fdf:8ff8 with SMTP id p26-20020ac8741a000000b003a80fdf8ff8mr26168097qtq.36.1671074624597; Wed, 14 Dec 2022 19:23:44 -0800 (PST) Received: from localhost.localdomain (dsl-10-129-63.b2b2c.ca. [72.10.129.63]) by smtp.gmail.com with ESMTPSA id c13-20020ac853cd000000b003a7e4129f83sm2763101qtq.85.2022.12.14.19.23.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Dec 2022 19:23:44 -0800 (PST) From: Maxim Cournoyer To: 60056@debbugs.gnu.org Subject: [PATCH RFC 3/6] build-systems: gnu: Infer cross-toolchain from native-inputs components. Date: Wed, 14 Dec 2022 22:23:25 -0500 Message-Id: <20221215032328.3368-3-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221215032328.3368-1-maxim.cournoyer@gmail.com> References: <20221215032328.3368-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 X-Debbugs-Cc: zimon.toutoune@gmail.com X-Debbugs-Cc: dev@jpoiret.xyz X-Debbugs-Cc: mail@cbaines.net X-Debbugs-Cc: rekado@elephly.net X-Debbugs-Cc: othacehe@gnu.org X-Debbugs-Cc: ludo@gnu.org Content-Transfer-Encoding: 8bit X-Spam-Score: -0.0 (/) X-Debbugs-Envelope-To: 60056 Cc: Maxim Cournoyer 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 (-) This enables a user to override the base components used to build the cross toolchain, which allows for example to use an older version of GCC. * guix/build-system/gnu.scm (standard-cross-packages): New GCC, BINUTILS, LIBC and LINUX-LIBRE-HEADERS keyword arguments. Update doc. Rename implementation to... (%standard-cross-packages): ... this procedure, which is extended to support the above new arguments. Compute the cross toolchain components taking these arguments into account. (lower): Apply the GCC, BINUTILS, LIBC, and LINUX-LIBRE-HEADERS packages found in the native inputs to standard-cross-packages, when available. --- guix/build-system/gnu2.scm | 111 +++++++++++++++++++++++++++---------- 1 file changed, 83 insertions(+), 28 deletions(-) diff --git a/guix/build-system/gnu2.scm b/guix/build-system/gnu2.scm index 95fce76714..5b0780d315 100644 --- a/guix/build-system/gnu2.scm +++ b/guix/build-system/gnu2.scm @@ -68,7 +68,7 @@ (define* (package-with-explicit-inputs/deprecated p inputs temporarily instead of memoizing across all transformations where INPUTS is the same. -Rewrite P, which is assumed to use GNU-BUILD-SYSTEM2, to take INPUTS and +Rewrite P, which is assumed to use GNU-BUILD-SYSTEM, to take INPUTS and NATIVE-INPUTS as explicit inputs instead of the implicit default, and return it. INPUTS and NATIVE-INPUTS can be either input lists or thunks; in the latter case, they will be called in a context where the `%current-system' and @@ -287,9 +287,21 @@ (define private-keywords #:implicit-inputs? #:implicit-cross-inputs? ,@(if target '() '(#:target)))) + (define standard-cross-packages-args + ;; Since the packages used to customize the toolchain are intended to be + ;; provided manually at the package level, their actual package *name* + ;; must be expected, e.g. "glibc" rather than "libc". + (list #:gcc (and=> (assoc-ref native-inputs "gcc") car) + #:binutils (and=> (assoc-ref native-inputs "binutils") car) + #:libc (and=> (assoc-ref native-inputs "glibc") car) + #:linux-libre-headers + (and=> (assoc-ref native-inputs + "linux-libre-headers") car))) + (bag (name name) - (system system) (target target) + (system system) + (target target) (build-inputs `(,@(if source `(("source" ,source)) '()) @@ -301,7 +313,8 @@ (define private-keywords ;; . ,@(if target '() inputs) ,@(if (and target implicit-cross-inputs?) - (standard-cross-packages2 target 'host) + (apply standard-cross-packages2 + target 'host standard-cross-packages-args) '()) ,@(if implicit-inputs? (standard-packages2) @@ -314,7 +327,8 @@ (define private-keywords ;; 'cross-libc' (built with 'gnu-build'), whereas all the other packages ;; would use a target variant (built with 'gnu-cross-build'.) (target-inputs (if (and target implicit-cross-inputs?) - (standard-cross-packages2 target 'target) + (apply standard-cross-packages2 + target 'target standard-cross-packages-args) '())) (outputs (if strip-binaries? outputs @@ -439,34 +453,75 @@ (define builder ;;; Cross-compilation. ;;; -(define standard-cross-packages2 - (mlambda (target kind) - "Return the list of name/package tuples to cross-build for TARGET. KIND -is one of `host' or `target'." - (let* ((cross (resolve-interface '(gnu packages cross-base))) - (gcc (module-ref cross 'cross-gcc)) - (binutils (module-ref cross 'cross-binutils)) - (libc (module-ref cross 'cross-libc))) +(define* (standard-cross-packages2 target kind + #:key gcc binutils libc linux-libre-headers) + "Return the list of name/package tuples to cross-build for TARGET. KIND is +one of `host' or `target'. GCC, BINUTILS, LIBC and LINUX-LIBRE-HEADERS are +the packages to use to build the cross toolchain. Unless specified, the +defaults of the CROSS-GCC, CROSS-BINUTILS, CROSS-LIBC and CROSS-KERNEL-HEADERS +procedures from (gnu packages cross-base) are used." + (%standard-cross-packages2 target kind gcc binutils libc linux-libre-headers)) + +(define %standard-cross-packages2 + (mlambda (target kind gcc binutils libc linux-libre-headers) + (let* ((cross-base (resolve-interface '(gnu packages cross-base))) + (cross-gcc (module-ref cross-base 'cross-gcc)) + (cross-binutils (module-ref cross-base 'cross-binutils)) + (cross-libc (module-ref cross-base 'cross-libc)) + (cross-kernel-headers (module-ref cross-base 'cross-kernel-headers)) + (xbinutils (if binutils + (cross-binutils target #:binutils binutils) + (cross-binutils target))) + (cross-gcc-args/no-libc `(,target + ,@(if gcc + `(#:xgcc ,gcc) + '()) + ,@(if binutils + `(#:xbinutils ,xbinutils) + '()))) + (xgcc/no-libc (apply cross-gcc cross-gcc-args/no-libc)) + (cross-libc-args `(,target + ,@(if libc + `(#:libc ,libc) + '()) + ,@(if gcc + `(#:xgcc ,xgcc/no-libc) + '()) + ,@(if binutils + `(#:xbinutils ,xbinutils) + '()) + ,@(if linux-libre-headers + `(#:xheaders + ,(apply cross-kernel-headers + `(,target + ,@(if linux-libre-headers + `(#:linux-headers + ,linux-libre-headers)) + ,@(if gcc + `(#:xgcc ,xgcc/no-libc) + '()) + ,@(if binutils + `(#:xbinutils ,xbinutils) + '())))) + '()))) + (xlibc (apply cross-libc cross-libc-args)) + (xgcc (apply cross-gcc + `(,@cross-gcc-args/no-libc #:libc ,xlibc)))) (case kind ((host) ;; Cross-GCC appears once here, so that it's in $PATH... - `(("cross-gcc" ,(gcc target - #:xbinutils (binutils target) - #:libc (libc target))) - ("cross-binutils" ,(binutils target)))) + `(("cross-gcc" ,xgcc) + ("cross-binutils" ,xbinutils))) ((target) - (let ((libc (libc target))) - ;; ... and once here, so that libstdc++ & co. are in - ;; CROSS_CPLUS_INCLUDE_PATH, etc. - `(("cross-gcc" ,(gcc target - #:xbinutils (binutils target) - #:libc libc)) - ("cross-libc" ,libc) - - ;; MinGW's libc doesn't have a "static" output. - ,@(if (member "static" (package-outputs libc)) - `(("cross-libc:static" ,libc "static")) - '())))))))) + ;; ... and once here, so that libstdc++ & co. are in + ;; CROSS_CPLUS_INCLUDE_PATH, etc. + `(("cross-gcc" ,xgcc) + ("cross-libc" ,xlibc) + + ;; MinGW's libc doesn't have a "static" output. + ,@(if (member "static" (package-outputs xlibc)) + `(("cross-libc:static" ,xlibc "static")) + '()))))))) (define* (gnu-cross-build name #:key -- 2.38.1