Skip to content
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

[svsim] Better error message when verilator not on PATH #3829

Merged
merged 1 commit into from
Feb 16, 2024

Conversation

jackkoenig
Copy link
Contributor

Contributor Checklist

  • Did you add Scaladoc to every public function/method?
  • Did you add at least one test demonstrating the PR?
  • Did you delete any extraneous printlns/debugging code?
  • Did you specify the type of improvement?
  • Did you add appropriate documentation in docs/src?
  • Did you request a desired merge strategy?
  • Did you add text to be included in the Release Notes for this change?

Type of Improvement

  • Bugfix

Desired Merge Strategy

  • Squash

Release Notes

Reviewer Checklist (only modified by reviewer)

  • Did you add the appropriate labels? (Select the most appropriate one based on the "Type of Improvement")
  • Did you mark the proper milestone (Bug fix: 3.6.x, 5.x, or 6.x depending on impact, API modification or big change: 7.0)?
  • Did you review?
  • Did you check whether all relevant Contributor checkboxes have been checked?
  • Did you do one of the following when ready to merge:
    • Squash: You/ the contributor Enable auto-merge (squash), clean up the commit message, and label with Please Merge.
    • Merge: Ensure that contributor has cleaned up their commit history, then merge with Create a merge commit.

@jackkoenig jackkoenig added the Bugfix Fixes a bug, will be included in release notes label Feb 16, 2024
@jackkoenig jackkoenig added this to the 5.x milestone Feb 16, 2024
@jackkoenig jackkoenig force-pushed the svsim-better-error-no-verilator branch from 213afb9 to 827bc93 Compare February 16, 2024 21:52
Copy link
Member

@seldridge seldridge left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Question about avoiding which. May be able to be ignored.

I can't think of any easy way to test this code path other than with the something like applying the suggested change of using verilator --lint-only and then aliasing verilator to false in the test.

Comment on lines +26 to +31
val output = mutable.ArrayBuffer.empty[String]
val exitCode = List("which", "verilator").!(ProcessLogger(output += _))
if (exitCode != 0) {
throw new Exception(s"verilator not found on the PATH!\n${output.mkString("\n")}")
}
val executablePath = output.head.trim
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This definitely works on macOS and linux. Does this work on Windows?

It may be better to instead do verilator --version which may be more platform independent.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I doubt which works on Windows except maybe WSL/WSL2. verilator --version won't give the path to it, which is what this code is trying to do (not sure why, it's how it's always been). I think I'll merge this fix as is (although will try to add a test), but point taken about trying to make it platform independent. That being said, I'm not sure how well Verilator works on Windows anyway since it also uses a Makefile that is very much written in a *nix style... Checking all of this on Windows is probably just a big task across the board.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rereading your suggestion (from review) about a test, I don't think there's any reasonable way to test the behavior of "which" here, at least not via ScalaTest. I'm not sure how valuable it is that this code is getting the full path to Verilator, but it does have some nice properties like ensuring the generated Makefile for replaying points to the exact Verilator rather than requiring the user to have the same environment.

@jackkoenig jackkoenig merged commit 41dd267 into main Feb 16, 2024
14 checks passed
@jackkoenig jackkoenig deleted the svsim-better-error-no-verilator branch February 16, 2024 23:17
@mergify mergify bot added the Backported This PR has been backported label Feb 16, 2024
mergify bot pushed a commit that referenced this pull request Feb 16, 2024
mergify bot pushed a commit that referenced this pull request Feb 16, 2024
chiselbot pushed a commit that referenced this pull request Feb 16, 2024
(cherry picked from commit 41dd267)

Co-authored-by: Jack Koenig <koenig@sifive.com>
chiselbot pushed a commit that referenced this pull request Feb 16, 2024
(cherry picked from commit 41dd267)

Co-authored-by: Jack Koenig <koenig@sifive.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Backported This PR has been backported Bugfix Fixes a bug, will be included in release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants