3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-09-30 13:19:05 +00:00

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.
This commit is contained in:
Jannis Harder 2025-09-23 14:19:30 +02:00
parent 71882debe7
commit 86a46b9e5c

View file

@ -331,10 +331,12 @@ static void log_error_with_prefix(std::string_view prefix, std::string str)
if (log_errfile != NULL) if (log_errfile != NULL)
log_files.push_back(log_errfile); 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) for (auto &f : log_files)
if (f == stdout) if (f == stdout)
f = stderr; f = stderr;
}
log_last_error = std::move(str); log_last_error = std::move(str);
log("%s%s", prefix, log_last_error); log("%s%s", prefix, log_last_error);