diff --git a/Makefile b/Makefile index 6b66bd640..a6f4235d7 100644 --- a/Makefile +++ b/Makefile @@ -176,7 +176,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) YOSYS_COMMIT := $(shell echo $(YOSYS_VER) | cut -d'.' -f3) @@ -847,7 +847,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 >/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; \ @@ -873,6 +873,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 >/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."; \ + 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; \ 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/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) 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;