From unknown Fri Aug 15 19:31:15 2025 X-Loop: help-debbugs@gnu.org Subject: [bug#65016] [PATCH] gnu: cross-libc: Return #f if no libc for target. Resent-From: Jean-Pierre De Jesus DIAZ Original-Sender: "Debbugs-submit" Resent-CC: guix@cbaines.net, efraim@flashner.co.il, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, vagrant@debian.org, guix-patches@gnu.org Resent-Date: Wed, 02 Aug 2023 13:25:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65016 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65016@debbugs.gnu.org Cc: Jean-Pierre De Jesus DIAZ , guix@cbaines.net, efraim@flashner.co.il, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, vagrant@debian.org X-Debbugs-Original-To: guix-patches@gnu.org X-Debbugs-Original-Xcc: guix@cbaines.net, efraim@flashner.co.il, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, vagrant@debian.org Received: via spool by submit@debbugs.gnu.org id=B.169098266921546 (code B ref -1); Wed, 02 Aug 2023 13:25:01 +0000 Received: (at submit) by debbugs.gnu.org; 2 Aug 2023 13:24:29 +0000 Received: from localhost ([127.0.0.1]:49220 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRBq0-0005bS-KF for submit@debbugs.gnu.org; Wed, 02 Aug 2023 09:24:29 -0400 Received: from lists.gnu.org ([2001:470:142::17]:54484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRBpx-0005bA-VV for submit@debbugs.gnu.org; Wed, 02 Aug 2023 09:24:27 -0400 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 1qRBpr-000219-Az for guix-patches@gnu.org; Wed, 02 Aug 2023 09:24:19 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qRBpo-0008TQ-61 for guix-patches@gnu.org; Wed, 02 Aug 2023 09:24:18 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc63c2e84so72879865e9.3 for ; Wed, 02 Aug 2023 06:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundationdevices.com; s=google; t=1690982653; x=1691587453; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mO+bfCq1sNyINBN0o6e7QjBr38J0eEy5sIQAG+nam/M=; b=T8D7YybEqLwfAoKotAuriy3MjrXbmMhDniqnOQr8OWpw2eiOqnRzdiDZh2DdyvkDrP SkoLIQUdrRLMDuT1W/SddhCG0bxNFgeZ1YukfxiY6mFZPm7crQW2jJCJfkr865ONL82P cb2fVl0IMECbqLwKwRf7HTcjtWvWt0dA13aGLOKGpdPNGKBxQddsrvKe8hevZbmk1DUs i02GU9+E0IqNgLCM9IXjZoNG8D+9Hybj8gv/JBuThnwd6T3RQwQyR5XGYtZGZ//D4QRu tppzEaKpVQnvZisdXT4To9tzR24IG/F/j13SDnwQ0zp8ZyL0Ckzv2MpOoJbl2AaoBwI1 0Dlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690982653; x=1691587453; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mO+bfCq1sNyINBN0o6e7QjBr38J0eEy5sIQAG+nam/M=; b=LJu8NwR9me9koYta7vu1eV9LeskFeIQ/KYpC4wOzDwg9oj2/vychRRV/1C/cw84aUy 69YhpBrFV1FfnhbYzDOQyIpkuHiOV2Ez5bRfwBGFIajAfqXteKaPakLd9TfE/xTh1qvV D1N3heC/tPhUk5WM3EmxxDqfV/ObyIh/hgvlXKqoZ/oqFjYnekkMoFoyDZK9AmQE/hJx aP/73+dG3ripffXg+pgNL3q8VxcOTPanvxLDG/VIax+Eo7Ezm52BpVRCBpmY5donzEmw jye3ToX7FqJj3I5F+NIIj9W6kBGRhbIpn7vY3sQ4hYPsGysmoQWQa1N6ykypk+2NzXqQ x6Ww== X-Gm-Message-State: ABy/qLZLbC/t0JSUys9VUGJBoEhzNtED5m7RuvWKy2vlTX38bo83C49T 8YsMy6cIHa0dafVlmtGcuEwfuzmqTc/nQt1NptL46Q== X-Google-Smtp-Source: APBJJlFJ30FASoMR1TOg4jnTi0EvMmeXkdDhI1hAYaOxwXKKDJxAcDJ7mSFBn1TLGj/x9Yu9NhcGdw== X-Received: by 2002:a1c:7505:0:b0:3fc:2e8:ea8b with SMTP id o5-20020a1c7505000000b003fc02e8ea8bmr4949484wmc.28.1690982653200; Wed, 02 Aug 2023 06:24:13 -0700 (PDT) Received: from omen15.home ([89.131.29.87]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c22c700b003fe1a96845bsm1660684wmg.2.2023.08.02.06.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 06:24:12 -0700 (PDT) From: Jean-Pierre De Jesus DIAZ Date: Wed, 2 Aug 2023 15:24:08 +0200 Message-Id: <20230802132408.1164570-1-jean@foundationdevices.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=jean@foundationdevices.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 2.7 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does not contain a libc implementation. This is the common case for most of the bare metal targets like aarch64-none-elf et al. Some bare-metal targets like `avr' do include AVR Libc though, but this patch allows handling that separately in the future. Content analysis details: (2.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.7 URIBL_BLACK Contains an URL listed in the URIBL blacklist [URIs: libc.so] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does not contain a libc implementation. This is the common case for most of the bare metal targets like aarch64-none-elf et al. Some bare-metal targets like `avr' do include AVR Libc though, but this patch allows handling that separately in the future. Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.7 URIBL_BLACK Contains an URL listed in the URIBL blacklist [URIs: libc.so] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does not contain a libc implementation. This is the common case for most of the bare metal targets like aarch64-none-elf et al. Some bare-metal targets like `avr' do include AVR Libc though, but this patch allows handling that separately in the future. As glibc now only has been tested to work on Linux and GNU Hurd it makes sense to contain it only for those targets. This essentially allows to specify targets on packages like: (arguments (list #:target "aarch64-none-elf" ...)) And it should provide the implicit cross inputs packages without a libc. And opens the door for bare-metal platform definitions on GNU Guix as it'd be nice to have proper cross toolchains and package management for bare metal packages as the industry right now relies on bundling each other's dependencies to compile entire systems. * guix/build-system/gnu.scm (standard-cross-packages): Only add libc inputs if actually present as a result of returning #f on cross-libc. Do the same for the `static' output. Signed-off-by: Jean-Pierre De Jesus DIAZ --- gnu/packages/cross-base.scm | 139 ++++++++++++++++++------------------ guix/build-system/gnu.scm | 6 +- 2 files changed, 75 insertions(+), 70 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 14cb365099..d24d85c179 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -610,74 +610,77 @@ (define* (cross-libc* target (xbinutils (cross-binutils target)) (xheaders (cross-kernel-headers target))) "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS -and the cross tool chain." - (if (target-mingw? target) - (let ((machine (substring target 0 (string-index target #\-)))) - (make-mingw-w64 machine - #:xgcc xgcc - #:xbinutils xbinutils)) - (package - (inherit libc) - (name (string-append "glibc-cross-" target)) - (arguments - (substitute-keyword-arguments - `( ;; Disable stripping (see above.) - #:strip-binaries? #f - - ;; This package is used as a target input, but it should not have - ;; the usual cross-compilation inputs since that would include - ;; itself. - #:implicit-cross-inputs? #f - - ;; We need SRFI 26. - #:modules ((guix build gnu-build-system) - (guix build utils) - (srfi srfi-26)) - - ,@(package-arguments libc)) - ((#:configure-flags flags) - `(cons ,(string-append "--host=" target) - ,(if (target-hurd? target) - `(append (list "--disable-werror" - ,@%glibc/hurd-configure-flags) - ,flags) - flags))) - ((#:phases phases) - `(modify-phases ,phases - (add-before 'configure 'set-cross-kernel-headers-path - (lambda* (#:key inputs #:allow-other-keys) - (let* ((kernel (assoc-ref inputs "kernel-headers")) - (cpath (string-append kernel "/include"))) - (for-each (cut setenv <> cpath) - ',%gcc-cross-include-paths) - (setenv "CROSS_LIBRARY_PATH" - (string-append kernel "/lib")) ; for Hurd's libihash - #t))) - ,@(if (target-hurd? target) - '((add-after 'install 'augment-libc.so - (lambda* (#:key outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out"))) - (substitute* (string-append out "/lib/libc.so") - (("/[^ ]+/lib/libc.so.0.3") - (string-append out "/lib/libc.so.0.3" - " libmachuser.so libhurduser.so")))) - #t))) - '()))))) - - ;; Shadow the native "kernel-headers" because glibc's recipe expects the - ;; "kernel-headers" input to point to the right thing. - (propagated-inputs `(("kernel-headers" ,xheaders))) - - (native-inputs `(("cross-gcc" ,xgcc) - ("cross-binutils" ,xbinutils) - ,@(if (target-hurd? target) - `(("cross-mig" - ,(cross-mig target - #:xgcc xgcc - #:xbinutils xbinutils))) - '()) - ,@(package-inputs libc) ;FIXME: static-bash - ,@(package-native-inputs libc)))))) +and the cross tool chain. If TARGET does not have a libc then #f is returned." + (match target + ((? target-mingw?) + (let ((machine (substring target 0 (string-index target #\-)))) + (make-mingw-w64 machine + #:xgcc xgcc + #:xbinutils xbinutils))) + ((or (? target-linux?) (? target-hurd?)) + (package + (inherit libc) + (name (string-append "glibc-cross-" target)) + (arguments + (substitute-keyword-arguments + `( ;; Disable stripping (see above.) + #:strip-binaries? #f + + ;; This package is used as a target input, but it should not have + ;; the usual cross-compilation inputs since that would include + ;; itself. + #:implicit-cross-inputs? #f + + ;; We need SRFI 26. + #:modules ((guix build gnu-build-system) + (guix build utils) + (srfi srfi-26)) + + ,@(package-arguments libc)) + ((#:configure-flags flags) + `(cons ,(string-append "--host=" target) + ,(if (target-hurd? target) + `(append (list "--disable-werror" + ,@%glibc/hurd-configure-flags) + ,flags) + flags))) + ((#:phases phases) + `(modify-phases ,phases + (add-before 'configure 'set-cross-kernel-headers-path + (lambda* (#:key inputs #:allow-other-keys) + (let* ((kernel (assoc-ref inputs "kernel-headers")) + (cpath (string-append kernel "/include"))) + (for-each (cut setenv <> cpath) + ',%gcc-cross-include-paths) + (setenv "CROSS_LIBRARY_PATH" + (string-append kernel "/lib")) ; for Hurd's libihash + #t))) + ,@(if (target-hurd? target) + '((add-after 'install 'augment-libc.so + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out"))) + (substitute* (string-append out "/lib/libc.so") + (("/[^ ]+/lib/libc.so.0.3") + (string-append out "/lib/libc.so.0.3" + " libmachuser.so libhurduser.so")))) + #t))) + '()))))) + + ;; Shadow the native "kernel-headers" because glibc's recipe expects the + ;; "kernel-headers" input to point to the right thing. + (propagated-inputs `(("kernel-headers" ,xheaders))) + + (native-inputs `(("cross-gcc" ,xgcc) + ("cross-binutils" ,xbinutils) + ,@(if (target-hurd? target) + `(("cross-mig" + ,(cross-mig target + #:xgcc xgcc + #:xbinutils xbinutils))) + '()) + ,@(package-inputs libc) ;FIXME: static-bash + ,@(package-native-inputs libc))))) + (else #f))) ;;; Concrete cross tool chains are instantiated like this: diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index c1aa187c42..1483f6baeb 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -460,10 +460,12 @@ (define standard-cross-packages `(("cross-gcc" ,(gcc target #:xbinutils (binutils target) #:libc libc)) - ("cross-libc" ,libc) + ,@(if libc + `(("cross-libc" ,libc)) + '()) ;; MinGW's libc doesn't have a "static" output. - ,@(if (member "static" (package-outputs libc)) + ,@(if (and libc (member "static" (package-outputs libc))) `(("cross-libc:static" ,libc "static")) '())))))))) -- 2.34.1 From unknown Fri Aug 15 19:31:15 2025 MIME-Version: 1.0 X-Mailer: MIME-tools 5.505 (Entity 5.505) X-Loop: help-debbugs@gnu.org From: help-debbugs@gnu.org (GNU bug Tracking System) To: Jean-Pierre De Jesus DIAZ Subject: bug#65016: closed (Re: bug#65016: [PATCH] gnu: cross-libc: Return #f if no libc for target.) Message-ID: References: <87il7lumcu.fsf@gnu.org> <20230802132408.1164570-1-jean@foundationdevices.com> X-Gnu-PR-Message: they-closed 65016 X-Gnu-PR-Package: guix-patches X-Gnu-PR-Keywords: patch Reply-To: 65016@debbugs.gnu.org Date: Thu, 05 Oct 2023 15:22:02 +0000 Content-Type: multipart/mixed; boundary="----------=_1696519322-16012-1" This is a multi-part message in MIME format... ------------=_1696519322-16012-1 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Your bug report #65016: [PATCH] gnu: cross-libc: Return #f if no libc for target. which was filed against the guix-patches package, has been closed. The explanation is attached below, along with your original report. If you require more details, please reply to 65016@debbugs.gnu.org. --=20 65016: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=3D65016 GNU Bug Tracking System Contact help-debbugs@gnu.org with problems ------------=_1696519322-16012-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at 65016-done) by debbugs.gnu.org; 5 Oct 2023 15:21:42 +0000 Received: from localhost ([127.0.0.1]:48258 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoQAY-00049a-I2 for submit@debbugs.gnu.org; Thu, 05 Oct 2023 11:21:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54492) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qoQAW-00049M-7k for 65016-done@debbugs.gnu.org; Thu, 05 Oct 2023 11:21:40 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qoQ9x-0003sM-Ah; Thu, 05 Oct 2023 11:21:13 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:In-Reply-To:Date:References:Subject:To: From; bh=rXjeeyD3MGWPJAKbMeo/B5b9XbfRBz1GBUJ8YudFTtk=; b=If61sJj91WMMiutrv1d1 xDT6ScvOZ42c3oh5dy/FcuLMv7zlQk+Yi9C6m+iB2zcjPBTBG3DPfZeMXEY4CqGowTzsPHUbW+0vK i8VPXG10zQNIhx7EktTbyAQnCl0asfzDOtjw8OVKM664Bs+mUOflaei6BKQF9SAJ/REeurJIEQL9G yjbbp3QoR44ig7k/u6H+5i7RB8yUHn2ho8Ty9SuPdrjlJKZMvVV246Ov3udcsVFmzhnmYjigGZXeD Y8bgulgdGXMyebuPFKzM4E46KmrXYwhXxSqsBEEBWRkZuGIF8doHnX3cWJk2nWyVkA2k79snrI3E+ 56QsjWHeVyov0w==; From: Mathieu Othacehe To: Jean-Pierre De Jesus DIAZ Subject: Re: bug#65016: [PATCH] gnu: cross-libc: Return #f if no libc for target. References: <20230802132408.1164570-1-jean@foundationdevices.com> Date: Thu, 05 Oct 2023 17:20:49 +0200 In-Reply-To: <20230802132408.1164570-1-jean@foundationdevices.com> (Jean-Pierre De Jesus DIAZ's message of "Wed, 2 Aug 2023 15:24:08 +0200") Message-ID: <87il7lumcu.fsf@gnu.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 65016-done Cc: dev@jpoiret.xyz, zimon.toutoune@gmail.com, vagrant@debian.org, ludo@gnu.org, me@tobias.gr, efraim@flashner.co.il, rekado@elephly.net, 65016-done@debbugs.gnu.org, guix@cbaines.net 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 (---) Hello, > * gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does > not contain a libc implementation. This is the first patch of your 66263 series unless I'm mistaken. Closing this one, Thanks, Mathieu ------------=_1696519322-16012-1 Content-Type: message/rfc822 Content-Disposition: inline Content-Transfer-Encoding: 7bit Received: (at submit) by debbugs.gnu.org; 2 Aug 2023 13:24:29 +0000 Received: from localhost ([127.0.0.1]:49220 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRBq0-0005bS-KF for submit@debbugs.gnu.org; Wed, 02 Aug 2023 09:24:29 -0400 Received: from lists.gnu.org ([2001:470:142::17]:54484) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qRBpx-0005bA-VV for submit@debbugs.gnu.org; Wed, 02 Aug 2023 09:24:27 -0400 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 1qRBpr-000219-Az for guix-patches@gnu.org; Wed, 02 Aug 2023 09:24:19 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qRBpo-0008TQ-61 for guix-patches@gnu.org; Wed, 02 Aug 2023 09:24:18 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-3fbc63c2e84so72879865e9.3 for ; Wed, 02 Aug 2023 06:24:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foundationdevices.com; s=google; t=1690982653; x=1691587453; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=mO+bfCq1sNyINBN0o6e7QjBr38J0eEy5sIQAG+nam/M=; b=T8D7YybEqLwfAoKotAuriy3MjrXbmMhDniqnOQr8OWpw2eiOqnRzdiDZh2DdyvkDrP SkoLIQUdrRLMDuT1W/SddhCG0bxNFgeZ1YukfxiY6mFZPm7crQW2jJCJfkr865ONL82P cb2fVl0IMECbqLwKwRf7HTcjtWvWt0dA13aGLOKGpdPNGKBxQddsrvKe8hevZbmk1DUs i02GU9+E0IqNgLCM9IXjZoNG8D+9Hybj8gv/JBuThnwd6T3RQwQyR5XGYtZGZ//D4QRu tppzEaKpVQnvZisdXT4To9tzR24IG/F/j13SDnwQ0zp8ZyL0Ckzv2MpOoJbl2AaoBwI1 0Dlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1690982653; x=1691587453; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mO+bfCq1sNyINBN0o6e7QjBr38J0eEy5sIQAG+nam/M=; b=LJu8NwR9me9koYta7vu1eV9LeskFeIQ/KYpC4wOzDwg9oj2/vychRRV/1C/cw84aUy 69YhpBrFV1FfnhbYzDOQyIpkuHiOV2Ez5bRfwBGFIajAfqXteKaPakLd9TfE/xTh1qvV D1N3heC/tPhUk5WM3EmxxDqfV/ObyIh/hgvlXKqoZ/oqFjYnekkMoFoyDZK9AmQE/hJx aP/73+dG3ripffXg+pgNL3q8VxcOTPanvxLDG/VIax+Eo7Ezm52BpVRCBpmY5donzEmw jye3ToX7FqJj3I5F+NIIj9W6kBGRhbIpn7vY3sQ4hYPsGysmoQWQa1N6ykypk+2NzXqQ x6Ww== X-Gm-Message-State: ABy/qLZLbC/t0JSUys9VUGJBoEhzNtED5m7RuvWKy2vlTX38bo83C49T 8YsMy6cIHa0dafVlmtGcuEwfuzmqTc/nQt1NptL46Q== X-Google-Smtp-Source: APBJJlFJ30FASoMR1TOg4jnTi0EvMmeXkdDhI1hAYaOxwXKKDJxAcDJ7mSFBn1TLGj/x9Yu9NhcGdw== X-Received: by 2002:a1c:7505:0:b0:3fc:2e8:ea8b with SMTP id o5-20020a1c7505000000b003fc02e8ea8bmr4949484wmc.28.1690982653200; Wed, 02 Aug 2023 06:24:13 -0700 (PDT) Received: from omen15.home ([89.131.29.87]) by smtp.gmail.com with ESMTPSA id 7-20020a05600c22c700b003fe1a96845bsm1660684wmg.2.2023.08.02.06.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Aug 2023 06:24:12 -0700 (PDT) From: Jean-Pierre De Jesus DIAZ To: guix-patches@gnu.org Subject: [PATCH] gnu: cross-libc: Return #f if no libc for target. Date: Wed, 2 Aug 2023 15:24:08 +0200 Message-Id: <20230802132408.1164570-1-jean@foundationdevices.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Debbugs-Cc: guix@cbaines.net, efraim@flashner.co.il, dev@jpoiret.xyz, ludo@gnu.org, othacehe@gnu.org, rekado@elephly.net, zimon.toutoune@gmail.com, me@tobias.gr, vagrant@debian.org Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=jean@foundationdevices.com; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: 2.7 (++) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does not contain a libc implementation. This is the common case for most of the bare metal targets like aarch64-none-elf et al. Some bare-metal targets like `avr' do include AVR Libc though, but this patch allows handling that separately in the future. Content analysis details: (2.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record 1.7 URIBL_BLACK Contains an URL listed in the URIBL blacklist [URIs: libc.so] -0.0 T_SCC_BODY_TEXT_LINE No description available. X-Debbugs-Envelope-To: submit Cc: Jean-Pierre De Jesus DIAZ 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.7 (+) X-Spam-Report: Spam detection software, running on the system "debbugs.gnu.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: * gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does not contain a libc implementation. This is the common case for most of the bare metal targets like aarch64-none-elf et al. Some bare-metal targets like `avr' do include AVR Libc though, but this patch allows handling that separately in the future. Content analysis details: (1.7 points, 10.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.7 URIBL_BLACK Contains an URL listed in the URIBL blacklist [URIs: libc.so] 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 T_SCC_BODY_TEXT_LINE No description available. -1.0 MAILING_LIST_MULTI Multiple indicators imply a widely-seen list manager * gnu/packages/cross-base.scm (cross-libc): Return #f if TARGET does not contain a libc implementation. This is the common case for most of the bare metal targets like aarch64-none-elf et al. Some bare-metal targets like `avr' do include AVR Libc though, but this patch allows handling that separately in the future. As glibc now only has been tested to work on Linux and GNU Hurd it makes sense to contain it only for those targets. This essentially allows to specify targets on packages like: (arguments (list #:target "aarch64-none-elf" ...)) And it should provide the implicit cross inputs packages without a libc. And opens the door for bare-metal platform definitions on GNU Guix as it'd be nice to have proper cross toolchains and package management for bare metal packages as the industry right now relies on bundling each other's dependencies to compile entire systems. * guix/build-system/gnu.scm (standard-cross-packages): Only add libc inputs if actually present as a result of returning #f on cross-libc. Do the same for the `static' output. Signed-off-by: Jean-Pierre De Jesus DIAZ --- gnu/packages/cross-base.scm | 139 ++++++++++++++++++------------------ guix/build-system/gnu.scm | 6 +- 2 files changed, 75 insertions(+), 70 deletions(-) diff --git a/gnu/packages/cross-base.scm b/gnu/packages/cross-base.scm index 14cb365099..d24d85c179 100644 --- a/gnu/packages/cross-base.scm +++ b/gnu/packages/cross-base.scm @@ -610,74 +610,77 @@ (define* (cross-libc* target (xbinutils (cross-binutils target)) (xheaders (cross-kernel-headers target))) "Return LIBC cross-built for TARGET, a GNU triplet. Use XGCC and XBINUTILS -and the cross tool chain." - (if (target-mingw? target) - (let ((machine (substring target 0 (string-index target #\-)))) - (make-mingw-w64 machine - #:xgcc xgcc - #:xbinutils xbinutils)) - (package - (inherit libc) - (name (string-append "glibc-cross-" target)) - (arguments - (substitute-keyword-arguments - `( ;; Disable stripping (see above.) - #:strip-binaries? #f - - ;; This package is used as a target input, but it should not have - ;; the usual cross-compilation inputs since that would include - ;; itself. - #:implicit-cross-inputs? #f - - ;; We need SRFI 26. - #:modules ((guix build gnu-build-system) - (guix build utils) - (srfi srfi-26)) - - ,@(package-arguments libc)) - ((#:configure-flags flags) - `(cons ,(string-append "--host=" target) - ,(if (target-hurd? target) - `(append (list "--disable-werror" - ,@%glibc/hurd-configure-flags) - ,flags) - flags))) - ((#:phases phases) - `(modify-phases ,phases - (add-before 'configure 'set-cross-kernel-headers-path - (lambda* (#:key inputs #:allow-other-keys) - (let* ((kernel (assoc-ref inputs "kernel-headers")) - (cpath (string-append kernel "/include"))) - (for-each (cut setenv <> cpath) - ',%gcc-cross-include-paths) - (setenv "CROSS_LIBRARY_PATH" - (string-append kernel "/lib")) ; for Hurd's libihash - #t))) - ,@(if (target-hurd? target) - '((add-after 'install 'augment-libc.so - (lambda* (#:key outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out"))) - (substitute* (string-append out "/lib/libc.so") - (("/[^ ]+/lib/libc.so.0.3") - (string-append out "/lib/libc.so.0.3" - " libmachuser.so libhurduser.so")))) - #t))) - '()))))) - - ;; Shadow the native "kernel-headers" because glibc's recipe expects the - ;; "kernel-headers" input to point to the right thing. - (propagated-inputs `(("kernel-headers" ,xheaders))) - - (native-inputs `(("cross-gcc" ,xgcc) - ("cross-binutils" ,xbinutils) - ,@(if (target-hurd? target) - `(("cross-mig" - ,(cross-mig target - #:xgcc xgcc - #:xbinutils xbinutils))) - '()) - ,@(package-inputs libc) ;FIXME: static-bash - ,@(package-native-inputs libc)))))) +and the cross tool chain. If TARGET does not have a libc then #f is returned." + (match target + ((? target-mingw?) + (let ((machine (substring target 0 (string-index target #\-)))) + (make-mingw-w64 machine + #:xgcc xgcc + #:xbinutils xbinutils))) + ((or (? target-linux?) (? target-hurd?)) + (package + (inherit libc) + (name (string-append "glibc-cross-" target)) + (arguments + (substitute-keyword-arguments + `( ;; Disable stripping (see above.) + #:strip-binaries? #f + + ;; This package is used as a target input, but it should not have + ;; the usual cross-compilation inputs since that would include + ;; itself. + #:implicit-cross-inputs? #f + + ;; We need SRFI 26. + #:modules ((guix build gnu-build-system) + (guix build utils) + (srfi srfi-26)) + + ,@(package-arguments libc)) + ((#:configure-flags flags) + `(cons ,(string-append "--host=" target) + ,(if (target-hurd? target) + `(append (list "--disable-werror" + ,@%glibc/hurd-configure-flags) + ,flags) + flags))) + ((#:phases phases) + `(modify-phases ,phases + (add-before 'configure 'set-cross-kernel-headers-path + (lambda* (#:key inputs #:allow-other-keys) + (let* ((kernel (assoc-ref inputs "kernel-headers")) + (cpath (string-append kernel "/include"))) + (for-each (cut setenv <> cpath) + ',%gcc-cross-include-paths) + (setenv "CROSS_LIBRARY_PATH" + (string-append kernel "/lib")) ; for Hurd's libihash + #t))) + ,@(if (target-hurd? target) + '((add-after 'install 'augment-libc.so + (lambda* (#:key outputs #:allow-other-keys) + (let* ((out (assoc-ref outputs "out"))) + (substitute* (string-append out "/lib/libc.so") + (("/[^ ]+/lib/libc.so.0.3") + (string-append out "/lib/libc.so.0.3" + " libmachuser.so libhurduser.so")))) + #t))) + '()))))) + + ;; Shadow the native "kernel-headers" because glibc's recipe expects the + ;; "kernel-headers" input to point to the right thing. + (propagated-inputs `(("kernel-headers" ,xheaders))) + + (native-inputs `(("cross-gcc" ,xgcc) + ("cross-binutils" ,xbinutils) + ,@(if (target-hurd? target) + `(("cross-mig" + ,(cross-mig target + #:xgcc xgcc + #:xbinutils xbinutils))) + '()) + ,@(package-inputs libc) ;FIXME: static-bash + ,@(package-native-inputs libc))))) + (else #f))) ;;; Concrete cross tool chains are instantiated like this: diff --git a/guix/build-system/gnu.scm b/guix/build-system/gnu.scm index c1aa187c42..1483f6baeb 100644 --- a/guix/build-system/gnu.scm +++ b/guix/build-system/gnu.scm @@ -460,10 +460,12 @@ (define standard-cross-packages `(("cross-gcc" ,(gcc target #:xbinutils (binutils target) #:libc libc)) - ("cross-libc" ,libc) + ,@(if libc + `(("cross-libc" ,libc)) + '()) ;; MinGW's libc doesn't have a "static" output. - ,@(if (member "static" (package-outputs libc)) + ,@(if (and libc (member "static" (package-outputs libc))) `(("cross-libc:static" ,libc "static")) '())))))))) -- 2.34.1 ------------=_1696519322-16012-1--