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

Add support for bzlmod #27

Merged
merged 9 commits into from
Dec 11, 2024
Merged

Add support for bzlmod #27

merged 9 commits into from
Dec 11, 2024

Conversation

jwnrt
Copy link
Contributor

@jwnrt jwnrt commented Jul 9, 2024

Summary

This PR does some general cleaning to prepare for and then enable bzlmod support.

WORKSPACE support has been removed to reduce maintenance burden and complexity.

Best reviewed by commit.

Details

The full changes are:

  • CI workflow added to build the firmware in PRs.
  • bazel-release dependency removed, GitHub CLI used directly.
  • crt dependency swapped for toolchains_arm_gnu which supports bzlmod.
  • BUILD files cleaned up with some indirection and hacks removed.
  • WORKSPACE files and infrastructure removed.

Testing

Tested the deployment in my fork here: https://github.com/jwnrt/hyperdebug-firmware/actions/runs/9853140349

Created this release: https://github.com/jwnrt/hyperdebug-firmware/releases/tag/20240709_01

I've tested the release on our FPGA board by running a few tests that go through HyperDebug.

run: |
git tag ${{ inputs.release_tag }}
bazel build --stamp :release
Copy link

Choose a reason for hiding this comment

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

I don't necessarily have a strong opinion but I can see an advantage to using bazel-release in theory: the release process is part of the build and can be done locally easily. Github/Azure flows are always notorioulsy bad for local reproducibility as they get more complicated.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That makes sense.

I have this PR for adding bzlmod support to bazel-release: lowRISC/bazel-release#5

If that's merged, we could go back to using it.

@jwnrt
Copy link
Contributor Author

jwnrt commented Jul 9, 2024

@jesultra this PR changes the toolchain (still GNU ARM) from the one provided by CRT to the one provided by https://github.com/hexdae/toolchains_arm_gnu which I believe is more up to date and generates a different binary.

This is mainly because I couldn't port CRT to bzlmod very easily.

I've tested the binary on our HyperDebug in the office, but wanted to get your opinion on changing the toolchain here.

Copy link

@pamaury pamaury left a comment

Choose a reason for hiding this comment

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

Overall this looks to me though I am no blzmod-expert.

@jesultra
Copy link
Collaborator

@jesultra this PR changes the toolchain (still GNU ARM) from the one provided by CRT to the one provided by https://github.com/hexdae/toolchains_arm_gnu which I believe is more up to date and generates a different binary.

This project already uses a different toolchain than the one found in ChromeOS "chroot" build environment, meaning that when I do local modifications to the source in platform/ec, and build without using this repository, the resulting binary may behave differently than the official one through this release process. One time recently, timing or optimization differences let to a bug not being detected when I compiled locally.

What I am saying is that I do not mind at all the toolchain being changed, and furthermore, if in the process we could make it easier to run the same build process locally, and even with modifications to the source code, then that would be a welcome bonus.

Copy link
Collaborator

@jesultra jesultra left a comment

Choose a reason for hiding this comment

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

It seems that after upgrading to Bazel 8, I am no longer able to compile pre-built binaries by running an "Action" on this repository. I believe this PR is key to a solution.

@jwnrt Please let me know if I can assist in any way. I have a HyperDebug firmware bugfix, that I would like to publish.

third_party/chromium/BUILD.bazel Outdated Show resolved Hide resolved
Builds the HyperDebug firmware for pull requests.

Signed-off-by: James Wainwright <[email protected]>
I don't think this was adding anything over using the GitHub CLI
directly.

Signed-off-by: James Wainwright <[email protected]>
Signed-off-by: James Wainwright <[email protected]>
Signed-off-by: James Wainwright <[email protected]>
Signed-off-by: James Wainwright <[email protected]>
Major version changes to Bazel could break this repository. Pinning
ensures Bazelisk (if used) uses a known-working version of Bazel
automatically.
Signed-off-by: James Wainwright <[email protected]>
Signed-off-by: James Wainwright <[email protected]>
This reduces maintenence burden.

The ARM toolchain was not working entirely correctly in the `WORKSPACE`
configuration either for unknown reasons.

Signed-off-by: James Wainwright <[email protected]>
@jwnrt
Copy link
Contributor Author

jwnrt commented Dec 11, 2024

I've rebased to fix that conflict and it seems to build fine. I don't have much time to test it right now but I'm happy for you to merge this if it's working.

It seems that after upgrading to Bazel 8, I am no longer able to compile pre-built binaries by running an "Action" on this repository. I believe this PR is key to a solution.

Ah, Bazel 8 no longer supports the WORKSPACE this repo currently uses. We can try get the action to go back to Bazel 7 or add the --enable_workspace flag if this PR doesn't work out.

@jesultra
Copy link
Collaborator

jesultra commented Dec 11, 2024

With this PR, I am able to run bazel build :hyperdebug-firmware locally, and the generated ec.bin runs on my HyperDebug, so I have high confidence that once this has merged, the GitHub action will also work.

Thank you very much for resolving this issue for me quickly.

@jesultra jesultra merged commit adb2e4f into lowRISC:main Dec 11, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants