From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id MPqdMneTmmMfhAAAbAwnHQ (envelope-from ) for ; Thu, 15 Dec 2022 04:24:39 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id gGqXMneTmmNbzAAA9RJhRA (envelope-from ) for ; Thu, 15 Dec 2022 04:24:39 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 530C928E17 for ; Thu, 15 Dec 2022 04:24:39 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p5eqt-000368-4l; Wed, 14 Dec 2022 22:24:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p5eqp-00035O-P0 for bug-guix@gnu.org; Wed, 14 Dec 2022 22:24:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p5eqp-00024r-0j; Wed, 14 Dec 2022 22:24:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p5eqo-0004pe-Sl; Wed, 14 Dec 2022 22:24:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#60056: [PATCH RFC 3/6] build-systems: gnu: Infer cross-toolchain from native-inputs components. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: ludo@gnu.org, bug-guix@gnu.org Resent-Date: Thu, 15 Dec 2022 03:24:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 60056 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 60056@debbugs.gnu.org Cc: Maxim Cournoyer , ludo@gnu.org X-Debbugs-Original-Xcc: ludo@gnu.org Received: via spool by 60056-submit@debbugs.gnu.org id=B60056.167107463518528 (code B ref 60056); Thu, 15 Dec 2022 03:24:02 +0000 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 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 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Country: US X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1671074679; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=ozyqNrJ2qFMoaVJQ/rclsTGhEMJp3k6oT0BanlCT0nI=; b=GrBE4kI2YaMLggMkMCNy60FKT5PBgzHf940Q61yYye+n0h+vwRPHpfCeN279V4cHUl9ki1 eWUTNldCck985WFy/vuJGwfg4bO0rkHIblqD9NKLj7JFaCjaU/Cr3uXzYKZ7NNnhmXK9dK gY1WjIAlF//RuAcE+PgHS4fBjWLGPL3Qk8j5MyBmi+OjWq660wpk+tFv1pPmk1jZ/ujVON 1yBIgYWo38upPJYCt+Nu5s836KxQ5nErjBpuM0SeZ4Nq7RmKJLE5xBS+J8UbbYeHNA4717 RGt//S+DB879LajtGmeEV7QRTWzdyLnZVRyOPXWD+ziU8Shbmo7Tumu+RtxwJg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=TrAFOU5z; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1671074679; a=rsa-sha256; cv=none; b=GDBseGOyeagoWMiAkxE7M4WlUMLZXhY8cAy4pYwkjIzBPHN2PseZE4YsvLPtzbt5cwhYZM Aqk+hBWH53StVaoUy3ypxh4x5e6j58+LgAwFVHGuqhXrXmaPCoNzrtwYk/WMshCwm7/KjE /B/5XZTM3/dlqiCNZmd32Re9f9p/rPkAybBUVswE0q3w9xe6k33+sEfgHAC64ZSdC6c6jp KlE49QUbw1Dp8DhjPgffpVGLIZR9/VGhAWslAkwdNEhlmqTKeMoQHRSuftiZKPoj82H2ml 4hAsTQRAqzdANGlnkksw+2AMYWTOmZ7ZTV4+nF2xYtOpQ//ftf/hy+/L+b8m1Q== X-Migadu-Spam-Score: -1.38 X-Spam-Score: -1.38 X-Migadu-Queue-Id: 530C928E17 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=TrAFOU5z; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) X-TUID: rO/bRWjdnI19 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