From ae8c4e2ea6ee8f6c2e68261c06eb7f33131732ee Mon Sep 17 00:00:00 2001 From: Mohamed Gaber Date: Sat, 30 Aug 2025 06:13:12 +0300 Subject: [PATCH] libparse/filterlib: mark LibertyParser::error() as weak When FILTERLIB is defined (attempts to compile libparse more or less standalone,) mark the `LibertyParser::error()` as weak so utilities using libparse as a library can override its behavior (the default behavior being exit(1)). As the code is quite performance-critical, I've elected to not modify it to raise an exception or have a callback or similar and simply allow for a link-time replacement. --- passes/techmap/libparse.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/passes/techmap/libparse.cc b/passes/techmap/libparse.cc index c6f87b60b..b60e0b84b 100644 --- a/passes/techmap/libparse.cc +++ b/passes/techmap/libparse.cc @@ -676,12 +676,15 @@ void LibertyParser::error(const std::string &str) const #else +YS_ATTRIBUTE(weak) void LibertyParser::error() const { fprintf(stderr, "Syntax error in liberty file on line %d.\n", line); exit(1); } + +YS_ATTRIBUTE(weak) void LibertyParser::error(const std::string &str) const { std::stringstream ss;