From 904d49c6d818897bb4c854e64c6c395861146e0d Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 23 Sep 2025 14:38:15 +0200 Subject: [PATCH 1/4] abc9_ops: Remove temporary debug log message I missed this when adding the -replace_zbufs option. --- passes/techmap/abc9_ops.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/passes/techmap/abc9_ops.cc b/passes/techmap/abc9_ops.cc index ecba519bf..2e762d7b9 100644 --- a/passes/techmap/abc9_ops.cc +++ b/passes/techmap/abc9_ops.cc @@ -1600,7 +1600,6 @@ static void replace_zbufs(Design *design) sig[i] = w; } } - log("XXX %s -> %s\n", log_signal(cell->getPort(ID::A)), log_signal(sig)); cell->setPort(ID::A, sig); } From 71882debe78cda10a963b89404ac4decbedca8f2 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Wed, 24 Sep 2025 13:15:36 +0200 Subject: [PATCH 2/4] simplemap: Remove leftover debug output --- passes/techmap/simplemap.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/passes/techmap/simplemap.cc b/passes/techmap/simplemap.cc index 86ff5c149..938ed5355 100644 --- a/passes/techmap/simplemap.cc +++ b/passes/techmap/simplemap.cc @@ -18,7 +18,6 @@ */ #include "simplemap.h" -#include "backends/rtlil/rtlil_backend.h" #include "kernel/sigtools.h" #include "kernel/ff.h" #include @@ -156,14 +155,11 @@ void simplemap_reduce(RTLIL::Module *module, RTLIL::Cell *cell) } RTLIL::Cell *gate = module->addCell(NEW_ID, gate_type); - log("huh\n"); - RTLIL_BACKEND::dump_cell(std::cout, "", cell); transfer_src(gate, cell); gate->setPort(ID::A, sig_a[i]); gate->setPort(ID::B, sig_a[i+1]); gate->setPort(ID::Y, sig_t[i/2]); last_output_cell = gate; - RTLIL_BACKEND::dump_cell(std::cout, "", gate); } sig_a = sig_t; From 86a46b9e5c122a4f6463390e8e9bbac8f48f4bea Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 23 Sep 2025 14:19:30 +0200 Subject: [PATCH 3/4] log: Flush stdout before printing a fatal error to stderr This hasn't been an issue when using -l to redirect or when stdout is line buffered, explaining how we didn't notice this earlier, but for `yosys ... > log` that extra flush is required to ensure all messages preceding the fatal error are flushed. --- kernel/log.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/log.cc b/kernel/log.cc index 0085980b1..af083860a 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -331,10 +331,12 @@ static void log_error_with_prefix(std::string_view prefix, std::string str) if (log_errfile != NULL) log_files.push_back(log_errfile); - if (log_error_stderr) + if (log_error_stderr) { + log_flush(); // Make sure we flush stdout before replacing it with stderr for (auto &f : log_files) if (f == stdout) f = stderr; + } log_last_error = std::move(str); log("%s%s", prefix, log_last_error); From 2dce50516b218b28a34b838810709fa0ee24d256 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 23 Sep 2025 14:26:53 +0200 Subject: [PATCH 4/4] log: Print static message as fatal error for YOSYS_ABORT --- kernel/log.cc | 5 +++++ kernel/yosys_common.h | 7 ++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/log.cc b/kernel/log.cc index af083860a..34e56f8ac 100644 --- a/kernel/log.cc +++ b/kernel/log.cc @@ -407,6 +407,11 @@ void log_abort_internal(const char *file, int line) log_error("Abort in %s:%d.\n", file, line); } +void log_yosys_abort_message(std::string_view file, int line, std::string_view func, std::string_view message) +{ + log_error("Abort in %s:%d (%s): %s\n", file, line, func, message); +} + void log_formatted_cmd_error(std::string str) { if (log_cmd_error_throw) { diff --git a/kernel/yosys_common.h b/kernel/yosys_common.h index fd84dd74e..d69e02a59 100644 --- a/kernel/yosys_common.h +++ b/kernel/yosys_common.h @@ -142,7 +142,12 @@ #define YOSYS_CONSTEVAL constexpr #endif -#define YOSYS_ABORT(s) abort() +#define YOSYS_ABORT(s) YOSYS_NAMESPACE_PREFIX log_yosys_abort_message(__FILE__, __LINE__, __FUNCTION__, s) + +// This has to precede including "kernel/io.h" +YOSYS_NAMESPACE_BEGIN +[[noreturn]] void log_yosys_abort_message(std::string_view file, int line, std::string_view func, std::string_view message); +YOSYS_NAMESPACE_END #include "kernel/io.h"