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

Make ABC_DONE detection more robust.

1) Change token from ABC_DONE to YOSYS_ABC_DONE to be a bit more robust against false matches.
2) Emit the token from the sourced script so that we don't have to worry about it showing up in the echoing
of the command as it executes. It will only appear in ABC stdout when it executes, i.e. when
our script has completed.
3) `set abcout` doesn't actually switch ABC to line buffering on stdout, since HAVE_SETVBUF is not actually
set in ABC builds in general. So stop using that. ABC does the necessary flushing when
`source` has finished.
This commit is contained in:
Robert O'Callahan 2025-09-22 04:35:48 +00:00
parent 2de641d051
commit 4fc782ef2b

View file

@ -1065,6 +1065,9 @@ void AbcModuleState::prepare_module(RTLIL::Design *design, RTLIL::Module *module
abc_script += stringf("; dress \"%s/input.blif\"", run_abc.tempdir_name); abc_script += stringf("; dress \"%s/input.blif\"", run_abc.tempdir_name);
abc_script += stringf("; write_blif %s/output.blif", run_abc.tempdir_name); abc_script += stringf("; write_blif %s/output.blif", run_abc.tempdir_name);
abc_script = add_echos_to_abc_cmd(abc_script); abc_script = add_echos_to_abc_cmd(abc_script);
#if defined(__linux__) && !defined(YOSYS_DISABLE_SPAWN)
abc_script += "; echo \"YOSYS_ABC_DONE\"\n";
#endif
for (size_t i = 0; i+1 < abc_script.size(); i++) for (size_t i = 0; i+1 < abc_script.size(); i++)
if (abc_script[i] == ';' && abc_script[i+1] == ' ') if (abc_script[i] == ';' && abc_script[i+1] == ' ')
@ -1147,9 +1150,7 @@ bool read_until_abc_done(abc_output_filter &filt, int fd, DeferredLogs &logs) {
break; break;
} }
line.append(start, p + 1 - start); line.append(start, p + 1 - start);
// ABC seems to actually print "ABC_DONE \n", but we probably shouldn't if (line.substr(0, 14) == "YOSYS_ABC_DONE") {
// rely on that extra space being output.
if (line.substr(0, 8) == "ABC_DONE") {
// Ignore any leftover output, there should only be a prompt perhaps // Ignore any leftover output, there should only be a prompt perhaps
return true; return true;
} }
@ -1344,12 +1345,8 @@ void RunAbcState::run(ConcurrentStack<AbcProcess> &process_pool)
return; return;
} }
std::string cmd = stringf( std::string cmd = stringf(
// This makes ABC switch stdout to line buffering, which we need
// to see our ABC_DONE message.
"set abcout /dev/stdout\n"
"empty\n" "empty\n"
"source %s\n" "source %s\n", tmp_script_name);
"echo \"ABC_DONE\"\n", tmp_script_name);
int ret = write(process.to_child_pipe, cmd.c_str(), cmd.size()); int ret = write(process.to_child_pipe, cmd.c_str(), cmd.size());
if (ret != static_cast<int>(cmd.size())) { if (ret != static_cast<int>(cmd.size())) {
logs.log_error("write failed"); logs.log_error("write failed");