Skip to content

Commit 980cc06

Browse files
committed
bazel: add local_arguments= to orfs_design() for make-only helpers
Some config.mk files declare exported helper variables (notably VERILOG_FILES_BLACKBOX in microwatt and chameleon) that are used only for $(VAR) expansion within the same config.mk and are never read by ORFS or by any user-supplied .tcl/.mk. They surfaced in bazel-orfs's parsed sources/arguments and tripped the variables.yaml validator. Patch 0002 adds local_arguments= to orfs_design(); listed vars are popped from both arguments and sources before orfs_flow() is called, so they neither get validated against variables.yaml nor leak into the per-stage environment. design() (flow/designs/design.bzl) forwards the kwarg. microwatt and chameleon now declare VERILOG_FILES_BLACKBOX in local_arguments. VERILOG_FILES_BLACKBOX is removed from variables.yaml (it was registered there only to silence the validator) and the generated variables.json / FlowVariables.md are regenerated. Drive-by: * add bazel/BUILD so //bazel:0001-...patch resolves (the patch label was referenced from MODULE.bazel but had no package definition). * move bazel-orfs.md under flow/ alongside the bazel rules it documents; update the pointer in MODULE.bazel. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 4912278 commit 980cc06

10 files changed

Lines changed: 73 additions & 25 deletions

File tree

MODULE.bazel

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ BAZEL_ORFS_REMOTE = "https://github.com/The-OpenROAD-Project/bazel-orfs.git"
4545
git_override(
4646
module_name = "bazel-orfs",
4747
commit = BAZEL_ORFS_COMMIT,
48-
patches = ["//bazel:0001-orfs_design-accept-config-mk-explicitly-drop-exports.patch"],
48+
patches = [
49+
"//bazel:0001-orfs_design-accept-config-mk-explicitly-drop-exports.patch",
50+
"//bazel:0002-orfs_design-add-local_arguments-to-drop-helper-vars.patch",
51+
],
4952
patch_strip = 1,
5053
remote = BAZEL_ORFS_REMOTE,
5154
)
@@ -112,7 +115,7 @@ use_repo(orfs, "gnumake")
112115
use_repo(orfs, "orfs_variable_metadata")
113116

114117
# Auto-generate orfs_flow() targets from config.mk files.
115-
# See bazel-orfs.md for usage.
118+
# See flow/bazel-orfs.md for usage.
116119
orfs_designs = use_repo_rule("@bazel-orfs//private:designs.bzl", "orfs_designs")
117120

118121
orfs_designs(
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
diff --git a/private/orfs_design.bzl b/private/orfs_design.bzl
2+
--- a/private/orfs_design.bzl
3+
+++ b/private/orfs_design.bzl
4+
@@ -47,7 +47,7 @@
5+
result[var] = converted
6+
return result
7+
8+
-def orfs_design(name = None, config = "config.mk", platform = None, design = None, designs = None, mock_openroad = None, mock_yosys = None, user_arguments = []): # buildifier: disable=unused-variable
9+
+def orfs_design(name = None, config = "config.mk", platform = None, design = None, designs = None, mock_openroad = None, mock_yosys = None, user_arguments = [], local_arguments = []): # buildifier: disable=unused-variable
10+
"""Create orfs_flow() targets for a design based on its parsed config.mk.
11+
12+
Usage:
13+
@@ -79,6 +79,12 @@
14+
Routed through orfs_flow(user_arguments=...) to bypass the
15+
variables.yaml validator instead of being checked as known
16+
ORFS arguments.
17+
+ local_arguments: List of variable names that are only used for
18+
+ $(VAR) expansion within the same config.mk and are not read
19+
+ by ORFS or by any user .tcl/.mk (e.g. VERILOG_FILES_BLACKBOX,
20+
+ which appears verbatim inside VERILOG_FILES). These are
21+
+ dropped entirely before orfs_flow() is invoked — neither
22+
+ validated against variables.yaml nor exposed as env vars.
23+
"""
24+
if designs == None:
25+
fail("orfs_design() requires designs: load orfs_design from @orfs_designs//:designs.bzl")
26+
@@ -172,6 +178,16 @@
27+
# Real flow — uses Docker image with real OpenROAD/Yosys
28+
arguments = dict(config["arguments"])
29+
30+
+ # Drop caller-flagged local helper vars used only via $(VAR)
31+
+ # expansion within the same config.mk (e.g. VERILOG_FILES_BLACKBOX).
32+
+ # They must not reach orfs_flow — they would either fail validation
33+
+ # or be exposed as noise env vars. The config.mk parser may classify
34+
+ # such helpers as either arguments or sources (e.g. when they expand
35+
+ # to file globs), so drop from both.
36+
+ for var in local_arguments:
37+
+ arguments.pop(var, None)
38+
+ sources.pop(var, None)
39+
+
40+
# Move caller-flagged design-specific knobs out of arguments and into
41+
# user_arguments so they bypass the variables.yaml validator.
42+
user_args = {}

bazel/BUILD

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

docs/user/FlowVariables.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,6 @@ configuration file.
324324
| <a name="USE_NEGOTIATION"></a>USE_NEGOTIATION| Enable using negotiation legalizer for detailed placement.| 0|
325325
| <a name="VERILOG_DEFINES"></a>VERILOG_DEFINES| Preprocessor defines passed to the language frontend. Example: `-D HPDCACHE_ASSERT_OFF`| |
326326
| <a name="VERILOG_FILES"></a>VERILOG_FILES| The path to the design Verilog/SystemVerilog files providing a description of modules.| |
327-
| <a name="VERILOG_FILES_BLACKBOX"></a>VERILOG_FILES_BLACKBOX| Verilog files (typically `IPs/*.v`) that are appended to VERILOG_FILES in hierarchical designs and treated as blackbox modules by yosys. Only used by config.mk; ORFS doesn't read it as an env var.| |
328327
| <a name="VERILOG_INCLUDE_DIRS"></a>VERILOG_INCLUDE_DIRS| Specifies the include directories for the Verilog input files.| |
329328
| <a name="VERILOG_TOP_PARAMS"></a>VERILOG_TOP_PARAMS| Apply toplevel params (if exist). Passed in as a list of key value pairs in tcl syntax; separated by spaces: PARAM1 VALUE1 PARAM2 VALUE2| |
330329
| <a name="VIA_IN_PIN_MAX_LAYER"></a>VIA_IN_PIN_MAX_LAYER| Passed as -via_in_pin_top_layer to pin_access and detailed_route.| |
@@ -377,7 +376,6 @@ configuration file.
377376
- [UNSET_ABC9_BOX_CELLS](#UNSET_ABC9_BOX_CELLS)
378377
- [VERILOG_DEFINES](#VERILOG_DEFINES)
379378
- [VERILOG_FILES](#VERILOG_FILES)
380-
- [VERILOG_FILES_BLACKBOX](#VERILOG_FILES_BLACKBOX)
381379
- [VERILOG_INCLUDE_DIRS](#VERILOG_INCLUDE_DIRS)
382380
- [VERILOG_TOP_PARAMS](#VERILOG_TOP_PARAMS)
383381
- [YOSYS_FLAGS](#YOSYS_FLAGS)
File renamed without changes.

flow/designs/design.bzl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,24 @@ _GROUPS = {
1313
"gds": ["gds", "gds.gz"],
1414
}
1515

16-
def design(config = "config.mk", user_arguments = []):
16+
def design(config = "config.mk", user_arguments = [], local_arguments = []):
1717
"""Standard BUILD body for flow/designs/<platform>/<design>/.
1818
1919
Args:
2020
config: The config.mk file that drives this design.
2121
user_arguments: see orfs_design — list of config.mk var names that
2222
are project-specific (read by the design's own .tcl/.mk, not by
2323
ORFS) and should bypass the variables.yaml validator.
24+
local_arguments: see orfs_design — list of config.mk var names that
25+
are pure make-only helpers (used only via $(VAR) expansion
26+
within the same config.mk, never read by ORFS or by user
27+
.tcl/.mk). Dropped entirely before orfs_flow() is invoked.
2428
"""
25-
orfs_design(config = config, user_arguments = user_arguments)
29+
orfs_design(
30+
config = config,
31+
user_arguments = user_arguments,
32+
local_arguments = local_arguments,
33+
)
2634

2735
def files(group, extra_srcs = None):
2836
"""Named filegroup over conventional extensions."""

flow/designs/sky130hd/chameleon/BUILD

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,14 @@ load("//flow/designs:design.bzl", "design")
33
# FP_PDN_RAIL_{OFFSET,WIDTH} are read by chameleon's own pdn.cfg, not
44
# by ORFS itself — route them through user_arguments so the validator
55
# doesn't reject them as unknown ORFS variables.
6-
design(config = "config.mk", user_arguments = [
7-
"FP_PDN_RAIL_OFFSET",
8-
"FP_PDN_RAIL_WIDTH",
9-
])
6+
#
7+
# VERILOG_FILES_BLACKBOX is a config.mk-local helper: only used via
8+
# $(VERILOG_FILES_BLACKBOX) expansion inside VERILOG_FILES.
9+
design(
10+
config = "config.mk",
11+
user_arguments = [
12+
"FP_PDN_RAIL_OFFSET",
13+
"FP_PDN_RAIL_WIDTH",
14+
],
15+
local_arguments = ["VERILOG_FILES_BLACKBOX"],
16+
)
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
load("//flow/designs:design.bzl", "design")
22

3-
design(config = "config.mk")
3+
# VERILOG_FILES_BLACKBOX is a config.mk-local helper: only used via
4+
# $(VERILOG_FILES_BLACKBOX) expansion inside VERILOG_FILES. Not read by
5+
# ORFS or by any user .tcl/.mk — drop it so it never reaches orfs_flow.
6+
design(config = "config.mk", local_arguments = ["VERILOG_FILES_BLACKBOX"])

flow/scripts/variables.json

Lines changed: 0 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flow/scripts/variables.yaml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,11 +1585,3 @@ CDL_FILE:
15851585
for generating Circuit Description Language output.
15861586
stages:
15871587
- final
1588-
VERILOG_FILES_BLACKBOX:
1589-
description: >
1590-
Verilog files (typically `IPs/*.v`) that are appended to
1591-
VERILOG_FILES in hierarchical designs and treated as blackbox
1592-
modules by yosys. Only used by config.mk; ORFS doesn't read it as
1593-
an env var.
1594-
stages:
1595-
- synth

0 commit comments

Comments
 (0)