-
Notifications
You must be signed in to change notification settings - Fork 484
Bazel orfs update #4229
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
Merged
maliberty
merged 10 commits into
The-OpenROAD-Project:master
from
oharboe:bazel-orfs-update
May 14, 2026
Merged
Bazel orfs update #4229
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a8a4733
flow: declare LIB_MODEL + MIN_CLK_ROUTING_LAYER + SDC_FILE_EXTRA
oharboe a655249
designs/mock-alu: declare MOCK_ALU_{WIDTH,OPERATIONS} as user_arguments
oharboe fd25207
flow/designs: exports_files() for cross-package source references
oharboe 4014255
flow: exports_files for platform + cva6 cross-package source labels
oharboe 24acdb3
flow: log synthesized-netlist hash in synth.sh + clarify column label
oharboe 2ebd38e
bazel: stop tracking MODULE.bazel.lock
oharboe c18e424
flow/designs/design.bzl: export gds/gds.gz + factor helper
oharboe c44b22d
bazel: bump bazel-orfs to ce6efd9 with shared-block.mk + determinism …
oharboe cd5f4c7
fix: address gemini-code-assist nits on #4229
oharboe 5d5949a
bazel: user_sources= for design-private SOURCE_VARS, drop SDC_FILE_EX…
oharboe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,12 @@ | ||
| build --incompatible_strict_action_env | ||
| build --cxxopt "-std=c++20" --host_cxxopt "-std=c++20" | ||
|
|
||
| # Don't track MODULE.bazel.lock. Resolved versions ride along with the | ||
| # pinned BCR + git_override(commit=…) coordinates in MODULE.bazel and | ||
| # downstream cache hits are what we actually care about. Tracking the | ||
| # lockfile just means every bazel-orfs / yosys / openroad bump produces | ||
| # a 1000-line lock diff that buries the real change. Matches what | ||
| # bazel-orfs itself does (its own .bazelrc:7). | ||
| common --lockfile_mode=off | ||
|
|
||
| try-import %workspace%/user.bazelrc |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| From 58df356479d6d9f04aa0bc3ac3676d3b89d26813 Mon Sep 17 00:00:00 2001 | ||
| From: =?UTF-8?q?=C3=98yvind=20Harboe?= <oyvind@ascenium.com> | ||
| Date: Thu, 14 May 2026 18:48:12 +0200 | ||
| Subject: [PATCH] orfs_design/orfs_flow: add user_sources= for design-private | ||
| path hooks | ||
| MIME-Version: 1.0 | ||
| Content-Type: text/plain; charset=UTF-8 | ||
| Content-Transfer-Encoding: 8bit | ||
|
|
||
| Symmetric to user_arguments=, but for source-typed (path-label) vars: | ||
| a variable that the config_mk_parser classifies as a SOURCE_VAR (path | ||
| staged into the sandbox via _map_source_file) but that is read only | ||
| by user-supplied .tcl/.mk and has no entry in ORFS variables.yaml. | ||
|
|
||
| Today such a variable bumps into check_variables(sources.keys()) in | ||
| orfs_flow and fails the load phase, even though the file itself is | ||
| staged correctly. user_arguments= doesn't help because it pops from | ||
| arguments, not sources. | ||
|
|
||
| The motivating case is SDC_FILE_EXTRA — set by | ||
| flow/designs/asap7/mock-cpu/config.mk and source'd from that design's | ||
| io.tcl, with no ORFS-side consumer. SDC_FILE_EXTRA is in this file's | ||
| SOURCE_VARS list, so its value is path-staged; making it work without | ||
| declaring it as a global ORFS variable is what user_sources= is for. | ||
|
|
||
| API: | ||
| - orfs_design() gains user_sources=[VAR, ...]. Each named var is | ||
| popped from sources and forwarded as orfs_flow(user_sources={...}). | ||
| - orfs_flow() gains user_sources={VAR: [label, ...]}. Merged into | ||
| sources before _orfs_pass so files are still staged, but the key | ||
| set skips check_variables. Same shadowing guard as user_arguments=: | ||
| collision with a known ORFS variable fails fast. | ||
|
|
||
| Mirrors user_arguments= in both surface and intent. | ||
|
|
||
| Signed-off-by: Øyvind Harboe <oyvind@ascenium.com> | ||
| --- | ||
| private/flow.bzl | 19 +++++++++++++++++-- | ||
| private/orfs_design.bzl | 19 ++++++++++++++++++- | ||
| 2 files changed, 35 insertions(+), 3 deletions(-) | ||
|
|
||
| diff --git a/private/flow.bzl b/private/flow.bzl | ||
| index fd9001f..b59d059 100644 | ||
| --- a/private/flow.bzl | ||
| +++ b/private/flow.bzl | ||
| @@ -171,6 +171,7 @@ def orfs_flow( | ||
| verilog_files = [], | ||
| macros = [], | ||
| sources = {}, | ||
| + user_sources = {}, | ||
| stage_sources = {}, | ||
| stage_arguments = {}, | ||
| renamed_inputs = {}, | ||
| @@ -213,6 +214,12 @@ def orfs_flow( | ||
| validating against ORFS variables.yaml. Use for vars read only by user-supplied .tcl/.mk | ||
| (e.g. ARRAY_COLS in a project's MACRO_PLACEMENT_TCL). Keys that collide with known ORFS | ||
| variables are rejected — route those through 'arguments' instead. | ||
| + user_sources: dictionary of project-specific source-typed (path-label) env vars to expose | ||
| + to every stage without validating against ORFS variables.yaml. The path is still staged | ||
| + into the sandbox like a normal source — only the variable name skips the validator. | ||
| + Use for path hooks read only by user-supplied .tcl/.mk (e.g. an extra-SDC hook | ||
| + source'd from the design's own io.tcl). Keys that collide with known ORFS variables | ||
| + are rejected — route those through 'sources' instead. | ||
| extra_arguments: dictionary keyed by ORFS stages with lists of .json argument file labels. | ||
| These .json files are merged into the stage config, providing computed arguments | ||
| that flow through OrfsInfo to subsequent stages. | ||
| @@ -269,6 +276,14 @@ def orfs_flow( | ||
| ) + | ||
| "Use arguments= for ORFS variables; reserve user_arguments= for project-specific env vars.", | ||
| ) | ||
| + shadowed_srcs = sorted([k for k in user_sources if k in ALL_VARIABLE_TO_STAGES]) | ||
| + if shadowed_srcs: | ||
| + fail( | ||
| + "user_sources contains known ORFS variable(s): {shadowed}. ".format( | ||
| + shadowed = ", ".join(shadowed_srcs), | ||
| + ) + | ||
| + "Use sources= for ORFS variables; reserve user_sources= for project-specific path hooks.", | ||
| + ) | ||
| if abstract_stage and last_stage: | ||
| fail("abstract_stage and last_stage are mutually exclusive") | ||
| if variant == "base": | ||
| @@ -281,7 +296,7 @@ def orfs_flow( | ||
| top = top, | ||
| verilog_files = verilog_files, | ||
| macros = macros, | ||
| - sources = sources, | ||
| + sources = sources | user_sources, | ||
| stage_sources = stage_sources, | ||
| stage_arguments = stage_arguments, | ||
| renamed_inputs = renamed_inputs, | ||
| @@ -319,7 +334,7 @@ def orfs_flow( | ||
| top = top, | ||
| verilog_files = verilog_files, | ||
| macros = macros, | ||
| - sources = sources, | ||
| + sources = sources | user_sources, | ||
| stage_sources = stage_sources, | ||
| stage_arguments = stage_arguments, | ||
| renamed_inputs = {}, | ||
| diff --git a/private/orfs_design.bzl b/private/orfs_design.bzl | ||
| index 554da44..d53d4bd 100644 | ||
| --- a/private/orfs_design.bzl | ||
| +++ b/private/orfs_design.bzl | ||
| @@ -47,7 +47,7 @@ def _convert_sources(sources, pkg): | ||
| result[var] = converted | ||
| return result | ||
|
|
||
| -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 | ||
| +def orfs_design(name = None, config = "config.mk", platform = None, design = None, designs = None, mock_openroad = None, mock_yosys = None, user_arguments = [], user_sources = [], local_arguments = []): # buildifier: disable=unused-variable | ||
| """Create orfs_flow() targets for a design based on its parsed config.mk. | ||
|
|
||
| Usage: | ||
| @@ -79,6 +79,13 @@ def orfs_design(name = None, config = "config.mk", platform = None, design = Non | ||
| Routed through orfs_flow(user_arguments=...) to bypass the | ||
| variables.yaml validator instead of being checked as known | ||
| ORFS arguments. | ||
| + user_sources: List of source-typed variable names (vars in | ||
| + SOURCE_VARS) that are project-specific path hooks read only | ||
| + by user-supplied .tcl/.mk, not by ORFS itself (e.g. a | ||
| + per-design extra-SDC hook source'd from the design's own | ||
| + io.tcl). Routed through orfs_flow(user_sources=...) so the | ||
| + file is still staged into the sandbox, but the variable | ||
| + name bypasses the variables.yaml validator. | ||
| local_arguments: List of variable names that are only used for | ||
| $(VAR) expansion within the same config.mk and are not read | ||
| by ORFS or by any user .tcl/.mk (e.g. VERILOG_FILES_BLACKBOX, | ||
| @@ -195,6 +202,15 @@ def orfs_design(name = None, config = "config.mk", platform = None, design = Non | ||
| if var in arguments: | ||
| user_args[var] = arguments.pop(var) | ||
|
|
||
| + # Same idea for source-typed (path-label) project-specific knobs: | ||
| + # variables that are in SOURCE_VARS (so the parser staged the path | ||
| + # as a label) but are read only by user .tcl/.mk and have no | ||
| + # variables.yaml entry. | ||
| + user_srcs = {} | ||
| + for var in user_sources: | ||
| + if var in sources: | ||
| + user_srcs[var] = sources.pop(var) | ||
| + | ||
| # Default SYNTH_NUM_PARTITIONS to a static value so that the action graph | ||
| # is identical across machines and remote cache hits are possible. Users | ||
| # who prefer local parallelism over caching can pass NUM_CPUS explicitly. | ||
| @@ -213,6 +229,7 @@ def orfs_design(name = None, config = "config.mk", platform = None, design = Non | ||
| arguments = arguments, | ||
| user_arguments = user_args, | ||
| sources = sources, | ||
| + user_sources = user_srcs, | ||
| macros = macros if macros else [], | ||
| stage_data = {"synth": extra_data} if extra_data else {}, | ||
| tags = tags, | ||
| -- | ||
| 2.51.0 | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| exports_files(glob(["*.patch"])) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,9 @@ | ||
| load("//flow/designs:design.bzl", "design") | ||
|
|
||
| design(config = "config.mk") | ||
| design( | ||
| config = "config.mk", | ||
| user_arguments = [ | ||
| "MOCK_ALU_OPERATIONS", | ||
| "MOCK_ALU_WIDTH", | ||
| ], | ||
| ) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is this for? It seems to relate to private files not in ORFS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will wash out in the next bump, already merged in bazel-orfs. I patch things here to check if they work out to reduce churn in bazel-orfs as the use-case originated here.
Patching to reduce churn and let the use-case settle and then upstreaming is idiomatic for bazel usage.
Any other comments?