Skip to content

Migrate to Bzlmod#428

Closed
MrAMS wants to merge 45 commits into
hdl:mainfrom
MrAMS:bzl-module
Closed

Migrate to Bzlmod#428
MrAMS wants to merge 45 commits into
hdl:mainfrom
MrAMS:bzl-module

Conversation

@MrAMS

@MrAMS MrAMS commented Dec 11, 2025

Copy link
Copy Markdown
Contributor

Description:

This PR introduces Bzlmod support to the project. It builds mainly upon the groundwork laid by @lromor in this comment.

Changes:

  • Rebased @lromor's attempt against the latest main branch.
  • Fixed several bugs encountered after the merge.
  • Verified compatibility with a minimal working example.

Verification:
I have validated the changes using my minimal working project (specifically, see rules_hdl_overrides.MODULE.bazel).

The following rules have been tested and verified to work, covering Verilator simulation, Yosys synthesize and the OpenROAD full EDA flow:

  • verilog_library
  • verilator_cc_library
  • synthesize_rtl
  • place_and_route
  • gds_write

Given the long-standing discussions(issue#336, issue#332, issue#210, pull#405) regarding this migration since 2023, I believe now is the right time to move forward with Bzlmod.

ericastor and others added 30 commits December 10, 2025 19:12
These flags enable seeded synthesis runs, allowing users to introduce controlled variability to help explore the space of valid solutions.
Adds the copyright header & default license
Conflicts: verilator/settings/BUILD.bazel
Conflicts:
	dependency_support/edu_berkeley_abc/bundled.BUILD.bazel
Conflicts:
	dependency_support/edu_berkeley_abc/bundled.BUILD.bazel
…#395)

* Add missing genrule to com_github_ivmai_cudd/bundled.BUILD.bazel

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>

* add build_test to cudd

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>

* rm build_test from cudd

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>

* correct package name in com_github_ivmai_cudd.bzl comments

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>

* make cudd libraries public visibility

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>

---------

Signed-off-by: Matt Liberty <mliberty@precisioninno.com>
Conflicts:
	dependency_support/edu_berkeley_abc/bundled.BUILD.bazel
Using archive links from github is dangerous as they can change
any time, as they build them on-the-fly, so hashing the file
can create unstable hashes:

https://github.blog/open-source/git/update-on-the-future-stability-of-source-code-archives-and-hashes/

(Unlike for instance nix, bazel does not hash the content of a tar but
the binary tar.gz itself, so it is prone to run into the issue)

Fix that by using another source that is providing the tar.gz itself,
so is stable.

Note: this will change this dependency from `@com_github_ivmai_cudd`
to `@com_github_davidkebo_cudd`
Conflicts:
	.gitignore
	MODULE.bazel
Conflicts:
	.bazelversion
	extensions.bzl
@MrAMS

MrAMS commented Dec 13, 2025

Copy link
Copy Markdown
Contributor Author

Note: OpenROAD depends on lemon, ncurses, abc, and swig. We need to wait for their upstream PRs to be merged first.

@whitequark

Copy link
Copy Markdown

Please do not spam YosysHQ projects with your build system PRs. They are not welcome and it is not appropriate to even send that many PRs without first asking the upstream project if they're interested in the maintenance burden of another build system.

@MrAMS

MrAMS commented Dec 13, 2025

Copy link
Copy Markdown
Contributor Author

Hi @whitequark ,
I sincerely apologize for the disruption and the volume of PRs. I understand that introducing an additional build system imposes a maintenance burden that the project does not wish to take on.

I should have opened an issue to discuss this beforehand instead of sending multiple PRs directly. I respect your decision and will close these PRs immediately.

Thank you for your work on YosysHQ.

@whitequark

Copy link
Copy Markdown

Thanks.

@MrAMS

MrAMS commented Dec 13, 2025

Copy link
Copy Markdown
Contributor Author

@mikesinouye Given the reaction from the community, maintaining a separate fork seems to be the better choice. I plan to set up a CI pipeline to automatically merge changes from upstream on a monthly basis, as relying on patches would introduce too much maintenance overhead for me.

@lromor

lromor commented Dec 13, 2025

Copy link
Copy Markdown

@MrAMS have a look at this discussion:
The-OpenROAD-Project/OpenROAD#7647

OpenROAD people seemed interested in the work I did. It would be amazing if you could continue there.
Ideally we could create a separate bazel registry that people can overlay with just patches, and then slowly merge those in the upstream bcr. This is the best approach I can think of.

If you feel like collaborating more, please let me know your preferred means of communication or just reach out.

@maliberty

Copy link
Copy Markdown
Contributor

OpenROAD is slowly converting to having bazel be our main and eventually only build system.

@MrAMS

MrAMS commented Dec 13, 2025

Copy link
Copy Markdown
Contributor Author

Hi @lromor @maliberty
Since I'm still familiarizing myself with the open-source contribution workflow, I've decided to focus on maintaining my own fork for now. However, feel free to check out this branch: MrAMS/OpenROAD#bzlmodify-upstream-merge. I've updated openroad to the latest upstream version, and verified that all tests are passing.

@MrAMS

MrAMS commented Dec 14, 2025

Copy link
Copy Markdown
Contributor Author

Here is a summary of my recent progress:

  • OpenROAD: I have merged the bzlmod-supported OpenROAD with the latest upstream changes and resolved numerous issues. You can check it out here.
  • bazel_rules_hdl: I updated this to ensure compatibility with the latest OpenROAD and fixed several related bugs. The branch is here.
  • Dependencies: I synchronized almost all dependencies to their latest upstream versions. In particular, I addressed multiple issues regarding the swig integration.
  • CI Workflow: I added a new CI workflow to bazel_rules_hdl. Since git_override can be quite slow and hard to reproduce, the CI now automatically generates an archive_override package on every push. You can see an example release here. (optional, original code use git_override)
  • Verification: Finally, I updated my minimal working project and verified that all tests are currently RTL CI

@UebelAndre

UebelAndre commented Dec 15, 2025

Copy link
Copy Markdown
Contributor

Hey, I noticed a number of PRs to BCR and am kinda confused.

For these:

It looks like you're pointing to your private repo as the source of truth for builds? Also usurping ownership? The current state of those PRs makes me concerned so can you explain how they were generated and provide more context on the direction?

@MrAMS

MrAMS commented Dec 15, 2025

Copy link
Copy Markdown
Contributor Author

Hi @UebelAndre ,
Thank you very much for your review. Please forgive me if I have offended you in any way—I’m still not very familiar with the open-source contribution process for Bazel. Feel free to close any PRs from me that you find inappropriate, and I would be happy to hear any specific improvement suggestions from you.

My forked repository will automatically pull and attempt to merge the latest upstream changes via CI every month. If upstream changes are detected and merged successfully, the CI will automatically submit a BCR update PR. You can check the CI status of these repositories. If you still think this approach is inappropriate, feel free to refuse to merge and close these PRs.

@MrAMS

MrAMS commented Dec 15, 2025

Copy link
Copy Markdown
Contributor Author

Additionally, I have now decided not to continue trying to migrate rules_hdl to Bzlmod or publish it to BCR. After discussing with the open-source community, I found that rules_hdl is inconsistent with the minimal modularity concept of Bzlmod. I will focus on making further contributions to OpenROAD, bazel-orfs and rules_verilator in the future, so feel free to close this migration PR as well.

Thank you again for your patience and guidance, as I’m still new to open-source contributions.

@UebelAndre

Copy link
Copy Markdown
Contributor

Hi @UebelAndre , Thank you very much for your review. Please forgive me if I have offended you in any way—I’m still not very familiar with the open-source contribution process for Bazel. Feel free to close any PRs from me that you find inappropriate, and I would be happy to hear any specific improvement suggestions from you.

My forked repository will automatically pull and attempt to merge the latest upstream changes via CI every month. If upstream changes are detected and merged successfully, the CI will automatically submit a BCR update PR. You can check the CI status of these repositories. If you still think this approach is inappropriate, feel free to refuse to merge and close these PRs.

Thanks! I'm not offended, just alarmed for security reasons by a bunch of changes that moved sources to private repos. I think contributing to OpenROAD would be great and to eventually see The-OpenROAD-Project/OpenROAD#8828 implemented. Thank you for all your work!

@stridge-tnp

Copy link
Copy Markdown
Contributor

Just to clarify as i was confused initially. These are the deps referred to above that are patched/modified versions that are not yet available in bcr. Adding the following to my MODULE.bazel worked:

git_override(
    module_name = "p7zip",
    commit = "be778d8e29b3f21bd3b0c661be0d4f4ab49d3ffa",
    remote = "https://github.com/amorphic-io/7zip.git",
)

git_override(
    module_name = "prjtrellis",
    commit = "3332d029295a8e424969126f5c61a5ea111882a8",
    remote = "https://github.com/amorphic-io/prjtrellis.git",
)

git_override(
    module_name = "icestorm",
    commit = "85fd1682b58581b82d1d14f63c089fb033177c21",
    remote = "https://github.com/amorphic-io/icestorm.git",
)

git_override(
    module_name = "nextpnr",
    commit = "2ab1f5e7e6be52e2a59347cace86f5c16348a115",
    remote = "https://github.com/amorphic-io/nextpnr.git",
)

git_override(
    module_name = "cxxopts",
    commit = "0fc4bdab71ea25e3623e2b609b4e5b2bd20bb938",
    remote = "https://github.com/amorphic-io/cxxopts.git",
)

git_override(
    module_name = "yosys",
    commit = "590ad236368e41af3de4ea8252811beeaadb5f97",
    init_submodules = True,
    remote = "https://github.com/amorphic-io/yosys.git",
)

git_override(
    module_name = "swig",
    commit = "52ed25274e9042611bda40c42e48aae8b6748686",
    remote = "https://github.com/amorphic-io/swig.git",
)

git_override(
    module_name = "iverilog",
    commit = "760dfa28d8f863164a2fbbaabebd1202850249c8",
    remote = "https://github.com/amorphic-io/iverilog.git",
)

git_override(
    module_name = "lemon",
    commit = "f8be7b96fbdfa789a4dae0429967b7724e89d5f5",
    remote = "https://github.com/amorphic-io/lemon",
)

git_override(
    module_name = "abc",
    commit = "2fa8f6e551a85da586fbe01792e6cfdaa7ce72cc",
    remote = "https://github.com/amorphic-io/abc",
)

git_override(
    module_name = "ncurses",
    commit = "f918fafc9f7aeb1745d02e7978597abf8e580de2",
    remote = "https://github.com/amorphic-io/ncurses",
)

git_override(
    module_name = "llvm-project",
    commit = "93c4a9c7b9d2fef50ad97c80efa54ccaed7df0c8",
    remote = "https://github.com/amorphic-io/llvm-project",
)

git_override(
    module_name = "tcl",
    commit = "e285aca41d39e84ab1753f125b095d65a0e15640",
    remote = "https://github.com/amorphic-io/tcl.git",
)

git_override(
    module_name = "openroad",
    commit = "c80e4b3f54dd94cdbebfecc3c98a64049b8c7efc",
    init_submodules = True,
    remote = "https://github.com/amorphic-io/OpenROAD",
)

git_override(
    module_name = "bazel-orfs",
    commit = "126765508161956f8f82ae169084da0235230637",
    remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
)

Also @MrAMS I agree with the modularity argument, but i think bazel_rules_hdl should still collect/aggregate it all. For example the verilator block you have done as standalone is nice and bazel_rules_hdl should depend on it instead of having a parallel implementation. The rules hdl idea with bazel was essential with the WORKSPACE as dependencies were a nightmare, but perhaps splitting sections off into separate repos makes sense now?

Before BCR it was very hard to discover repos/projects. Thoughts from maintainers? @UebelAndre @QuantamHD

@MrAMS

MrAMS commented Jan 28, 2026

Copy link
Copy Markdown
Contributor Author

@stridge-tnp For new projects, it is highly recommended to use MODULE.bazel (Bzlmod) instead of WORKSPACE. I personally suggest checking out bazel-orfs as a reference.

@stridge-tnp

Copy link
Copy Markdown
Contributor

@stridge-tnp For new projects, it is highly recommended to use MODULE.bazel (Bzlmod) instead of WORKSPACE. I personally suggest checking out bazel-orfs as a reference.

Yeah, I have been using my draft pr for bazel 8.

I was just suggesting that with the transition to bazel 8 I think there is still a place for rules HDL but maybe it should be structured differently.

@MrAMS

MrAMS commented Feb 10, 2026

Copy link
Copy Markdown
Contributor Author

For anyone interested in the Chisel support within rules_hdl, I’ve published a BCR package called rules_chisel as a Bzlmod-native alternative.

@MrAMS

MrAMS commented Mar 9, 2026

Copy link
Copy Markdown
Contributor Author

For anyone interested in the verilog_library support within rules_hdl, I’ve published a BCR package called rules_verilog as a Bzlmod-native alternative.

@mikesinouye

Copy link
Copy Markdown
Collaborator

Superseded by #430

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.