From 2dce50516b218b28a34b838810709fa0ee24d256 Mon Sep 17 00:00:00 2001 From: Jannis Harder Date: Tue, 23 Sep 2025 14:26:53 +0200 Subject: [PATCH] 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"