From 7c3becfbcd0c2e3ae820f6fa5129200761a7b04e Mon Sep 17 00:00:00 2001 From: Mike Inouye Date: Mon, 17 Aug 2026 21:18:34 +0000 Subject: [PATCH] add file lock on liberty scl cache Signed-off-by: Mike Inouye --- passes/techmap/liberty_cache.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/passes/techmap/liberty_cache.h b/passes/techmap/liberty_cache.h index e2b0900aa..f5fe7f750 100644 --- a/passes/techmap/liberty_cache.h +++ b/passes/techmap/liberty_cache.h @@ -9,8 +9,25 @@ namespace abc { } #endif +#if !defined(_WIN32) +#include +#endif + YOSYS_NAMESPACE_BEGIN +#if !defined(_WIN32) +struct ScopedFlock { + int fd; + ScopedFlock(const std::string &path) { + fd = open(path.c_str(), O_CREAT | O_RDWR, 0666); + if (fd >= 0) flock(fd, LOCK_EX); + } + ~ScopedFlock() { + if (fd >= 0) { flock(fd, LOCK_UN); close(fd); } + } +}; +#endif + // Controlled by the libcache pass (-scl option), enabled by default extern bool scl_cache_enabled; @@ -81,6 +98,13 @@ inline std::string convert_liberty_files_to_merged_scl(const std::vector= newest_mtime) { + log("ABC: using cached merged SCL: %s (%zu files)\n", merged_scl.c_str(), liberty_files.size()); + return merged_scl; + } +#endif // read_lib -X cell1 -X cell2 file1 ; read_lib -X cell1 -X cell2 -m file2 ; ... ; write_scl merged.scl std::string temp_scl = merged_scl + ".tmp";