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

Switch to firtool-resolver #3458

Merged
merged 2 commits into from
Dec 14, 2023
Merged

Switch to firtool-resolver #3458

merged 2 commits into from
Dec 14, 2023

Conversation

jackkoenig
Copy link
Contributor

@jackkoenig jackkoenig commented Aug 4, 2023

This uses https://github.com/jackkoenig/firtool-resolver which I will transfer to be an actual chipsalliance repo once this is merged.

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

  • API modification

Desired Merge Strategy

  • Squash

Release Notes

Whereas in the past, the user was expected to provide the firtool binary
on the PATH, Chisel will now manage the firtool binary automatically.
Chisel users the following 3-step process for determining which binary
to use:

  1. If environment variable FIRTOOL_PATH is set, it will check for
    firtool in that directory
  2. It will check the classpath for firtool provided by
    chipsalliance/llvm-firtool
  3. It will download a default version of chipsalliance/llvm-firtool

Both (2) and (3) will store the firtool binary in a sensible location
depending on the user's operating system. See dirs-dev/directories-jvm
for more information. The user can override this location by setting the
FIRTOOL_CACHE environment variable.

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.5.x, 3.6.x, or 5.x depending on impact, API modification or big change: 6.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 changed the title WIP using firtool-resolver Switch to firtool-resolver Dec 11, 2023
@sequencer
Copy link
Member

sequencer commented Dec 13, 2023

I wonder how about merging firtool-resolver into the chisel repo?

@jackkoenig jackkoenig force-pushed the jackkoenig/firtool-resolver branch 6 times, most recently from fe85427 to c3cfe55 Compare December 13, 2023 23:24
@jackkoenig
Copy link
Contributor Author

I wonder how about merging firtool-resolver into the chisel repo?

We could. I sort of like keeping it separate because llvm-firtool (the module for re-publishing firtool binaries as Java artifacts) lives in the same repo as firtool-resolver and thus can use firtool-resolver to test itself.

@jackkoenig jackkoenig force-pushed the jackkoenig/firtool-resolver branch 4 times, most recently from 274288c to 62d27d3 Compare December 14, 2023 00:09
Whereas in the past, the user was expected to provide the firtool binary
on the PATH, Chisel will now manage the firtool binary automatically.
Chisel users the following 3-step process for determining which binary
to use:

1. If environment variable FIRTOOL_PATH is set, it will check for
   firtool in that directory
2. It will check the classpath for firtool provided by
   chipsalliance/llvm-firtool
3. It will download a default version of chipsalliance/llvm-firtool

Both (2) and (3) will store the firtool binary in a sensible location
depending on the user's operating system. See dirs-dev/directories-jvm
for more information. The user can override this location by setting the
FIRTOOL_CACHE environment variable.
@sequencer
Copy link
Member

my point is, if living in chisel repo, it might be convenient to bump with the ci-nightly branch? It is good for those following the master branch.

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.

LGTM

It's great to see this finally happening.

Comment on lines -67 to +76
firtool -version >> $GITHUB_STEP_SUMMARY
$FIRTOOL_PATH/firtool -version >> $GITHUB_STEP_SUMMARY
Copy link
Member

Choose a reason for hiding this comment

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

The full path should be unnecessary due to the circt/install-circt action adding it to the path: https://github.com/circt/install-circt/blob/main/action.yml#L73

Copy link
Member

Choose a reason for hiding this comment

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

Also, consider inlining this step with the previous step as they have the same predicate.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thinking here was that the above step setting FIRTOOL_PATH will eventually be folded into circt/install-circt, so I factored this in the way such that once that happens, we can just bump the circt/install-circt version and delete the step above and everything will continue to work. Basically writing this code such that the expected next change will be extremely simple, does that make sense?

with:
version: ${{ inputs.circt }}
github-token: ${{ github.token }}
# TODO have install-circt do this
Copy link
Member

Choose a reason for hiding this comment

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

I agree that this seems reasonable to do.

That would avoid this type of chained conditional steps. Such chained conditional steps usually seems like an anti-pattern. No real problem with this as-is, though.

description: 'The CIRCT version to use (must be a valid release tag or "nightly")'
description: 'The CIRCT version to use (must be a valid release tag, "default", "nightly", or "version-file")'
Copy link
Member

Choose a reason for hiding this comment

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

Default may be a bit ambiguous. This is probably fine as-is. Consider either making this empty/not a required option or something more descriptive like "use-firtool-resolver".

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 good point. I think I'll go with not-required (thus empty) because that makes more sense that you're not installing a specific input, you're just leaving it up to chisel.

@jackkoenig jackkoenig added this to the 3.6.x milestone Dec 14, 2023
@jackkoenig
Copy link
Contributor Author

jackkoenig commented Dec 14, 2023

I've marked this for backporting to 3.6. It's technical an API change since firtool on the PATH will now be ignored, but I think it's a worthwhile one for usability. Actually deploying this for 3.6.x and 5.x will require ensuring we have the right versions of firtool published with llvm-firtool

@jackkoenig
Copy link
Contributor Author

my point is, if living in chisel repo, it might be convenient to bump with the ci-nightly branch? It is good for those following the master branch.

I see your point but I don't think that's going to be an issue. firtool-resolver (and llvm-firtool) are intended to be as independent of the actual APIs they wrap as possible. We may need to update them as firtool evolves packaging-wise (adding more artifacts, etc.) but never with the actual day-to-day APIs. I don't see a problem with keeping it backwards (and forwards) compatible enough to avoid needing to change it with nightly.

@jackkoenig jackkoenig merged commit 3938a46 into main Dec 14, 2023
14 checks passed
@jackkoenig jackkoenig deleted the jackkoenig/firtool-resolver branch December 14, 2023 22:31
@mergify mergify bot added the Backported This PR has been backported label Dec 14, 2023
mergify bot pushed a commit that referenced this pull request Dec 14, 2023
Whereas in the past, the user was expected to provide the firtool binary
on the PATH, Chisel will now manage the firtool binary automatically.
Chisel users the following 3-step process for determining which binary
to use:

1. If environment variable FIRTOOL_PATH is set, it will check for
   firtool in that directory
2. It will check the classpath for firtool provided by
   chipsalliance/llvm-firtool
3. It will download a default version of chipsalliance/llvm-firtool

Both (2) and (3) will store the firtool binary in a sensible location
depending on the user's operating system. See dirs-dev/directories-jvm
for more information. The user can override this location by setting the
FIRTOOL_CACHE environment variable.

(cherry picked from commit 3938a46)

# Conflicts:
#	.github/workflows/build-scala-cli-template.yml
#	.github/workflows/ci.yml
#	.github/workflows/test.yml
#	build.sbt
#	build.sc
#	common.sc
#	project/plugins.sbt
#	src/main/scala/circt/stage/phases/CIRCT.scala
#	src/test/scala/chiselTests/LoadMemoryFromFileSpec.scala
#	src/test/scala/circtTests/stage/ChiselStageSpec.scala
mergify bot pushed a commit that referenced this pull request Dec 14, 2023
Whereas in the past, the user was expected to provide the firtool binary
on the PATH, Chisel will now manage the firtool binary automatically.
Chisel users the following 3-step process for determining which binary
to use:

1. If environment variable FIRTOOL_PATH is set, it will check for
   firtool in that directory
2. It will check the classpath for firtool provided by
   chipsalliance/llvm-firtool
3. It will download a default version of chipsalliance/llvm-firtool

Both (2) and (3) will store the firtool binary in a sensible location
depending on the user's operating system. See dirs-dev/directories-jvm
for more information. The user can override this location by setting the
FIRTOOL_CACHE environment variable.

(cherry picked from commit 3938a46)

# Conflicts:
#	.github/workflows/build-scala-cli-template.yml
#	.github/workflows/ci.yml
#	.github/workflows/test.yml
#	build.sbt
#	build.sc
#	common.sc
#	project/plugins.sbt
#	src/main/scala/circt/stage/phases/CIRCT.scala
#	src/test/scala/chiselTests/LoadMemoryFromFileSpec.scala
#	src/test/scala/circtTests/stage/ChiselStageSpec.scala
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Modification Backported This PR has been backported
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants