From 95a2099c906feaa808345a01390afe3c83a41ae0 Mon Sep 17 00:00:00 2001 From: "Mike A." Date: Sun, 29 Sep 2024 17:15:59 +0200 Subject: [PATCH 1/5] Allow whitespace in `tee` command paths --- passes/cmds/tee.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/passes/cmds/tee.cc b/passes/cmds/tee.cc index 39ed4a7a8..853f1bad3 100644 --- a/passes/cmds/tee.cc +++ b/passes/cmds/tee.cc @@ -72,7 +72,9 @@ struct TeePass : public Pass { } if ((args[argidx] == "-o" || args[argidx] == "-a") && argidx+1 < args.size()) { const char *open_mode = args[argidx] == "-o" ? "w" : "a+"; - FILE *f = fopen(args[++argidx].c_str(), open_mode); + auto path = args[++argidx]; + rewrite_filename(path); + FILE *f = fopen(path.c_str(), open_mode); yosys_input_files.insert(args[argidx]); if (f == NULL) { for (auto cf : files_to_close) From 80dc94649953205134c5486a5c3ba370db949302 Mon Sep 17 00:00:00 2001 From: KrystalDelusion <93062060+KrystalDelusion@users.noreply.github.com> Date: Sat, 29 Mar 2025 12:29:55 +1300 Subject: [PATCH 2/5] Makefile: Test yosys git status in check-git-abc As in #4986, `check-git-abc` is misleading if Yosys itself isn't a git repository. So check `git status` before suggesting `git` based solutions, providing alternative suggestions for using ABCEXTERNAL (which bypasses `check-git-abc`), or downloading release tar (noting that the 'Source code' archives won't work, which is probably how they ended up in this situtation). --- Makefile | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 5745d1d0c..2e4db2456 100644 --- a/Makefile +++ b/Makefile @@ -785,7 +785,7 @@ $(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in $(YOSYS_SRC)/Makefile .PHONY: check-git-abc check-git-abc: - @if [ ! -d "$(YOSYS_SRC)/abc" ]; then \ + @if [ ! -d "$(YOSYS_SRC)/abc" ] && git -C "$(YOSYS_SRC)" status 2>/dev/null; then \ echo "Error: The 'abc' directory does not exist."; \ echo "Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ exit 1; \ @@ -811,6 +811,12 @@ check-git-abc: echo "3. Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ echo "4. Reapply your changes: Move your saved changes back to the 'abc' directory, if necessary."; \ exit 1; \ + elif ! git -C "$(YOSYS_SRC)" status 2>/dev/null; then \ + echo "$(realpath $(YOSYS_SRC)) is not configured as a git repository, and 'abc' folder is missing."; \ + echo "If you already have ABC, set 'ABCEXTERNAL' make variable to point to ABC executable."; \ + echo "Otherwise, download release archive 'yosys.tar.gz' from https://github.com/YosysHQ/yosys/releases."; \ + echo " ('Source code' archive does not contain submodules.)"; \ + exit 1; \ else \ echo "Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ exit 1; \ From 1e8adc6bd011487ddcc5a6c6cedd51799c0926f2 Mon Sep 17 00:00:00 2001 From: Krystine Sherwin <93062060+KrystalDelusion@users.noreply.github.com> Date: Sat, 26 Apr 2025 10:59:24 +1200 Subject: [PATCH 3/5] Makefile: Redirect all git output For some platforms (Arch Linux, at least), `git status` reports errors on stdout instead of stderr, so we need to redirect that to `/dev/null` too. This also prevents `git status` from logging output when the yosys directory is a git repo, but is missing the abc folder. --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 2e4db2456..23d91b117 100644 --- a/Makefile +++ b/Makefile @@ -785,7 +785,7 @@ $(PROGRAM_PREFIX)yosys-config: misc/yosys-config.in $(YOSYS_SRC)/Makefile .PHONY: check-git-abc check-git-abc: - @if [ ! -d "$(YOSYS_SRC)/abc" ] && git -C "$(YOSYS_SRC)" status 2>/dev/null; then \ + @if [ ! -d "$(YOSYS_SRC)/abc" ] && git -C "$(YOSYS_SRC)" status >/dev/null 2>&1; then \ echo "Error: The 'abc' directory does not exist."; \ echo "Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ exit 1; \ @@ -811,7 +811,7 @@ check-git-abc: echo "3. Initialize the submodule: Run 'git submodule update --init' to set up 'abc' as a submodule."; \ echo "4. Reapply your changes: Move your saved changes back to the 'abc' directory, if necessary."; \ exit 1; \ - elif ! git -C "$(YOSYS_SRC)" status 2>/dev/null; then \ + elif ! git -C "$(YOSYS_SRC)" status >/dev/null 2>&1; then \ echo "$(realpath $(YOSYS_SRC)) is not configured as a git repository, and 'abc' folder is missing."; \ echo "If you already have ABC, set 'ABCEXTERNAL' make variable to point to ABC executable."; \ echo "Otherwise, download release archive 'yosys.tar.gz' from https://github.com/YosysHQ/yosys/releases."; \ From adb1986dc10d19b414971b472497a71bc0d0e052 Mon Sep 17 00:00:00 2001 From: "Emil J. Tywoniak" Date: Tue, 29 Apr 2025 10:37:35 +0200 Subject: [PATCH 4/5] gzip: refactor file open failure errors --- kernel/gzip.cc | 5 +++-- kernel/register.cc | 2 -- passes/cmds/stat.cc | 2 -- passes/techmap/clockgate.cc | 2 -- passes/techmap/dfflibmap.cc | 2 -- 5 files changed, 3 insertions(+), 10 deletions(-) diff --git a/kernel/gzip.cc b/kernel/gzip.cc index d44b03517..4567fe03b 100644 --- a/kernel/gzip.cc +++ b/kernel/gzip.cc @@ -100,11 +100,12 @@ gzip_istream::ibuf::~ibuf() { // Takes a successfully opened ifstream. If it's gzipped, returns an istream. Otherwise, // returns the original ifstream, rewound to the start. +// Never returns nullptr or failed state istream* std::istream* uncompressed(const std::string filename, std::ios_base::openmode mode) { std::ifstream* f = new std::ifstream(); f->open(filename, mode); if (f->fail()) - return f; + log_cmd_error("Can't open input file `%s' for reading: %s\n", filename.c_str(), strerror(errno)); // Check for gzip magic unsigned char magic[3]; int n = 0; @@ -124,7 +125,7 @@ std::istream* uncompressed(const std::string filename, std::ios_base::openmode m filename.c_str(), unsigned(magic[2])); gzip_istream* s = new gzip_istream(); delete f; - s->open(filename.c_str()); + log_assert(s->open(filename.c_str())); return s; #else log_cmd_error("File `%s' is a gzip file, but Yosys is compiled without zlib.\n", filename.c_str()); diff --git a/kernel/register.cc b/kernel/register.cc index c52bfb5b8..a82f93555 100644 --- a/kernel/register.cc +++ b/kernel/register.cc @@ -472,8 +472,6 @@ void Frontend::extra_args(std::istream *&f, std::string &filename, std::vector &cell_area, string libert { std::istream* f = uncompressed(liberty_file.c_str()); yosys_input_files.insert(liberty_file); - if (f->fail()) - log_cmd_error("Can't open liberty file `%s': %s\n", liberty_file.c_str(), strerror(errno)); LibertyParser libparser(*f, liberty_file); delete f; diff --git a/passes/techmap/clockgate.cc b/passes/techmap/clockgate.cc index 2305cfc94..508e66d23 100644 --- a/passes/techmap/clockgate.cc +++ b/passes/techmap/clockgate.cc @@ -310,8 +310,6 @@ struct ClockgatePass : public Pass { LibertyMergedCells merged; for (auto path : liberty_files) { std::istream* f = uncompressed(path); - if (f->fail()) - log_cmd_error("Can't open liberty file `%s': %s\n", path.c_str(), strerror(errno)); LibertyParser p(*f, path); merged.merge(p); delete f; diff --git a/passes/techmap/dfflibmap.cc b/passes/techmap/dfflibmap.cc index ae13a6ddd..d00fee83b 100644 --- a/passes/techmap/dfflibmap.cc +++ b/passes/techmap/dfflibmap.cc @@ -635,8 +635,6 @@ struct DfflibmapPass : public Pass { LibertyMergedCells merged; for (auto path : liberty_files) { std::istream* f = uncompressed(path); - if (f->fail()) - log_cmd_error("Can't open liberty file `%s': %s\n", path.c_str(), strerror(errno)); LibertyParser p(*f, path); merged.merge(p); delete f; From aa30589c123844bc576fc3c9938157b5db35a7c1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Thu, 1 May 2025 00:26:28 +0000 Subject: [PATCH 5/5] Bump version --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index e347d1c8c..d2f518d88 100644 --- a/Makefile +++ b/Makefile @@ -160,7 +160,7 @@ ifeq ($(OS), Haiku) CXXFLAGS += -D_DEFAULT_SOURCE endif -YOSYS_VER := 0.52+117 +YOSYS_VER := 0.52+137 YOSYS_MAJOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f1) YOSYS_MINOR := $(shell echo $(YOSYS_VER) | cut -d'.' -f2 | cut -d'+' -f1) YOSYS_COMMIT := $(shell echo $(YOSYS_VER) | cut -d'+' -f2)