No warning when attempting to build unsupported system with --system

  • Done
  • quality assurance status badge
Details
2 participants
  • Ludovic Courtès
  • Maxim Cournoyer
Owner
unassigned
Submitted by
Maxim Cournoyer
Severity
normal
M
M
Maxim Cournoyer wrote on 13 Nov 2021 03:51
(name . bug-guix)(address . bug-guix@gnu.org)
87o86oix8e.fsf@gmail.com
Hello Guix,

I was surprised that:

Toggle snippet (3 lines)
guix build fpc --system=armhf-linux

would send me in a dead end without any word of caution, given that
armhf-linux is *not* listed in the supported-systems field.

We should at least warn near the beginning of the build, and remind of
that fact at the end of the build in case of failure.

Thanks,

Maxim
L
L
Ludovic Courtès wrote on 17 Feb 2022 16:44
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 51801@debbugs.gnu.org)
874k4xmrau.fsf@gnu.org
Hi!

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

Toggle quote (10 lines)
> I was surprised that:
>
> guix build fpc --system=armhf-linux
>
> would send me in a dead end without any word of caution, given that
> armhf-linux is *not* listed in the supported-systems field.
>
> We should at least warn near the beginning of the build, and remind of
> that fact at the end of the build in case of failure.

I came up with the patches below.

The first part forbids unsupported packages altogether in user-facing
commands: ‘guix install’, ‘guix shell’, etc. Until now, they’d just
start building things that were bound to fail.

The second part adds a mere warning for ‘guix build’ (it does not repeat
it at the end, though).

Thanks,
Ludo’.
From 1b02db917f6b24b7c41dc20e2833fff452d9b900 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Thu, 17 Feb 2022 16:04:15 +0100
Subject: [PATCH 1/3] packages: 'package-transitive-supported-systems' ignores
'%current-target-system'.

Previously 'package-transitive-supported-systems' would enter an
infinite loop over the cross-compilation tool chain if
%CURRENT-TARGET-SYSTEM was set.

* guix/packages.scm (package-transitive-supported-systems)[supported-systems-procedure]:
Pass explicit SYSTEM and TARGET parameters.
* tests/packages.scm ("supported-package? vs. %current-target-system"):
New test.
---
guix/packages.scm | 4 ++--
tests/packages.scm | 10 ++++++++++
2 files changed, 12 insertions(+), 2 deletions(-)

Toggle diff (45 lines)
diff --git a/guix/packages.scm b/guix/packages.scm
index 9d5b23eb8a..3f0262602d 100644
--- a/guix/packages.scm
+++ b/guix/packages.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2014, 2015, 2017, 2018, 2019 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2015 Eric Bavier <bavier@member.fsf.org>
;;; Copyright © 2016 Alex Kost <alezost@gmail.com>
@@ -1235,7 +1235,7 @@ (define supported-systems
(_
systems)))
(package-supported-systems package)
- (bag-direct-inputs (package->bag package))))))
+ (bag-direct-inputs (package->bag package system #f))))))
supported-systems)
diff --git a/tests/packages.scm b/tests/packages.scm
index 55b1c4064f..02bdba5f98 100644
--- a/tests/packages.scm
+++ b/tests/packages.scm
@@ -508,6 +508,16 @@ (define read-at
(and (supported-package? p "x86_64-linux")
(supported-package? p "armhf-linux"))))
+(test-assert "supported-package? vs. %current-target-system"
+ ;; The %CURRENT-TARGET-SYSTEM value should have no influence.
+ (parameterize ((%current-target-system "arm-linux-gnueabihf"))
+ (let ((p (dummy-package "foo"
+ (build-system gnu-build-system)
+ (supported-systems '("x86_64-linux" "armhf-linux")))))
+ (and (supported-package? p "x86_64-linux")
+ (not (supported-package? p "i686-linux"))
+ (supported-package? p "armhf-linux")))))
+
(test-skip (if (not %store) 8 0))
(test-assert "package-source-derivation, file"

base-commit: 6481dbda5100e9b0ff9c5221280d2c0cadd663b7
--
2.34.0
From d4368c8c307f61b5346df540aaf329b8495fe32c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ludovic=20Court=C3=A8s?= <ludo@gnu.org>
Date: Thu, 17 Feb 2022 16:23:42 +0100
Subject: [PATCH 3/3] guix build: Warn when attempting to build an unsupported
package.

Reported by Maxim Cournoyer <maxim.cournoyer@gmail.com>.

* guix/scripts/build.scm (options->derivations)[warn-if-unsupported]:
New procedure.
[compute-derivation]: Use it.
* tests/guix-build.sh: Add test.
---
guix/scripts/build.scm | 22 ++++++++++++++++++++--
tests/guix-build.sh | 12 +++++++++++-
2 files changed, 31 insertions(+), 3 deletions(-)

Toggle diff (72 lines)
diff --git a/guix/scripts/build.scm b/guix/scripts/build.scm
index 97e2f5a167..d9cdb6e5e0 100644
--- a/guix/scripts/build.scm
+++ b/guix/scripts/build.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019, 2020, 2021, 2021 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2012-2022 Ludovic Courtès <ludo@gnu.org>
;;; Copyright © 2013 Mark H Weaver <mhw@netris.org>
;;; Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
;;; Copyright © 2020 Ricardo Wurmus <rekado@elephly.net>
@@ -559,11 +559,29 @@ (define systems
(define things-to-build
(map transform (options->things-to-build opts)))
+ (define warn-if-unsupported
+ (let ((target (assoc-ref opts 'target)))
+ (if target
+ (lambda (package system)
+ ;; We cannot tell whether PACKAGE supports TARGET.
+ package)
+ (lambda (package system)
+ (match package
+ ((? package? package)
+ (unless (supported-package? package system)
+ (warning (package-location package)
+ (G_ "package ~a does not support ~a~%")
+ (package-full-name package) system))
+ package)
+ (x x))))))
+
(define (compute-derivation obj system)
;; Compute the derivation of OBJ for SYSTEM.
(match obj
((? package? p)
- (let ((p (or (and graft? (package-replacement p)) p)))
+ (let ((p (warn-if-unsupported
+ (or (and graft? (package-replacement p)) p)
+ system)))
(match src
(#f
(list (package->derivation store p system)))
diff --git a/tests/guix-build.sh b/tests/guix-build.sh
index 86e41e2927..9cbf8fe26d 100644
--- a/tests/guix-build.sh
+++ b/tests/guix-build.sh
@@ -1,5 +1,5 @@
# GNU Guix --- Functional package management for GNU
-# Copyright © 2012, 2013, 2014, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
+# Copyright © 2012-2014, 2016-2022 Ludovic Courtès <ludo@gnu.org>
# Copyright © 2020 Marius Bakke <mbakke@fastmail.com>
# Copyright © 2021 Chris Marusich <cmmarusich@gmail.com>
#
@@ -31,6 +31,16 @@ guix build --version
guix build -e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S
test "`guix build -e '(@ (gnu packages bootstrap) %bootstrap-glibc)' -S`" = ""
+# Warn when attempting to build an unsupported package.
+case "$(guix build intelmetool -s armhf-linux -v0 -n 2>&1)" in
+ *warning:*intelmetool*support*armhf*)
+ true
+ break;;
+ *)
+ false;
+ break;;
+esac
+
# Should pass.
guix build -e '(@@ (gnu packages bootstrap) %bootstrap-guile)' | \
grep -e '-guile-'
--
2.34.0
L
L
Ludovic Courtès wrote on 18 Feb 2022 14:18
(name . Maxim Cournoyer)(address . maxim.cournoyer@gmail.com)(address . 51801-done@debbugs.gnu.org)
87bkz4jotx.fsf@gnu.org
Ludovic Courtès <ludo@gnu.org> skribis:

Toggle quote (21 lines)
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> I was surprised that:
>>
>> guix build fpc --system=armhf-linux
>>
>> would send me in a dead end without any word of caution, given that
>> armhf-linux is *not* listed in the supported-systems field.
>>
>> We should at least warn near the beginning of the build, and remind of
>> that fact at the end of the build in case of failure.
>
> I came up with the patches below.
>
> The first part forbids unsupported packages altogether in user-facing
> commands: ‘guix install’, ‘guix shell’, etc. Until now, they’d just
> start building things that were bound to fail.
>
> The second part adds a mere warning for ‘guix build’ (it does not repeat
> it at the end, though).

I went ahead and pushed them:

0ca26437cb guix build: Warn when attempting to build an unsupported package.
5a57313918 profiles: 'profile-derivation' rejects unsupported packages.
0572737a62 packages: 'package-transitive-supported-systems' ignores '%current-target-system'.

Ludo’.
Closed
M
M
Maxim Cournoyer wrote on 20 Feb 2022 03:46
Re: bug#51801: closed (Re: bug#51801: No warning when attempting to build unsupported system with --system)
(address . 51801@debbugs.gnu.org)
874k4uqmq2.fsf@gmail.com
Hi Ludo,

Toggle quote (35 lines)
> From: Ludovic Courtès <ludo@gnu.org>
> Subject: Re: bug#51801: No warning when attempting to build unsupported system with --system
> To: Maxim Cournoyer <maxim.cournoyer@gmail.com>
> Cc: 51801-done@debbugs.gnu.org
> Date: Fri, 18 Feb 2022 14:18:02 +0100 (1 day, 13 hours, 27 minutes ago)
>
> Ludovic Courtès <ludo@gnu.org> skribis:
>
>> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>>
>>> I was surprised that:
>>>
>>> guix build fpc --system=armhf-linux
>>>
>>> would send me in a dead end without any word of caution, given that
>>> armhf-linux is *not* listed in the supported-systems field.
>>>
>>> We should at least warn near the beginning of the build, and remind of
>>> that fact at the end of the build in case of failure.
>>
>> I came up with the patches below.
>>
>> The first part forbids unsupported packages altogether in user-facing
>> commands: ‘guix install’, ‘guix shell’, etc. Until now, they’d just
>> start building things that were bound to fail.
>>
>> The second part adds a mere warning for ‘guix build’ (it does not repeat
>> it at the end, though).
>
> I went ahead and pushed them:
>
> 0ca26437cb guix build: Warn when attempting to build an unsupported package.
> 5a57313918 profiles: 'profile-derivation' rejects unsupported packages.
> 0572737a62 packages: 'package-transitive-supported-systems' ignores '%current-target-system'.

Thank you!

Maxim
?