-
Notifications
You must be signed in to change notification settings - Fork 177
Fix _yosys_version()
#364
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix _yosys_version()
#364
Conversation
Codecov Report
@@ Coverage Diff @@
## master #364 +/- ##
==========================================
+ Coverage 82.27% 82.55% +0.28%
==========================================
Files 35 35
Lines 5849 5950 +101
Branches 1207 1210 +3
==========================================
+ Hits 4812 4912 +100
+ Misses 872 871 -1
- Partials 165 167 +2
Continue to review full report at Codecov.
|
I wonder if we can fix that upstream, or if that's something Verific forces on us.
The current behavior is very much intentional; eventually I would like to ship Yosys (in the default configuration at least) as a library (likely compiled as WASM, but other options would work too), and I find it rather distasteful when libraries communicate with their host application through files. You are right that it would be a bit more foolproof though. |
@@ -16,7 +16,7 @@ class YosysError(Exception): | |||
def _yosys_version(): | |||
yosys_path = require_tool("yosys") | |||
version = subprocess.check_output([yosys_path, "-V"], encoding="utf-8") | |||
m = re.match(r"^Yosys ([\d.]+)(?:\+(\d+))?", version) | |||
m = re.search(r"^Yosys ([\d.]+)(?:\+(\d+))?", version, flags=re.M) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A comment here would be handy:
m = re.search(r"^Yosys ([\d.]+)(?:\+(\d+))?", version, flags=re.M) | |
# If Yosys is built with Verific, then Verific license information is printed first. | |
m = re.search(r"^Yosys ([\d.]+)(?:\+(\d+))?", version, flags=re.M) |
Co-Authored-By: whitequark <whitequark@whitequark.org>
Thanks! |
I think it's Verific. Here's a relevant gdb backtrace:
I tried looking through the yosys code earlier and couldn't see anything that seemed like it would be the cause of it. It seems like yosys doesn't print anything before the header, which gets disabled if you pass |
That's, uh, one way to name your license check function. |
See YosysHQ/yosys#1980. |
As a |
@hofstee Looks like it's going to be a permanent workaround. Feel free to submit a PR that adds such a hack, it's pretty bad but using temporary files in a situation like this is IMO also quite bad so I prefer the bad option that won't have any impact on people not using Verific. |
re.match
only matches at the beginning of the string, not each line. This change changes it to do are.search
with the multiline flag. I think this is primarily of use when the user has compiled yosys with verific extensions.Example of
yosys -V
output that failed with the prior code:Verilog generation is still borked.
yosys -q -
doesn't seem to stop the Verific license from being printed, so it gets captured in the subprocess stdout when nmigen grabs the output from yosys. It might be a bit more foolproof to modify that to write the data to a tempfile instead and pass the file between nmigen/yosys.