all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24.
@ 2022-12-30 15:58 Simon South
  2022-12-30 16:00 ` [bug#60429] [PATCH 1/5] gnu: yosys: Update source and home-page URLs Simon South
                   ` (6 more replies)
  0 siblings, 7 replies; 20+ messages in thread
From: Simon South @ 2022-12-30 15:58 UTC (permalink / raw)
  To: 60429

Here's a patch series that aims to improve the package for Yosys, a tool for
synthesizing Verilog RTL designs, by

- Updating the source-repository and home-page URLs to their current location;

- Updating the package definition to the modern style, using gexps and
  search-input-file;

- Having Yosys use the "abc" executable from Guix's package rather than
  creating and installing a duplicate copy;

- Explicitly propagating packages with executables Yosys invokes at runtime
  rather than embedding store references in Yosys' code; and

- Updating Yosys to version 0.24.

I've tested building the package and its dependencies on x86-64 and AArch64
and everything seems okay[0].  Again, arachne-pnr fails to build in any case
and will need separate attention.

[0] Yosys' README.md file includes sample sessions useful for testing,
    particularly whether external tools can be invoked via the "show" and
    "abc" commands:

    https://github.com/YosysHQ/yosys/blob/3ebc50d/README.md#getting-started

    The files "fiedler-cooley.v" and "mycells.lib" are present in the source
    tree.

--
Simon South
simon@simonsouth.net


Simon South (5):
  gnu: yosys: Update source and home-page URLs.
  gnu: yosys: Use new package style.
  gnu: yosys: Use external abc.
  gnu: yosys: Propagate external dependencies.
  gnu: yosys: Update to 0.24.

 gnu/packages/fpga.scm | 120 ++++++++++++++++--------------------------
 1 file changed, 45 insertions(+), 75 deletions(-)


base-commit: 01762b7171f9afaf7ffa364f7926461bdebc903f
-- 
2.38.1





^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH 1/5] gnu: yosys: Update source and home-page URLs.
  2022-12-30 15:58 [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24 Simon South
@ 2022-12-30 16:00 ` Simon South
  2022-12-30 16:00 ` [bug#60429] [PATCH 2/5] gnu: yosys: Use new package style Simon South
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2022-12-30 16:00 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[source]: Update source-repository URL.
[home-page]: Update URL.
---
 gnu/packages/fpga.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index acce5f8f82..45aadf8ea4 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -141,7 +141,7 @@ (define-public yosys
     (source (origin
               (method git-fetch)
               (uri (git-reference
-                    (url "https://github.com/cliffordwolf/yosys")
+                    (url "https://github.com/YosysHQ/yosys")
                     (commit (string-append "yosys-" version))
                     (recursive? #t))) ; for the ‘iverilog’ submodule
               (sha256
@@ -223,7 +223,7 @@ (define-public yosys
            abc))
     (propagated-inputs
      (list z3)) ; should be in path for yosys-smtbmc
-    (home-page "http://www.clifford.at/yosys/")
+    (home-page "https://yosyshq.net/yosys/")
     (synopsis "FPGA Verilog RTL synthesizer")
     (description "Yosys synthesizes Verilog-2005.")
     (license license:isc)))
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH 2/5] gnu: yosys: Use new package style.
  2022-12-30 15:58 [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24 Simon South
  2022-12-30 16:00 ` [bug#60429] [PATCH 1/5] gnu: yosys: Update source and home-page URLs Simon South
@ 2022-12-30 16:00 ` Simon South
  2022-12-30 16:00 ` [bug#60429] [PATCH 3/5] gnu: yosys: Use external abc Simon South
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2022-12-30 16:00 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[source]: Use gexp in snippet and don't
explicitly return #t.
[arguments]: Use gexps; use search-input-file to locate executables; simplify
parameters to "configure" phase; don't explicitly return #t from phases.
[native-inputs]: Sort alphabetically.
[inputs]: Sort alphabetically.
---
 gnu/packages/fpga.scm | 122 +++++++++++++++++++++---------------------
 1 file changed, 60 insertions(+), 62 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 45aadf8ea4..479ca3b061 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -150,77 +150,75 @@ (define-public yosys
               (file-name (git-file-name name version))
               (modules '((guix build utils)))
               (snippet
-               '(begin
-                  (substitute* "Makefile"
-                    (("ABCREV = .*") "ABCREV = default\n"))
-                  #t))))
+               #~(begin
+                   (substitute* "Makefile"
+                     (("ABCREV = .*") "ABCREV = default\n"))))))
     (build-system gnu-build-system)
     (arguments
-     `(#:test-target "test"
-       #:make-flags (list "CC=gcc"
-                          "CXX=g++"
-                          (string-append "PREFIX=" %output))
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'fix-paths
-           (lambda _
-             (substitute* "./passes/cmds/show.cc"
-               (("exec xdot") (string-append "exec " (which "xdot")))
-               (("dot -") (string-append (which "dot") " -"))
-               (("fuser") (which "fuser")))
-             #t))
-         (replace 'configure
-           (lambda* (#:key inputs (make-flags '()) #:allow-other-keys)
-             (apply invoke "make" "config-gcc" make-flags)))
-         (add-after 'configure 'prepare-abc
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let* ((sourceabc (assoc-ref inputs "abc"))
-                    (sourcebin (string-append sourceabc "/bin"))
-                    (source (string-append sourcebin "/abc")))
-                   (mkdir-p "abc")
-                   (call-with-output-file "abc/Makefile"
-                     (lambda (port)
-                       (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
-                   (copy-file source "abc/abc")
-                   (invoke "chmod" "+w" "abc/abc"))))
+     (list
+      #:test-target "test"
+      #:make-flags #~(list "CC=gcc"
+                           "CXX=g++"
+                           (string-append "PREFIX=" #$output))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'configure 'fix-paths
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "./passes/cmds/show.cc"
+                (("exec xdot")
+                 (string-append "exec " (search-input-file inputs
+                                                           "/bin/xdot")))
+                (("dot -")
+                 (string-append (search-input-file inputs "/bin/dot") " -"))
+                (("fuser")
+                 (search-input-file inputs "/bin/fuser")))))
+          (replace 'configure
+            (lambda* (#:key make-flags #:allow-other-keys)
+              (apply invoke "make" "config-gcc" make-flags)))
+          (add-after 'configure 'prepare-abc
+            (lambda* (#:key inputs #:allow-other-keys)
+              (mkdir-p "abc")
+              (call-with-output-file "abc/Makefile"
+                (lambda (port)
+                  (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
+              (copy-file (search-input-file inputs "/bin/abc") "abc/abc")
+              (invoke "chmod" "+w" "abc/abc")))
           (add-before 'check 'fix-iverilog-references
-             (lambda* (#:key inputs native-inputs #:allow-other-keys)
-               (let* ((xinputs (or native-inputs inputs))
-                      (xdirname (assoc-ref xinputs "iverilog"))
-                      (iverilog (string-append xdirname "/bin/iverilog")))
-                     (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
-                                    "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
-                                    "./techlibs/ice40/tests/test_bram.sh"
-                                    "./techlibs/ice40/tests/test_ffs.sh"
-                                    "./techlibs/xilinx/tests/bram1.sh"
-                                    "./techlibs/xilinx/tests/bram2.sh"
-                                    "./tests/bram/run-single.sh"
-                                    "./tests/realmath/run-test.sh"
-                                    "./tests/simple/run-test.sh"
-                                    "./tests/techmap/mem_simple_4x1_runtest.sh"
-                                    "./tests/tools/autotest.sh"
-                                    "./tests/vloghtb/common.sh")
-                        (("if ! which iverilog") "if ! true")
-                        (("iverilog ") (string-append iverilog " "))
-                        (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
-                                                                iverilog "\"")))
-                     #t))))))
+            (lambda* (#:key inputs native-inputs #:allow-other-keys)
+              (let ((iverilog (search-input-file (or native-inputs inputs)
+                                                 "/bin/iverilog")))
+                (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
+                               "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
+                               "./techlibs/ice40/tests/test_bram.sh"
+                               "./techlibs/ice40/tests/test_ffs.sh"
+                               "./techlibs/xilinx/tests/bram1.sh"
+                               "./techlibs/xilinx/tests/bram2.sh"
+                               "./tests/bram/run-single.sh"
+                               "./tests/realmath/run-test.sh"
+                               "./tests/simple/run-test.sh"
+                               "./tests/techmap/mem_simple_4x1_runtest.sh"
+                               "./tests/tools/autotest.sh"
+                               "./tests/vloghtb/common.sh")
+                  (("if ! which iverilog") "if ! true")
+                  (("iverilog ") (string-append iverilog " "))
+                  (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
+                                                          iverilog "\"")))))))))
     (native-inputs
-     (list pkg-config
-           python
-           bison
+     (list bison
            flex
            gawk ; for the tests and "make" progress pretty-printing
-           tcl ; tclsh for the tests
-           iverilog)) ; for the tests
+           iverilog ; for the tests
+           pkg-config
+           python
+           tcl)) ; tclsh for the tests
     (inputs
-     (list tcl
-           readline
-           libffi
+     (list abc
            graphviz
+           libffi
            psmisc
-           xdot
-           abc))
+           readline
+           tcl
+           xdot))
     (propagated-inputs
      (list z3)) ; should be in path for yosys-smtbmc
     (home-page "https://yosyshq.net/yosys/")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH 3/5] gnu: yosys: Use external abc.
  2022-12-30 15:58 [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24 Simon South
  2022-12-30 16:00 ` [bug#60429] [PATCH 1/5] gnu: yosys: Update source and home-page URLs Simon South
  2022-12-30 16:00 ` [bug#60429] [PATCH 2/5] gnu: yosys: Use new package style Simon South
@ 2022-12-30 16:00 ` Simon South
  2022-12-30 16:00 ` [bug#60429] [PATCH 4/5] gnu: yosys: Propagate external dependencies Simon South
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2022-12-30 16:00 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[source]: Remove snippet and associated
"modules" field.
[arguments]: Replace "prepare-abc" phase with "use-external-abc", which
configures the package's build system to use the system's "abc" executable
instead of creating a duplicate; add "add-symbolic-link" phase to preserve
availability of "yosys-abc" command.
[inputs]: Move abc from here...
[propagated-inputs]: ...to here, to ensure its availability at runtime.
---
 gnu/packages/fpga.scm | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 479ca3b061..8effebd921 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -147,12 +147,7 @@ (define-public yosys
               (sha256
                 (base32
                    "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
-              (file-name (git-file-name name version))
-              (modules '((guix build utils)))
-              (snippet
-               #~(begin
-                   (substitute* "Makefile"
-                     (("ABCREV = .*") "ABCREV = default\n"))))))
+              (file-name (git-file-name name version))))
     (build-system gnu-build-system)
     (arguments
      (list
@@ -175,14 +170,10 @@ (define-public yosys
           (replace 'configure
             (lambda* (#:key make-flags #:allow-other-keys)
               (apply invoke "make" "config-gcc" make-flags)))
-          (add-after 'configure 'prepare-abc
-            (lambda* (#:key inputs #:allow-other-keys)
-              (mkdir-p "abc")
-              (call-with-output-file "abc/Makefile"
-                (lambda (port)
-                  (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
-              (copy-file (search-input-file inputs "/bin/abc") "abc/abc")
-              (invoke "chmod" "+w" "abc/abc")))
+          (add-after 'configure 'use-external-abc
+            (lambda _
+              (substitute* '("./Makefile")
+                (("ABCEXTERNAL \\?=") "ABCEXTERNAL = abc"))))
           (add-before 'check 'fix-iverilog-references
             (lambda* (#:key inputs native-inputs #:allow-other-keys)
               (let ((iverilog (search-input-file (or native-inputs inputs)
@@ -202,7 +193,15 @@ (define-public yosys
                   (("if ! which iverilog") "if ! true")
                   (("iverilog ") (string-append iverilog " "))
                   (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
-                                                          iverilog "\"")))))))))
+                                                          iverilog "\""))))))
+          (add-after 'install 'add-symbolic-link
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; Previously this package provided a copy of the "abc"
+              ;; executable in its output, named "yosys-abc".  Create a
+              ;; symbolic link so any external uses of that name continue to
+              ;; work.
+              (symlink (search-input-file inputs "/bin/abc")
+                       (string-append #$output "/bin/yosys-abc")))))))
     (native-inputs
      (list bison
            flex
@@ -212,15 +211,15 @@ (define-public yosys
            python
            tcl)) ; tclsh for the tests
     (inputs
-     (list abc
-           graphviz
+     (list graphviz
            libffi
            psmisc
            readline
            tcl
            xdot))
     (propagated-inputs
-     (list z3)) ; should be in path for yosys-smtbmc
+     (list abc
+           z3)) ; should be in path for yosys-smtbmc
     (home-page "https://yosyshq.net/yosys/")
     (synopsis "FPGA Verilog RTL synthesizer")
     (description "Yosys synthesizes Verilog-2005.")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH 4/5] gnu: yosys: Propagate external dependencies.
  2022-12-30 15:58 [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24 Simon South
                   ` (2 preceding siblings ...)
  2022-12-30 16:00 ` [bug#60429] [PATCH 3/5] gnu: yosys: Use external abc Simon South
@ 2022-12-30 16:00 ` Simon South
  2022-12-30 16:00 ` [bug#60429] [PATCH 5/5] gnu: yosys: Update to 0.24 Simon South
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2022-12-30 16:00 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[inputs]: Move graphviz, psmisc, xdot from
here...
[propagated-inputs]: ...to here, to ensure the availability at runtime of
executables invoked by yosys' "show" command.
[arguments]: Remove now-obsolete "fix-paths" phase.
---
 gnu/packages/fpga.scm | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 8effebd921..785d385621 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -157,16 +157,6 @@ (define-public yosys
                            (string-append "PREFIX=" #$output))
       #:phases
       #~(modify-phases %standard-phases
-          (add-before 'configure 'fix-paths
-            (lambda* (#:key inputs #:allow-other-keys)
-              (substitute* "./passes/cmds/show.cc"
-                (("exec xdot")
-                 (string-append "exec " (search-input-file inputs
-                                                           "/bin/xdot")))
-                (("dot -")
-                 (string-append (search-input-file inputs "/bin/dot") " -"))
-                (("fuser")
-                 (search-input-file inputs "/bin/fuser")))))
           (replace 'configure
             (lambda* (#:key make-flags #:allow-other-keys)
               (apply invoke "make" "config-gcc" make-flags)))
@@ -211,14 +201,14 @@ (define-public yosys
            python
            tcl)) ; tclsh for the tests
     (inputs
-     (list graphviz
-           libffi
-           psmisc
+     (list libffi
            readline
-           tcl
-           xdot))
+           tcl))
     (propagated-inputs
      (list abc
+           graphviz ; for dot
+           psmisc ; for fuser
+           xdot
            z3)) ; should be in path for yosys-smtbmc
     (home-page "https://yosyshq.net/yosys/")
     (synopsis "FPGA Verilog RTL synthesizer")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH 5/5] gnu: yosys: Update to 0.24.
  2022-12-30 15:58 [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24 Simon South
                   ` (3 preceding siblings ...)
  2022-12-30 16:00 ` [bug#60429] [PATCH 4/5] gnu: yosys: Propagate external dependencies Simon South
@ 2022-12-30 16:00 ` Simon South
  2023-01-08 18:31 ` [bug#60429] [PATCH v2 0/5] " Simon South
  2023-02-10 13:16 ` [bug#60429] [PATCH v3 0/5] gnu: yosys: Update to 0.24 Simon South
  6 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2022-12-30 16:00 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys): Update to 0.24.
[arguments]: Remove obsolete "fix-iverilog-references" phase.
[inputs]: Add zlib.
[propagated-inputs]: Add gtkwave, python, python-click.
---
 gnu/packages/fpga.scm | 35 +++++++++--------------------------
 1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 785d385621..d3532069e8 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -137,16 +137,15 @@ (define-public iverilog
 (define-public yosys
   (package
     (name "yosys")
-    (version "0.9")
+    (version "0.24")
     (source (origin
               (method git-fetch)
               (uri (git-reference
                     (url "https://github.com/YosysHQ/yosys")
-                    (commit (string-append "yosys-" version))
-                    (recursive? #t))) ; for the ‘iverilog’ submodule
+                    (commit (string-append "yosys-" version))))
               (sha256
-                (base32
-                   "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
+               (base32
+                "1hrlqq9850j0160z9ibcia8fp0xxn0iakh0yb69kjzb6ffgjjn3d"))
               (file-name (git-file-name name version))))
     (build-system gnu-build-system)
     (arguments
@@ -164,26 +163,6 @@ (define-public yosys
             (lambda _
               (substitute* '("./Makefile")
                 (("ABCEXTERNAL \\?=") "ABCEXTERNAL = abc"))))
-          (add-before 'check 'fix-iverilog-references
-            (lambda* (#:key inputs native-inputs #:allow-other-keys)
-              (let ((iverilog (search-input-file (or native-inputs inputs)
-                                                 "/bin/iverilog")))
-                (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
-                               "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
-                               "./techlibs/ice40/tests/test_bram.sh"
-                               "./techlibs/ice40/tests/test_ffs.sh"
-                               "./techlibs/xilinx/tests/bram1.sh"
-                               "./techlibs/xilinx/tests/bram2.sh"
-                               "./tests/bram/run-single.sh"
-                               "./tests/realmath/run-test.sh"
-                               "./tests/simple/run-test.sh"
-                               "./tests/techmap/mem_simple_4x1_runtest.sh"
-                               "./tests/tools/autotest.sh"
-                               "./tests/vloghtb/common.sh")
-                  (("if ! which iverilog") "if ! true")
-                  (("iverilog ") (string-append iverilog " "))
-                  (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
-                                                          iverilog "\""))))))
           (add-after 'install 'add-symbolic-link
             (lambda* (#:key inputs #:allow-other-keys)
               ;; Previously this package provided a copy of the "abc"
@@ -203,11 +182,15 @@ (define-public yosys
     (inputs
      (list libffi
            readline
-           tcl))
+           tcl
+           zlib))
     (propagated-inputs
      (list abc
            graphviz ; for dot
+           gtkwave ; for vcd2fst
            psmisc ; for fuser
+           python
+           python-click
            xdot
            z3)) ; should be in path for yosys-smtbmc
     (home-page "https://yosyshq.net/yosys/")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 0/5] gnu: yosys: Update to 0.24.
  2022-12-30 15:58 [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24 Simon South
                   ` (4 preceding siblings ...)
  2022-12-30 16:00 ` [bug#60429] [PATCH 5/5] gnu: yosys: Update to 0.24 Simon South
@ 2023-01-08 18:31 ` Simon South
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 1/5] gnu: yosys: Update source and home-page URLs Simon South
                     ` (4 more replies)
  2023-02-10 13:16 ` [bug#60429] [PATCH v3 0/5] gnu: yosys: Update to 0.24 Simon South
  6 siblings, 5 replies; 20+ messages in thread
From: Simon South @ 2023-01-08 18:31 UTC (permalink / raw)
  To: 60429

Here's a revised patchset with a modified final patch that updates yosys to
version 0.25, released in the past week, instead of 0.24.  Everything else
remains unchanged.

I've re-tested this on x86-64 and AArch64 and everything appears fine.

Here's the original cover letter:

Here's a patch series that aims to improve the package for Yosys, a tool for
synthesizing Verilog RTL designs, by

- Updating the source-repository and home-page URLs to their current location;

- Updating the package definition to the modern style, using gexps and
  search-input-file;

- Having Yosys use the "abc" executable from Guix's package rather than
  creating and installing a duplicate copy;

- Explicitly propagating packages with executables Yosys invokes at runtime
  rather than embedding store references in Yosys' code; and

- Updating Yosys to version 0.24.

I've tested building the package and its dependencies on x86-64 and AArch64
and everything seems okay[0].  Again, arachne-pnr fails to build in any case
and will need separate attention.

[0] Yosys' README.md file includes sample sessions useful for testing,
    particularly whether external tools can be invoked via the "show" and
    "abc" commands:

    https://github.com/YosysHQ/yosys/blob/3ebc50d/README.md#getting-started

    The files "fiedler-cooley.v" and "mycells.lib" are present in the source
    tree.

--
Simon South
simon@simonsouth.net


Simon South (5):
  gnu: yosys: Update source and home-page URLs.
  gnu: yosys: Use new package style.
  gnu: yosys: Use external abc.
  gnu: yosys: Propagate external dependencies.
  gnu: yosys: Update to 0.25.

 gnu/packages/fpga.scm | 120 ++++++++++++++++--------------------------
 1 file changed, 45 insertions(+), 75 deletions(-)


base-commit: f5ea392b9cd3851ed7517876a8cd4beb13893c9c
-- 
2.38.1





^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 1/5] gnu: yosys: Update source and home-page URLs.
  2023-01-08 18:31 ` [bug#60429] [PATCH v2 0/5] " Simon South
@ 2023-01-08 18:31   ` Simon South
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 2/5] gnu: yosys: Use new package style Simon South
                     ` (3 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2023-01-08 18:31 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[source]: Update source-repository URL.
[home-page]: Update URL.
---
 gnu/packages/fpga.scm | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index acce5f8f82..45aadf8ea4 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -141,7 +141,7 @@ (define-public yosys
     (source (origin
               (method git-fetch)
               (uri (git-reference
-                    (url "https://github.com/cliffordwolf/yosys")
+                    (url "https://github.com/YosysHQ/yosys")
                     (commit (string-append "yosys-" version))
                     (recursive? #t))) ; for the ‘iverilog’ submodule
               (sha256
@@ -223,7 +223,7 @@ (define-public yosys
            abc))
     (propagated-inputs
      (list z3)) ; should be in path for yosys-smtbmc
-    (home-page "http://www.clifford.at/yosys/")
+    (home-page "https://yosyshq.net/yosys/")
     (synopsis "FPGA Verilog RTL synthesizer")
     (description "Yosys synthesizes Verilog-2005.")
     (license license:isc)))
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 2/5] gnu: yosys: Use new package style.
  2023-01-08 18:31 ` [bug#60429] [PATCH v2 0/5] " Simon South
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 1/5] gnu: yosys: Update source and home-page URLs Simon South
@ 2023-01-08 18:31   ` Simon South
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 3/5] gnu: yosys: Use external abc Simon South
                     ` (2 subsequent siblings)
  4 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2023-01-08 18:31 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[source]: Use gexp in snippet and don't
explicitly return #t.
[arguments]: Use gexps; use search-input-file to locate executables; simplify
parameters to "configure" phase; don't explicitly return #t from phases.
[native-inputs]: Sort alphabetically.
[inputs]: Sort alphabetically.
---
 gnu/packages/fpga.scm | 122 +++++++++++++++++++++---------------------
 1 file changed, 60 insertions(+), 62 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 45aadf8ea4..479ca3b061 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -150,77 +150,75 @@ (define-public yosys
               (file-name (git-file-name name version))
               (modules '((guix build utils)))
               (snippet
-               '(begin
-                  (substitute* "Makefile"
-                    (("ABCREV = .*") "ABCREV = default\n"))
-                  #t))))
+               #~(begin
+                   (substitute* "Makefile"
+                     (("ABCREV = .*") "ABCREV = default\n"))))))
     (build-system gnu-build-system)
     (arguments
-     `(#:test-target "test"
-       #:make-flags (list "CC=gcc"
-                          "CXX=g++"
-                          (string-append "PREFIX=" %output))
-       #:phases
-       (modify-phases %standard-phases
-         (add-before 'configure 'fix-paths
-           (lambda _
-             (substitute* "./passes/cmds/show.cc"
-               (("exec xdot") (string-append "exec " (which "xdot")))
-               (("dot -") (string-append (which "dot") " -"))
-               (("fuser") (which "fuser")))
-             #t))
-         (replace 'configure
-           (lambda* (#:key inputs (make-flags '()) #:allow-other-keys)
-             (apply invoke "make" "config-gcc" make-flags)))
-         (add-after 'configure 'prepare-abc
-           (lambda* (#:key inputs #:allow-other-keys)
-             (let* ((sourceabc (assoc-ref inputs "abc"))
-                    (sourcebin (string-append sourceabc "/bin"))
-                    (source (string-append sourcebin "/abc")))
-                   (mkdir-p "abc")
-                   (call-with-output-file "abc/Makefile"
-                     (lambda (port)
-                       (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
-                   (copy-file source "abc/abc")
-                   (invoke "chmod" "+w" "abc/abc"))))
+     (list
+      #:test-target "test"
+      #:make-flags #~(list "CC=gcc"
+                           "CXX=g++"
+                           (string-append "PREFIX=" #$output))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'configure 'fix-paths
+            (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "./passes/cmds/show.cc"
+                (("exec xdot")
+                 (string-append "exec " (search-input-file inputs
+                                                           "/bin/xdot")))
+                (("dot -")
+                 (string-append (search-input-file inputs "/bin/dot") " -"))
+                (("fuser")
+                 (search-input-file inputs "/bin/fuser")))))
+          (replace 'configure
+            (lambda* (#:key make-flags #:allow-other-keys)
+              (apply invoke "make" "config-gcc" make-flags)))
+          (add-after 'configure 'prepare-abc
+            (lambda* (#:key inputs #:allow-other-keys)
+              (mkdir-p "abc")
+              (call-with-output-file "abc/Makefile"
+                (lambda (port)
+                  (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
+              (copy-file (search-input-file inputs "/bin/abc") "abc/abc")
+              (invoke "chmod" "+w" "abc/abc")))
           (add-before 'check 'fix-iverilog-references
-             (lambda* (#:key inputs native-inputs #:allow-other-keys)
-               (let* ((xinputs (or native-inputs inputs))
-                      (xdirname (assoc-ref xinputs "iverilog"))
-                      (iverilog (string-append xdirname "/bin/iverilog")))
-                     (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
-                                    "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
-                                    "./techlibs/ice40/tests/test_bram.sh"
-                                    "./techlibs/ice40/tests/test_ffs.sh"
-                                    "./techlibs/xilinx/tests/bram1.sh"
-                                    "./techlibs/xilinx/tests/bram2.sh"
-                                    "./tests/bram/run-single.sh"
-                                    "./tests/realmath/run-test.sh"
-                                    "./tests/simple/run-test.sh"
-                                    "./tests/techmap/mem_simple_4x1_runtest.sh"
-                                    "./tests/tools/autotest.sh"
-                                    "./tests/vloghtb/common.sh")
-                        (("if ! which iverilog") "if ! true")
-                        (("iverilog ") (string-append iverilog " "))
-                        (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
-                                                                iverilog "\"")))
-                     #t))))))
+            (lambda* (#:key inputs native-inputs #:allow-other-keys)
+              (let ((iverilog (search-input-file (or native-inputs inputs)
+                                                 "/bin/iverilog")))
+                (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
+                               "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
+                               "./techlibs/ice40/tests/test_bram.sh"
+                               "./techlibs/ice40/tests/test_ffs.sh"
+                               "./techlibs/xilinx/tests/bram1.sh"
+                               "./techlibs/xilinx/tests/bram2.sh"
+                               "./tests/bram/run-single.sh"
+                               "./tests/realmath/run-test.sh"
+                               "./tests/simple/run-test.sh"
+                               "./tests/techmap/mem_simple_4x1_runtest.sh"
+                               "./tests/tools/autotest.sh"
+                               "./tests/vloghtb/common.sh")
+                  (("if ! which iverilog") "if ! true")
+                  (("iverilog ") (string-append iverilog " "))
+                  (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
+                                                          iverilog "\"")))))))))
     (native-inputs
-     (list pkg-config
-           python
-           bison
+     (list bison
            flex
            gawk ; for the tests and "make" progress pretty-printing
-           tcl ; tclsh for the tests
-           iverilog)) ; for the tests
+           iverilog ; for the tests
+           pkg-config
+           python
+           tcl)) ; tclsh for the tests
     (inputs
-     (list tcl
-           readline
-           libffi
+     (list abc
            graphviz
+           libffi
            psmisc
-           xdot
-           abc))
+           readline
+           tcl
+           xdot))
     (propagated-inputs
      (list z3)) ; should be in path for yosys-smtbmc
     (home-page "https://yosyshq.net/yosys/")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 3/5] gnu: yosys: Use external abc.
  2023-01-08 18:31 ` [bug#60429] [PATCH v2 0/5] " Simon South
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 1/5] gnu: yosys: Update source and home-page URLs Simon South
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 2/5] gnu: yosys: Use new package style Simon South
@ 2023-01-08 18:31   ` Simon South
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies Simon South
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 5/5] gnu: yosys: Update to 0.25 Simon South
  4 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2023-01-08 18:31 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[source]: Remove snippet and associated
"modules" field.
[arguments]: Replace "prepare-abc" phase with "use-external-abc", which
configures the package's build system to use the system's "abc" executable
instead of creating a duplicate; add "add-symbolic-link" phase to preserve
availability of "yosys-abc" command.
[inputs]: Move abc from here...
[propagated-inputs]: ...to here, to ensure its availability at runtime.
---
 gnu/packages/fpga.scm | 35 +++++++++++++++++------------------
 1 file changed, 17 insertions(+), 18 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 479ca3b061..8effebd921 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -147,12 +147,7 @@ (define-public yosys
               (sha256
                 (base32
                    "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
-              (file-name (git-file-name name version))
-              (modules '((guix build utils)))
-              (snippet
-               #~(begin
-                   (substitute* "Makefile"
-                     (("ABCREV = .*") "ABCREV = default\n"))))))
+              (file-name (git-file-name name version))))
     (build-system gnu-build-system)
     (arguments
      (list
@@ -175,14 +170,10 @@ (define-public yosys
           (replace 'configure
             (lambda* (#:key make-flags #:allow-other-keys)
               (apply invoke "make" "config-gcc" make-flags)))
-          (add-after 'configure 'prepare-abc
-            (lambda* (#:key inputs #:allow-other-keys)
-              (mkdir-p "abc")
-              (call-with-output-file "abc/Makefile"
-                (lambda (port)
-                  (format port ".PHONY: all\nall:\n\tcp -f abc abc-default\n")))
-              (copy-file (search-input-file inputs "/bin/abc") "abc/abc")
-              (invoke "chmod" "+w" "abc/abc")))
+          (add-after 'configure 'use-external-abc
+            (lambda _
+              (substitute* '("./Makefile")
+                (("ABCEXTERNAL \\?=") "ABCEXTERNAL = abc"))))
           (add-before 'check 'fix-iverilog-references
             (lambda* (#:key inputs native-inputs #:allow-other-keys)
               (let ((iverilog (search-input-file (or native-inputs inputs)
@@ -202,7 +193,15 @@ (define-public yosys
                   (("if ! which iverilog") "if ! true")
                   (("iverilog ") (string-append iverilog " "))
                   (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
-                                                          iverilog "\"")))))))))
+                                                          iverilog "\""))))))
+          (add-after 'install 'add-symbolic-link
+            (lambda* (#:key inputs #:allow-other-keys)
+              ;; Previously this package provided a copy of the "abc"
+              ;; executable in its output, named "yosys-abc".  Create a
+              ;; symbolic link so any external uses of that name continue to
+              ;; work.
+              (symlink (search-input-file inputs "/bin/abc")
+                       (string-append #$output "/bin/yosys-abc")))))))
     (native-inputs
      (list bison
            flex
@@ -212,15 +211,15 @@ (define-public yosys
            python
            tcl)) ; tclsh for the tests
     (inputs
-     (list abc
-           graphviz
+     (list graphviz
            libffi
            psmisc
            readline
            tcl
            xdot))
     (propagated-inputs
-     (list z3)) ; should be in path for yosys-smtbmc
+     (list abc
+           z3)) ; should be in path for yosys-smtbmc
     (home-page "https://yosyshq.net/yosys/")
     (synopsis "FPGA Verilog RTL synthesizer")
     (description "Yosys synthesizes Verilog-2005.")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies.
  2023-01-08 18:31 ` [bug#60429] [PATCH v2 0/5] " Simon South
                     ` (2 preceding siblings ...)
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 3/5] gnu: yosys: Use external abc Simon South
@ 2023-01-08 18:31   ` Simon South
  2023-02-08 17:14     ` Christopher Baines
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 5/5] gnu: yosys: Update to 0.25 Simon South
  4 siblings, 1 reply; 20+ messages in thread
From: Simon South @ 2023-01-08 18:31 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[inputs]: Move graphviz, psmisc, xdot from
here...
[propagated-inputs]: ...to here, to ensure the availability at runtime of
executables invoked by yosys' "show" command.
[arguments]: Remove now-obsolete "fix-paths" phase.
---
 gnu/packages/fpga.scm | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 8effebd921..785d385621 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -157,16 +157,6 @@ (define-public yosys
                            (string-append "PREFIX=" #$output))
       #:phases
       #~(modify-phases %standard-phases
-          (add-before 'configure 'fix-paths
-            (lambda* (#:key inputs #:allow-other-keys)
-              (substitute* "./passes/cmds/show.cc"
-                (("exec xdot")
-                 (string-append "exec " (search-input-file inputs
-                                                           "/bin/xdot")))
-                (("dot -")
-                 (string-append (search-input-file inputs "/bin/dot") " -"))
-                (("fuser")
-                 (search-input-file inputs "/bin/fuser")))))
           (replace 'configure
             (lambda* (#:key make-flags #:allow-other-keys)
               (apply invoke "make" "config-gcc" make-flags)))
@@ -211,14 +201,14 @@ (define-public yosys
            python
            tcl)) ; tclsh for the tests
     (inputs
-     (list graphviz
-           libffi
-           psmisc
+     (list libffi
            readline
-           tcl
-           xdot))
+           tcl))
     (propagated-inputs
      (list abc
+           graphviz ; for dot
+           psmisc ; for fuser
+           xdot
            z3)) ; should be in path for yosys-smtbmc
     (home-page "https://yosyshq.net/yosys/")
     (synopsis "FPGA Verilog RTL synthesizer")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 5/5] gnu: yosys: Update to 0.25.
  2023-01-08 18:31 ` [bug#60429] [PATCH v2 0/5] " Simon South
                     ` (3 preceding siblings ...)
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies Simon South
@ 2023-01-08 18:31   ` Simon South
  4 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2023-01-08 18:31 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys): Update to 0.25.
[arguments]: Remove obsolete "fix-iverilog-references" phase.
[inputs]: Add zlib.
[propagated-inputs]: Add gtkwave, python, python-click.
---
 gnu/packages/fpga.scm | 35 +++++++++--------------------------
 1 file changed, 9 insertions(+), 26 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 785d385621..45cf0e74cf 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -137,16 +137,15 @@ (define-public iverilog
 (define-public yosys
   (package
     (name "yosys")
-    (version "0.9")
+    (version "0.25")
     (source (origin
               (method git-fetch)
               (uri (git-reference
                     (url "https://github.com/YosysHQ/yosys")
-                    (commit (string-append "yosys-" version))
-                    (recursive? #t))) ; for the ‘iverilog’ submodule
+                    (commit (string-append "yosys-" version))))
               (sha256
-                (base32
-                   "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
+               (base32
+                "1j5slm7m02q6n0yv6f3ihv2rgrc4krzcdz6g8v6jmj0gwgh9xi5h"))
               (file-name (git-file-name name version))))
     (build-system gnu-build-system)
     (arguments
@@ -164,26 +163,6 @@ (define-public yosys
             (lambda _
               (substitute* '("./Makefile")
                 (("ABCEXTERNAL \\?=") "ABCEXTERNAL = abc"))))
-          (add-before 'check 'fix-iverilog-references
-            (lambda* (#:key inputs native-inputs #:allow-other-keys)
-              (let ((iverilog (search-input-file (or native-inputs inputs)
-                                                 "/bin/iverilog")))
-                (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
-                               "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
-                               "./techlibs/ice40/tests/test_bram.sh"
-                               "./techlibs/ice40/tests/test_ffs.sh"
-                               "./techlibs/xilinx/tests/bram1.sh"
-                               "./techlibs/xilinx/tests/bram2.sh"
-                               "./tests/bram/run-single.sh"
-                               "./tests/realmath/run-test.sh"
-                               "./tests/simple/run-test.sh"
-                               "./tests/techmap/mem_simple_4x1_runtest.sh"
-                               "./tests/tools/autotest.sh"
-                               "./tests/vloghtb/common.sh")
-                  (("if ! which iverilog") "if ! true")
-                  (("iverilog ") (string-append iverilog " "))
-                  (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
-                                                          iverilog "\""))))))
           (add-after 'install 'add-symbolic-link
             (lambda* (#:key inputs #:allow-other-keys)
               ;; Previously this package provided a copy of the "abc"
@@ -203,11 +182,15 @@ (define-public yosys
     (inputs
      (list libffi
            readline
-           tcl))
+           tcl
+           zlib))
     (propagated-inputs
      (list abc
            graphviz ; for dot
+           gtkwave ; for vcd2fst
            psmisc ; for fuser
+           python
+           python-click
            xdot
            z3)) ; should be in path for yosys-smtbmc
     (home-page "https://yosyshq.net/yosys/")
-- 
2.38.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies.
  2023-01-08 18:31   ` [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies Simon South
@ 2023-02-08 17:14     ` Christopher Baines
  2023-02-09  0:35       ` Simon South
  0 siblings, 1 reply; 20+ messages in thread
From: Christopher Baines @ 2023-02-08 17:14 UTC (permalink / raw)
  To: Simon South; +Cc: 60429

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


Simon South <simon@simonsouth.net> writes:

> * gnu/packages/fpga.scm (yosys)[inputs]: Move graphviz, psmisc, xdot from
> here...
> [propagated-inputs]: ...to here, to ensure the availability at runtime of
> executables invoked by yosys' "show" command.
> [arguments]: Remove now-obsolete "fix-paths" phase.
> ---
>  gnu/packages/fpga.scm | 20 +++++---------------
>  1 file changed, 5 insertions(+), 15 deletions(-)
>
> diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
> index 8effebd921..785d385621 100644
> --- a/gnu/packages/fpga.scm
> +++ b/gnu/packages/fpga.scm
> @@ -157,16 +157,6 @@ (define-public yosys
>                             (string-append "PREFIX=" #$output))
>        #:phases
>        #~(modify-phases %standard-phases
> -          (add-before 'configure 'fix-paths
> -            (lambda* (#:key inputs #:allow-other-keys)
> -              (substitute* "./passes/cmds/show.cc"
> -                (("exec xdot")
> -                 (string-append "exec " (search-input-file inputs
> -                                                           "/bin/xdot")))
> -                (("dot -")
> -                 (string-append (search-input-file inputs "/bin/dot") " -"))
> -                (("fuser")
> -                 (search-input-file inputs "/bin/fuser")))))
>            (replace 'configure
>              (lambda* (#:key make-flags #:allow-other-keys)
>                (apply invoke "make" "config-gcc" make-flags)))
> @@ -211,14 +201,14 @@ (define-public yosys
>             python
>             tcl)) ; tclsh for the tests
>      (inputs
> -     (list graphviz
> -           libffi
> -           psmisc
> +     (list libffi
>             readline
> -           tcl
> -           xdot))
> +           tcl))
>      (propagated-inputs
>       (list abc
> +           graphviz ; for dot
> +           psmisc ; for fuser
> +           xdot
>             z3)) ; should be in path for yosys-smtbmc
>      (home-page "https://yosyshq.net/yosys/")
>      (synopsis "FPGA Verilog RTL synthesizer")

Thanks Simon, I've pushed the first 3 patches from this series to the
master branch now.

For the changes regarding propagated-inputs though, I'm not sure this it
the right direction. Firstly, I think it's possible (and maybe
desirable) to keep the 'fix-paths phase, even if the inputs are changed
to be propagated.

I know you say this is related to yosys show in the commit message, can
you elaborate on why these packages are necessary to have in the users
environment?

Thanks,

Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies.
  2023-02-08 17:14     ` Christopher Baines
@ 2023-02-09  0:35       ` Simon South
  2023-02-09  5:29         ` Liliana Marie Prikler
  0 siblings, 1 reply; 20+ messages in thread
From: Simon South @ 2023-02-09  0:35 UTC (permalink / raw)
  To: Christopher Baines; +Cc: 60429

Christopher Baines <mail@cbaines.net> writes:
> Thanks Simon, I've pushed the first 3 patches from this series to the
> master branch now.

Nice, thank you.

> I know you say this is related to yosys show in the commit message,
> can you elaborate on why these packages are necessary to have in the
> users environment?

Yosys' "show" command produces its output by building and executing a
shell command that invokes "dot" or "xdot" on the user's data.  The
implementation is in passes/cmds/show.cc[0]; the code for invoking dot
for instance looks like

    #define DOT_CMD "dot -T%s '%s' > '%s.new' && mv '%s.new' '%s'"
    (...)
    std::string cmd = stringf(DOT_CMD, format.c_str(), dot_file.c_str(), out_file.c_str(), out_file.c_str(), out_file.c_str());
    log("Exec: %s\n", cmd.c_str());
    if (run_command(cmd) != 0)
        log_cmd_error("Shell command failed!\n");

Obviously this works only if "dot" is in the user's PATH (as Yosys
blindly assumes), so the graphviz package must be installed as well or
the "show" command will be broken.  Similarly for the "fuser" and "xdot"
executables, which by default are invoked to provide graphical output
(though their use can be overridden by a setting at runtime).

I find this business of generating shell commands a bit ugly but at
least it creates only a loose coupling between the executables: The
shell is free to select a suitable "dot" to run, so the user can
substitute their own as easily as changing their PATH.

In constrast, the existing 'fix-paths phase tightens this coupling
considerably, as it embeds in the DOT_CMD string above the full path to
a specific "dot" executable in the store.  This ties the two executables
together completely, making it very difficult to change which "dot" is
used by Yosys without rebuilding the package.

I see no advantage to coupling the executables together tightly this
way, and in fact it seems counter to what is implied by the code above.
(Note also the "ABCEXTERNAL" build variable adjusted in a previous patch
is provided specifically to allow users to swap in their own version of
abc, which a different Yosys command invokes.)  I'd rather we propagate
the packages needed to ensure Yosys works as expected out-of-the-box,
then leave the user free to override its behaviour as they see fit.

-- 
Simon South
simon@simonsouth.net

[0] https://github.com/YosysHQ/yosys/blob/1979e0b1f2482dbf0562f5116ab444280a377773/passes/cmds/show.cc




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies.
  2023-02-09  0:35       ` Simon South
@ 2023-02-09  5:29         ` Liliana Marie Prikler
  2023-02-09 16:47           ` Simon South
  0 siblings, 1 reply; 20+ messages in thread
From: Liliana Marie Prikler @ 2023-02-09  5:29 UTC (permalink / raw)
  To: Simon South, Christopher Baines; +Cc: 60429

Am Mittwoch, dem 08.02.2023 um 19:35 -0500 schrieb Simon South:
> Yosys' "show" command produces its output by building and executing a
> shell command that invokes "dot" or "xdot" on the user's data.  The
> implementation is in passes/cmds/show.cc[0]; the code for invoking
> dot for instance looks like
> 
>     #define DOT_CMD "dot -T%s '%s' > '%s.new' && mv '%s.new' '%s'"
>     (...)
>     std::string cmd = stringf(DOT_CMD, format.c_str(),
> dot_file.c_str(), out_file.c_str(), out_file.c_str(),
> out_file.c_str());
>     log("Exec: %s\n", cmd.c_str());
>     if (run_command(cmd) != 0)
>         log_cmd_error("Shell command failed!\n");
> 
> Obviously this works only if "dot" is in the user's PATH (as Yosys
> blindly assumes), so the graphviz package must be installed as well
> or the "show" command will be broken.  Similarly for the "fuser" and
> "xdot" executables, which by default are invoked to provide graphical
> output (though their use can be overridden by a setting at runtime).
> 
> I find this business of generating shell commands a bit ugly but at
> least it creates only a loose coupling between the executables: The
> shell is free to select a suitable "dot" to run, so the user can
> substitute their own as easily as changing their PATH.
When propagating inputs, it creates the same tight coupling as
hardcoding would, but with worse UX (think propagating conflicts).


You should instead try:

  std::optional<std::string> dot_bin = which("dot")
  if (!dot_bin)
    dot_bin = "@dot@";
  std::string cmd = string(DOT_CMD, *dot_bin, ...)

Cheers




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies.
  2023-02-09  5:29         ` Liliana Marie Prikler
@ 2023-02-09 16:47           ` Simon South
  0 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2023-02-09 16:47 UTC (permalink / raw)
  To: Liliana Marie Prikler; +Cc: 60429, Christopher Baines

Liliana Marie Prikler <liliana.prikler@gmail.com> writes:
> You should instead try:

That would be a nice approach but I don't really want to start modifying
the source code.

I'll send out a v3 of the remaining patches that keeps the 'fix-paths
phase (and updates Yosys to 0.26, since that came out yesterday).

Embedding store references directly in source code still feels ugly to
me but I can see how propagating packages just creates a different
problem.  Pity there isn't an elegant way to specify a package should
"use this input, but not exclusively" (though at least there's "guix
build --with-input").

--
Simon South
simon@simonsouth.net




^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v3 0/5] gnu: yosys: Update to 0.24.
  2022-12-30 15:58 [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24 Simon South
                   ` (5 preceding siblings ...)
  2023-01-08 18:31 ` [bug#60429] [PATCH v2 0/5] " Simon South
@ 2023-02-10 13:16 ` Simon South
  2023-02-10 13:16   ` [bug#60429] [PATCH v3 4/5] gnu: yosys: Do not propagate any inputs Simon South
                     ` (2 more replies)
  6 siblings, 3 replies; 20+ messages in thread
From: Simon South @ 2023-02-10 13:16 UTC (permalink / raw)
  To: 60429

Here's a third revision of the remaining two patches in this series.  These
updated patches now

- Remove the remaining propagated inputs (abc and z3) from the yosys package
  via changes to its "fix-paths" and "use-external-abc" phases, and

- Update Yosys to version 0.26.

Note the second patch adds python and python-click as new propagated inputs.
The Click library is needed by the "yosys-witness" command, and including both
it and the Python interpreter in propagated-inputs is the only combination
I've found that will cause Guix to set GUIX_PYTHONPATH appropriately on
installation so this command can function.

This appears to be supported by the Guix manual (in the sections "Search
Paths" and "Python Modules") but if there's a better approach, please let me
know.

As usual, I've tested these changes on x86-64 and AArch64 and all appears
well.

--
Simon South
simon@simonsouth.net


Simon South (2):
  gnu: yosys: Do not propagate any inputs.
  gnu: yosys: Update to 0.26.

 gnu/packages/fpga.scm | 56 +++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 32 deletions(-)


base-commit: b8f6ead5faac3c1b9a8fa6e060c00cf0917e884e
-- 
2.39.1





^ permalink raw reply	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v3 4/5] gnu: yosys: Do not propagate any inputs.
  2023-02-10 13:16 ` [bug#60429] [PATCH v3 0/5] gnu: yosys: Update to 0.24 Simon South
@ 2023-02-10 13:16   ` Simon South
  2023-02-10 13:16   ` [bug#60429] [PATCH v3 5/5] gnu: yosys: Update to 0.26 Simon South
  2023-02-11 20:38   ` bug#60429: [PATCH v3 0/5] gnu: yosys: Update to 0.24 Christopher Baines
  2 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2023-02-10 13:16 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys)[arguments]<#:phases>: Patch reference to z3 in
"fix-paths" phase; in "use-external-abc" phase, use complete path to "abc"
executable in store.
[propagated-inputs]: Remove, moving abc and z3 from here...
[inputs]: ...to here.
---
 gnu/packages/fpga.scm | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 7b3c522bf7..4a01714e81 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -159,6 +159,9 @@ (define-public yosys
       #~(modify-phases %standard-phases
           (add-before 'configure 'fix-paths
             (lambda* (#:key inputs #:allow-other-keys)
+              (substitute* "./backends/smt2/smtio.py"
+                (("\\['z3")
+                 (string-append "['" (search-input-file inputs "/bin/z3"))))
               (substitute* "./passes/cmds/show.cc"
                 (("exec xdot")
                  (string-append "exec " (search-input-file inputs
@@ -171,9 +174,11 @@ (define-public yosys
             (lambda* (#:key make-flags #:allow-other-keys)
               (apply invoke "make" "config-gcc" make-flags)))
           (add-after 'configure 'use-external-abc
-            (lambda _
+            (lambda* (#:key inputs #:allow-other-keys)
               (substitute* '("./Makefile")
-                (("ABCEXTERNAL \\?=") "ABCEXTERNAL = abc"))))
+                (("ABCEXTERNAL \\?=")
+                 (string-append "ABCEXTERNAL = "
+                                (search-input-file inputs "/bin/abc"))))))
           (add-before 'check 'fix-iverilog-references
             (lambda* (#:key inputs native-inputs #:allow-other-keys)
               (let ((iverilog (search-input-file (or native-inputs inputs)
@@ -211,15 +216,14 @@ (define-public yosys
            python
            tcl)) ; tclsh for the tests
     (inputs
-     (list graphviz
+     (list abc
+           graphviz
            libffi
            psmisc
            readline
            tcl
-           xdot))
-    (propagated-inputs
-     (list abc
-           z3)) ; should be in path for yosys-smtbmc
+           xdot
+           z3))
     (home-page "https://yosyshq.net/yosys/")
     (synopsis "FPGA Verilog RTL synthesizer")
     (description "Yosys synthesizes Verilog-2005.")
-- 
2.39.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* [bug#60429] [PATCH v3 5/5] gnu: yosys: Update to 0.26.
  2023-02-10 13:16 ` [bug#60429] [PATCH v3 0/5] gnu: yosys: Update to 0.24 Simon South
  2023-02-10 13:16   ` [bug#60429] [PATCH v3 4/5] gnu: yosys: Do not propagate any inputs Simon South
@ 2023-02-10 13:16   ` Simon South
  2023-02-11 20:38   ` bug#60429: [PATCH v3 0/5] gnu: yosys: Update to 0.24 Christopher Baines
  2 siblings, 0 replies; 20+ messages in thread
From: Simon South @ 2023-02-10 13:16 UTC (permalink / raw)
  To: 60429

* gnu/packages/fpga.scm (yosys): Update to 0.26.
[source]: Disable unnecessary recursive checkout.
[arguments]<#:phases>: Expand "fix-paths" phase to match new version; remove
obsolete "fix-iverilog-references" phase.
[inputs]: Add gtkwave, zlib.
[propagated-inputs]: Add python, python-click.
---
 gnu/packages/fpga.scm | 42 +++++++++++++++---------------------------
 1 file changed, 15 insertions(+), 27 deletions(-)

diff --git a/gnu/packages/fpga.scm b/gnu/packages/fpga.scm
index 4a01714e81..8f03ba7a1d 100644
--- a/gnu/packages/fpga.scm
+++ b/gnu/packages/fpga.scm
@@ -137,16 +137,15 @@ (define-public iverilog
 (define-public yosys
   (package
     (name "yosys")
-    (version "0.9")
+    (version "0.26")
     (source (origin
               (method git-fetch)
               (uri (git-reference
                     (url "https://github.com/YosysHQ/yosys")
-                    (commit (string-append "yosys-" version))
-                    (recursive? #t))) ; for the ‘iverilog’ submodule
+                    (commit (string-append "yosys-" version))))
               (sha256
-                (base32
-                   "0lb9r055h8y1vj2z8gm4ip0v06j5mk7f9zx9gi67kkqb7g4rhjli"))
+               (base32
+                "0s79ljgbcfkm7l9km7dcvlz4mnx38nbyxppscvh5il5lw07n45gx"))
               (file-name (git-file-name name version))))
     (build-system gnu-build-system)
     (arguments
@@ -162,7 +161,11 @@ (define-public yosys
               (substitute* "./backends/smt2/smtio.py"
                 (("\\['z3")
                  (string-append "['" (search-input-file inputs "/bin/z3"))))
-              (substitute* "./passes/cmds/show.cc"
+              (substitute* "./kernel/fstdata.cc"
+                (("vcd2fst")
+                 (search-input-file inputs "/bin/vcd2fst")))
+              (substitute* '("./passes/cmds/show.cc"
+                             "./passes/cmds/viz.cc")
                 (("exec xdot")
                  (string-append "exec " (search-input-file inputs
                                                            "/bin/xdot")))
@@ -179,26 +182,6 @@ (define-public yosys
                 (("ABCEXTERNAL \\?=")
                  (string-append "ABCEXTERNAL = "
                                 (search-input-file inputs "/bin/abc"))))))
-          (add-before 'check 'fix-iverilog-references
-            (lambda* (#:key inputs native-inputs #:allow-other-keys)
-              (let ((iverilog (search-input-file (or native-inputs inputs)
-                                                 "/bin/iverilog")))
-                (substitute* '("./manual/CHAPTER_StateOfTheArt/synth.sh"
-                               "./manual/CHAPTER_StateOfTheArt/validate_tb.sh"
-                               "./techlibs/ice40/tests/test_bram.sh"
-                               "./techlibs/ice40/tests/test_ffs.sh"
-                               "./techlibs/xilinx/tests/bram1.sh"
-                               "./techlibs/xilinx/tests/bram2.sh"
-                               "./tests/bram/run-single.sh"
-                               "./tests/realmath/run-test.sh"
-                               "./tests/simple/run-test.sh"
-                               "./tests/techmap/mem_simple_4x1_runtest.sh"
-                               "./tests/tools/autotest.sh"
-                               "./tests/vloghtb/common.sh")
-                  (("if ! which iverilog") "if ! true")
-                  (("iverilog ") (string-append iverilog " "))
-                  (("iverilog_bin=\".*\"") (string-append "iverilog_bin=\""
-                                                          iverilog "\""))))))
           (add-after 'install 'add-symbolic-link
             (lambda* (#:key inputs #:allow-other-keys)
               ;; Previously this package provided a copy of the "abc"
@@ -218,12 +201,17 @@ (define-public yosys
     (inputs
      (list abc
            graphviz
+           gtkwave
            libffi
            psmisc
            readline
            tcl
            xdot
-           z3))
+           z3
+           zlib))
+    (propagated-inputs
+     (list python
+           python-click))
     (home-page "https://yosyshq.net/yosys/")
     (synopsis "FPGA Verilog RTL synthesizer")
     (description "Yosys synthesizes Verilog-2005.")
-- 
2.39.1





^ permalink raw reply related	[flat|nested] 20+ messages in thread

* bug#60429: [PATCH v3 0/5] gnu: yosys: Update to 0.24.
  2023-02-10 13:16 ` [bug#60429] [PATCH v3 0/5] gnu: yosys: Update to 0.24 Simon South
  2023-02-10 13:16   ` [bug#60429] [PATCH v3 4/5] gnu: yosys: Do not propagate any inputs Simon South
  2023-02-10 13:16   ` [bug#60429] [PATCH v3 5/5] gnu: yosys: Update to 0.26 Simon South
@ 2023-02-11 20:38   ` Christopher Baines
  2 siblings, 0 replies; 20+ messages in thread
From: Christopher Baines @ 2023-02-11 20:38 UTC (permalink / raw)
  To: Simon South; +Cc: 60429-done, guix-patches

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


Simon South <simon@simonsouth.net> writes:

> Here's a third revision of the remaining two patches in this series.  These
> updated patches now
>
> - Remove the remaining propagated inputs (abc and z3) from the yosys package
>   via changes to its "fix-paths" and "use-external-abc" phases, and
>
> - Update Yosys to version 0.26.

Thanks for the update, I made a tweak and pushed these to master as
8553148dfb91a9957b95c7bc6bc108cc0a973f9e.

> Note the second patch adds python and python-click as new propagated inputs.
> The Click library is needed by the "yosys-witness" command, and including both
> it and the Python interpreter in propagated-inputs is the only combination
> I've found that will cause Guix to set GUIX_PYTHONPATH appropriately on
> installation so this command can function.
>
> This appears to be supported by the Guix manual (in the sections "Search
> Paths" and "Python Modules") but if there's a better approach, please let me
> know.

I believe the good approach to do this is to wrap the relevant
script. I've gone ahead and changed the patch to do this rather than add
the propagated inputs. Do let me know if there's a problem with this
approach though, as I don't know how to test this software as well as
you.

Thanks again,

Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 987 bytes --]

^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2023-02-11 20:42 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-30 15:58 [bug#60429] [PATCH 0/5] gnu: yosys: Update to 0.24 Simon South
2022-12-30 16:00 ` [bug#60429] [PATCH 1/5] gnu: yosys: Update source and home-page URLs Simon South
2022-12-30 16:00 ` [bug#60429] [PATCH 2/5] gnu: yosys: Use new package style Simon South
2022-12-30 16:00 ` [bug#60429] [PATCH 3/5] gnu: yosys: Use external abc Simon South
2022-12-30 16:00 ` [bug#60429] [PATCH 4/5] gnu: yosys: Propagate external dependencies Simon South
2022-12-30 16:00 ` [bug#60429] [PATCH 5/5] gnu: yosys: Update to 0.24 Simon South
2023-01-08 18:31 ` [bug#60429] [PATCH v2 0/5] " Simon South
2023-01-08 18:31   ` [bug#60429] [PATCH v2 1/5] gnu: yosys: Update source and home-page URLs Simon South
2023-01-08 18:31   ` [bug#60429] [PATCH v2 2/5] gnu: yosys: Use new package style Simon South
2023-01-08 18:31   ` [bug#60429] [PATCH v2 3/5] gnu: yosys: Use external abc Simon South
2023-01-08 18:31   ` [bug#60429] [PATCH v2 4/5] gnu: yosys: Propagate external dependencies Simon South
2023-02-08 17:14     ` Christopher Baines
2023-02-09  0:35       ` Simon South
2023-02-09  5:29         ` Liliana Marie Prikler
2023-02-09 16:47           ` Simon South
2023-01-08 18:31   ` [bug#60429] [PATCH v2 5/5] gnu: yosys: Update to 0.25 Simon South
2023-02-10 13:16 ` [bug#60429] [PATCH v3 0/5] gnu: yosys: Update to 0.24 Simon South
2023-02-10 13:16   ` [bug#60429] [PATCH v3 4/5] gnu: yosys: Do not propagate any inputs Simon South
2023-02-10 13:16   ` [bug#60429] [PATCH v3 5/5] gnu: yosys: Update to 0.26 Simon South
2023-02-11 20:38   ` bug#60429: [PATCH v3 0/5] gnu: yosys: Update to 0.24 Christopher Baines

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.