Skip to content

extension: add yosys_plugins attribute to orfs.default()#712

Merged
oharboe merged 1 commit into
mainfrom
yosys-plugins-attr
May 1, 2026
Merged

extension: add yosys_plugins attribute to orfs.default()#712
oharboe merged 1 commit into
mainfrom
yosys-plugins-attr

Conversation

@oharboe
Copy link
Copy Markdown
Collaborator

@oharboe oharboe commented May 1, 2026

Summary

Lets consumers expose out-of-tree yosys plugins (e.g. yosys-slang) without having to materialize a custom merged `yosys_share` tree.

  • New `yosys_plugins` attribute on `orfs.default()` (extension.bzl)
  • Plumbed through `global_config` as `CONFIG_YOSYS_PLUGINS` (config.bzl)
  • New `_yosys_plugins` private attr on yosys-using rules (private/attrs.bzl)
  • `yosys_environment` now sets `YOSYS_PLUGIN_PATH` from plugin dirnames; `yosys_inputs` includes the plugin files (private/environment.bzl)
  • Old single-tree-artifact `yosys_share` path preserved as a fallback when no plugins are specified — existing consumers (including `test/downstream/`) keep working unchanged.

Motivation

OpenROAD's PR The-OpenROAD-Project/OpenROAD#10237 carries a custom `merge_yosys_share` rule that materializes a TreeArtifact merging `@yosys//:yosys_share` with a locally-built `slang.so`. @hzeller flagged it as fragile (manual `/bin/bash` shell-out, breaks on NixOS) and asked for the `pkg_files` pattern. `pkg_files` doesn't fit because bazel-orfs requires a TreeArtifact for `yosys_share` — but accepting plugins as a separate label_list sidesteps the merge entirely.

With this change, OpenROAD's `orfs.default()` becomes:
```python
orfs.default(
openroad = "//:openroad",
yosys_plugins = ["@yosys-slang//src/yosys_plugin:slang.so"],
)
```
and `bazel/merge_share.bzl` + `//:yosys_share_with_slang` are deleted.

Test plan

  • Verified end-to-end against OpenROAD#10237: `bazelisk build //:openroad` clean, all 19 `//test/orfs/...` tests pass.
  • CI green (this repo).

Lets consumers expose out-of-tree yosys plugins (e.g. yosys-slang)
without having to materialize a custom yosys_share tree.

bazel-orfs now derives YOSYS_PLUGIN_PATH from the dirnames of the
plugin files passed via `yosys_plugins`, and adds them to the input
set of yosys actions. The old single-tree-artifact yosys_share path
is preserved as a fallback when no plugins are specified, so
existing consumers (including downstream/test) keep working.

Tested via The-OpenROAD-Project/OpenROAD#10237 (ditch-docker):
- bazelisk build //:openroad clean
- bazelisk test //test/orfs/... -- all 19 tests pass
- merge_yosys_share custom rule removed in OpenROAD; orfs.default()
  uses yosys_plugins = ["@yosys-slang//src/yosys_plugin:slang.so"]

Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
@oharboe oharboe merged commit f884756 into main May 1, 2026
1 check passed
@oharboe oharboe deleted the yosys-plugins-attr branch May 1, 2026 11:26
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.

1 participant