unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Taylor R Campbell <campbell+guile@mumble.net>
To: 54915@debbugs.gnu.org
Subject: bug#54915: [PATCH] Guile rejects empty vendor in GNU triplets, as used by NetBSD
Date: Wed, 13 Apr 2022 11:26:44 +0000	[thread overview]
Message-ID: <20220413112644.6016B60859@jupiter.mumble.net> (raw)

[-- Attachment #1: Type: text/plain, Size: 1454 bytes --]

NetBSD uses an empty vendor string in a GNU target triplet, like
`x86_64--netbsd' or `armv7--netbsdelf-eabihf'; it's been like this
since the mid-'90s.  (Before that, NetBSD omitted the vendor
altogether, so if x86_64 existed then it might have been
`x86_64-netbsd'.)

This runs afoul of a rule in guile's validate-target in
module/system/base/target.scm that requires all components to be
nonempty, so pkgsrc's guile build has been carrying around a
workaround -- just for guile, not for any other packages I know of --
for ages.  Without the workaround in pkgsrc:

>   BOOTSTRAP(stage0) GUILEC ice-9/eval.go
> Backtrace:
>            7 (apply-smob/1 #<boot-closure 736f6474ff80 (_ _)> #<exc?> ?)
>            6 (apply-smob/1 #<boot-closure 736f2e2fbd80 ()>)
>            5 (apply-smob/0 #<thunk 736f2e2fbe40>)
>            4 (primitive-eval ((@ (ice-9 control) %) (begin (# #) ?)))
>            3 (apply-smob/1 #<boot-closure 736f63786a80 ()>)
>            2 (apply-smob/1 #<boot-closure 736f265a9500 ()>)
>            1 (scm-error misc-error #f "~A ~S" ("invalid target" "?") #)
>            0 (apply-smob/1 #<boot-closure 736f6474ff40 (_ . _)> # #f ?)
> 
> ERROR: In procedure apply-smob/1:
> invalid target "x86_64--netbsd"

The attached patch relaxes validate-target so it accepts an empty
vendor string (but still requires all other components to be nonempty
as before).  With the patch and without the workaround in pkgsrc,
guile builds happily.

[-- Attachment #2: emptyvendor.patch --]
[-- Type: text/plain, Size: 1761 bytes --]

From 12440a85559c3de5e6bced9c9377f3d5d7f5948e Mon Sep 17 00:00:00 2001
From: Taylor R Campbell <campbell+guile@mumble.net>
Date: Wed, 13 Apr 2022 09:51:08 +0000
Subject: [PATCH] Allow empty vendor string in GNU target triplets.

NetBSD and pkgsrc have been using an empty vendor string since the
mid-'90s, such as x86_64--netbsd.  pkgsrc has been carrying around a
workaround just the guile build for a long time.  (Before that,
NetBSD omitted the vendor altogether, so if x86_64 existed then it
might have been `x86_64-netbsd', but that caused more problems.)
This change makes Guile accept an empty vendor string so workarounds
are no longer necessary.

* module/system/base/target.scm (validate-target): Allow empty vendor
string in GNU target triplets.
---
 module/system/base/target.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/module/system/base/target.scm b/module/system/base/target.scm
index 74af64b9d..87ab5b0c4 100644
--- a/module/system/base/target.scm
+++ b/module/system/base/target.scm
@@ -53,7 +53,14 @@
   (if (or (not (string? target))
           (let ((parts (string-split target #\-)))
             (or (< (length parts) 3)
-                (or-map string-null? parts))))
+                (let ((cpu (list-ref parts 0))
+                      (os (list-ref parts 2)))
+                  (or (string-null? cpu)
+                      ;; vendor (parts[1]) may be empty
+                      (string-null? os)
+                      ;; optional components (ABI) should be nonempty if
+                      ;; specified
+                      (or-map string-null? (list-tail parts 3)))))))
       (error "invalid target" target)))
 
 (define (with-target target thunk)

             reply	other threads:[~2022-04-13 11:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-13 11:26 Taylor R Campbell [this message]
2022-06-16  7:43 ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220413112644.6016B60859@jupiter.mumble.net \
    --to=campbell+guile@mumble.net \
    --cc=54915@debbugs.gnu.org \
    --subject='Re: bug#54915: [PATCH] Guile rejects empty vendor in GNU triplets, as used by NetBSD' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).