Skip to content

Commit 3cbfbde

Browse files
committed
deps: pin yosys 0.63 + carry bazel-orfs BLOCKS shared-block.mk patch
Two coupled MODULE.bazel changes: 1. single_version_override(yosys = "0.63"). bazel-orfs pins yosys 0.62.bcr.2, which has a KOGGE_STONE / BRENT_KUNG IdString memory-safety bug that crashes synth on a few asap7 designs. 0.63 is on canonical BCR; drop this override once bazel-orfs itself bumps to 0.63. 2. git_override(patches = [.../0001-blocks-shared-blockmk.patch]) on the bazel-orfs dep. bazel-orfs's BLOCKS handling only walks per-block sub-directory configs (<design>/<block>/config.mk). Make's flow/Makefile GENERATE_ABSTRACT_RULE has a second branch: when there's no per-block config.mk, fall back to a shared block.mk parameterised by DESIGN_NAME=<block> and DESIGN_NICKNAME=<parent>_<block>. flow/designs/asap7/aes-block is the canonical example: it sets BLOCKS=aes_rcon aes_sbox but the blocks share aes-block/block.mk rather than each owning a sub-dir config. Before this patch the parser recorded result.blocks but left result.block_configs empty; designs.bzl then never added asap7/aes-block_aes_rcon / asap7/aes-block_aes_sbox entries to DESIGNS; _create_block_targets looked them up by composite key, got None, and silently skipped. The parent's synth_odb action ran without the sub-block .lef/.lib abstracts and the resulting .odb omitted the two abstract cells (bazel's 1_synth.odb header byte at offset 16 = 212 cells vs make's 214). Patch carried locally; will be upstreamed. Two changes: - config_mk_parser.parse() takes an overrides= arg that pins DESIGN_NAME / DESIGN_NICKNAME after file parsing. BLOCKS post-processing falls back to shared block.mk and calls parse() with the appropriate overrides. - _path_to_label strips a leading "./" before label conversion so block.mk-style relative paths (e.g. ./designs/asap7/aes/constraint.sdc) don't become malformed labels (//./designs/asap7/aes:foo.sdc). Verified on asap7/aes-block: bazel's 1_synth.odb cell-count byte now matches make's (0xd6 = 214) — sub-block abstracts are read into the parent synth_odb action. MODULE.bazel.lock reflects the yosys 0.62.bcr.2 → 0.63 swap; no other modules move. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 30ae277 commit 3cbfbde

4 files changed

Lines changed: 139 additions & 4 deletions

File tree

MODULE.bazel

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,15 @@ module(
1010
bazel_dep(name = "rules_python", version = "1.8.5")
1111
bazel_dep(name = "rules_shell", version = "0.6.1")
1212

13+
# Override bazel-orfs's yosys 0.62.bcr.2 pin to 0.63 — 0.62 has a
14+
# KOGGE_STONE / BRENT_KUNG IdString memory-safety bug that breaks synth
15+
# on a few asap7 designs. 0.63 is on BCR; remove this once bazel-orfs
16+
# itself bumps to 0.63.
17+
single_version_override(
18+
module_name = "yosys",
19+
version = "0.63",
20+
)
21+
1322
# --- Dev dependencies (only honoured when @orfs is the root module) ---
1423
#
1524
# When @orfs is consumed as a non-root dep (e.g. by tools/OpenROAD), the
@@ -20,7 +29,6 @@ bazel_dep(name = "rules_shell", version = "0.6.1")
2029
# time.
2130

2231
bazel_dep(name = "toolchains_llvm", version = "1.5.0", dev_dependency = True)
23-
2432
bazel_dep(name = "openroad", dev_dependency = True)
2533
local_path_override(
2634
module_name = "openroad",
@@ -45,6 +53,10 @@ BAZEL_ORFS_REMOTE = "https://github.com/The-OpenROAD-Project/bazel-orfs.git"
4553
git_override(
4654
module_name = "bazel-orfs",
4755
commit = BAZEL_ORFS_COMMIT,
56+
patch_strip = 1,
57+
patches = [
58+
"//bazel/bazel-orfs-patches:0001-blocks-shared-blockmk.patch",
59+
],
4860
remote = BAZEL_ORFS_REMOTE,
4961
)
5062

@@ -79,7 +91,10 @@ llvm.toolchain(
7991
)
8092
use_repo(llvm, "llvm_toolchain")
8193

82-
register_toolchains("@llvm_toolchain//:all", dev_dependency = True)
94+
register_toolchains(
95+
"@llvm_toolchain//:all",
96+
dev_dependency = True,
97+
)
8398

8499
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
85100
python.toolchain(

MODULE.bazel.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?=C3=98yvind=20Harboe?= <oyvind@ascenium.com>
3+
Date: Wed, 14 May 2026 12:00:00 +0200
4+
Subject: [PATCH] config_mk_parser: handle shared block.mk for BLOCKS=
5+
6+
bazel-orfs's BLOCKS handling only walks per-block sub-directory
7+
configs (`<design>/<block>/config.mk`). Make's flow/Makefile
8+
GENERATE_ABSTRACT_RULE has a second branch: when there is no per-block
9+
config.mk, fall back to a shared `block.mk` parameterised by
10+
DESIGN_NAME=<block> and DESIGN_NICKNAME=<parent>_<block>.
11+
12+
`flow/designs/asap7/aes-block` is the canonical example: it sets
13+
`BLOCKS=aes_rcon aes_sbox` but the blocks share `aes-block/block.mk`
14+
rather than each owning a sub-dir config. Today the parser records
15+
`result.blocks = ["aes_rcon", "aes_sbox"]` but leaves
16+
`result.block_configs` empty; the `orfs_designs` repo rule then never
17+
adds `asap7/aes-block_aes_rcon` / `..._aes_sbox` entries to DESIGNS;
18+
`_create_block_targets` looks them up by composite key, gets `None`,
19+
and silently skips. The parent's synth_odb action then runs without
20+
the sub-block .lef/.lib abstracts and the resulting .odb omits the two
21+
abstract cells (bazel's 1_synth.odb header byte at offset 16 = 212
22+
cells vs make's 214).
23+
24+
Mirror the make-side fallback in the parser:
25+
26+
- Add an `overrides=` arg to parse() that pins DESIGN_NAME and
27+
DESIGN_NICKNAME after file parsing finishes.
28+
- In the BLOCKS post-processing, fall back to shared block.mk when
29+
no per-block sub-dir config exists.
30+
- Normalize leading "./" in _path_to_label so block.mk-style relative
31+
paths like `./designs/asap7/aes/constraint.sdc` don't become
32+
malformed labels (`//./designs/asap7/aes:constraint.sdc`).
33+
34+
`private/designs.bzl` already promotes each block_config to a DESIGNS
35+
entry keyed by `<platform>/<design_nickname>`, so once the parser
36+
populates block_configs the rest of the wiring works.
37+
38+
Signed-off-by: =?UTF-8?q?=C3=98yvind=20Harboe?= <oyvind@ascenium.com>
39+
---
40+
config_mk_parser.py | 47 ++++++++++++++++++++++++++++++++++++++++++++-
41+
1 file changed, 46 insertions(+), 1 deletion(-)
42+
43+
--- a/config_mk_parser.py
44+
+++ b/config_mk_parser.py
45+
@@ -156,7 +156,7 @@
46+
self.designs_home = designs_home
47+
self.flow_home = flow_home
48+
49+
- def parse(self, config_path, base_dir=None):
50+
+ def parse(self, config_path, base_dir=None, overrides=None):
51+
"""Parse a config.mk file and return a ParsedDesign.
52+
53+
Args:
54+
@@ -221,6 +221,16 @@
55+
elif result.design_name:
56+
result.design_nickname = result.design_name
57+
58+
+ # Apply caller-supplied overrides to structural vars. Used by
59+
+ # the shared-block.mk BLOCKS path below to parameterise the
60+
+ # same block.mk for each entry of BLOCKS=, mirroring make's
61+
+ # flow/Makefile GENERATE_ABSTRACT_RULE second branch.
62+
+ if overrides:
63+
+ if "DESIGN_NAME" in overrides:
64+
+ result.design_name = overrides["DESIGN_NAME"]
65+
+ if "DESIGN_NICKNAME" in overrides:
66+
+ result.design_nickname = overrides["DESIGN_NICKNAME"]
67+
+
68+
# Check structural vars for deprecated patterns
69+
for var_name in ("DESIGN_NICKNAME", "DESIGN_NAME", "PLATFORM"):
70+
if var_name in raw_vars:
71+
@@ -277,14 +287,34 @@
72+
elif var_name not in NON_ARGUMENT_VARS:
73+
result.arguments[var_name] = resolved
74+
75+
- # Process BLOCKS — discover and parse sub-macro configs
76+
+ # Process BLOCKS — discover and parse sub-macro configs.
77+
if result.blocks:
78+
config_dir = os.path.dirname(config_path)
79+
+ shared_block_mk = os.path.join(config_dir, "block.mk")
80+
for block_name in result.blocks:
81+
+ # Path 1: per-block config.mk in a sub-directory.
82+
block_config = os.path.join(config_dir, block_name, "config.mk")
83+
if os.path.exists(block_config):
84+
block_parsed = self.parse(block_config)
85+
result.block_configs.append(block_parsed)
86+
+ continue
87+
+ # Path 2: shared block.mk parameterised by DESIGN_NAME.
88+
+ # Matches make's flow/Makefile GENERATE_ABSTRACT_RULE
89+
+ # second branch:
90+
+ # $(MAKE) DESIGN_NAME=<block> \
91+
+ # DESIGN_NICKNAME=<parent>_<block> \
92+
+ # DESIGN_CONFIG=<parent_dir>/block.mk \
93+
+ # generate_abstract
94+
+ if os.path.exists(shared_block_mk):
95+
+ block_parsed = self.parse(
96+
+ shared_block_mk,
97+
+ overrides={
98+
+ "DESIGN_NAME": block_name,
99+
+ "DESIGN_NICKNAME":
100+
+ f"{result.design_nickname}_{block_name}",
101+
+ },
102+
+ )
103+
+ result.block_configs.append(block_parsed)
104+
105+
return result
106+
107+
@@ -812,6 +842,12 @@
108+
if not path:
109+
return path
110+
111+
+ # Normalize leading "./" — block.mk-style relative paths
112+
+ # (e.g. ./designs/asap7/aes/constraint.sdc). Without this
113+
+ # they become malformed labels like //./designs/asap7/aes:foo.
114+
+ while path.startswith("./"):
115+
+ path = path[2:]
116+
+
117+
# Already a label
118+
if path.startswith("//") or path.startswith("@"):
119+
return path

bazel/bazel-orfs-patches/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
exports_files(glob(["*.patch"]))

0 commit comments

Comments
 (0)