From c9e1ba4d3f1f149ee286550f08c7ca66fe10bdb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Wed, 9 Sep 2026 16:17:50 +0200 Subject: [PATCH 1/2] chore: drop bazel plumbing left over after the bazel surface removal MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #4501 removed ORFS's bazel surface, MODULE.bazel among it. A few files whose only purpose was to be referenced from that MODULE.bazel are still here, and nothing reads them any more. .bazelrc registry pins, C++ toolchain flags and a MODULE.bazel.lock policy for a bazel build that no longer exists. No workflow in .github/ invokes bazel. patches/{bison,icu,fakeram}/BUILD.bazel patches/tcl_lang/BUILD.bazel exports_files(glob(["*.patch"])) so a root MODULE.bazel could name the patches in single_version_override. With no MODULE.bazel nothing names them. Each file's own docstring said "Drop when tools/OpenROAD drops its copy"; tools/OpenROAD still has its copies, and those are the ones that matter. patches/tcl_lang/ goes entirely: it held no patch at all, so its glob matched nothing. flow/scripts/memories/bazel-orfs-auto-memories.patch a patch against bazel-orfs, carried here and described in AutoMemories.md as "to be upstreamed to bazel-orfs once the feature lands here". bazel-orfs implements AUTO_MEMORIES support itself now, and this copy no longer matches its tree. The patch files under patches/{bison,icu,fakeram} stay. Only the BUILD.bazel label plumbing goes; the patches themselves still describe real fixes. .bazelignore and .bazelversion also stay, and are not leftovers: .bazelversion is what bazelisk reads in docker/Dockerfile.claude, and .bazelignore keeps tools/ from being walked by anything that does consume this tree from bazel. AutoMemories.md loses a `bazelisk test //flow:memories_tests` line -- that target went with flow/BUILD in #4501 -- and its "Consuming from bazel-orfs" section now states what a sandboxed build system has to declare instead of pointing at the deleted patch. Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Øyvind Harboe --- .bazelrc | 31 ---- docs/user/AutoMemories.md | 32 ++-- .../memories/bazel-orfs-auto-memories.patch | 170 ------------------ patches/bison/BUILD.bazel | 7 - patches/fakeram/BUILD.bazel | 3 - patches/icu/BUILD.bazel | 7 - patches/tcl_lang/BUILD.bazel | 7 - 7 files changed, 19 insertions(+), 238 deletions(-) delete mode 100644 .bazelrc delete mode 100644 flow/scripts/memories/bazel-orfs-auto-memories.patch delete mode 100644 patches/bison/BUILD.bazel delete mode 100644 patches/fakeram/BUILD.bazel delete mode 100644 patches/icu/BUILD.bazel delete mode 100644 patches/tcl_lang/BUILD.bazel diff --git a/.bazelrc b/.bazelrc deleted file mode 100644 index e9f83d934f..0000000000 --- a/.bazelrc +++ /dev/null @@ -1,31 +0,0 @@ -# yosys 0.64 is not yet in BCR; add the unmerged PR's fork as a fallback -# registry until bazelbuild/bazel-central-registry#8862 lands. BCR is -# listed first so all other modules resolve from the official source; -# the fork is only consulted for modules/versions BCR doesn't carry yet. -# The commit hash makes the fork reference immutable. Mirrors what -# bazel-orfs/.bazelrc does upstream — ORFS root has its own .bazelrc so -# the upstream lines don't propagate automatically. -common --registry=https://bcr.bazel.build/ -common --registry=https://raw.githubusercontent.com/oharboe/bazel-central-registry/0586b398db6edd245da97cbec29e26c5e2a808d7/ - -build --incompatible_strict_action_env -build --cxxopt "-std=c++20" --host_cxxopt "-std=c++20" - -# Refuse to autodetect a local C++ toolchain (/usr/bin/gcc); the hermetic -# toolchain must win resolution. Mirrors tools/OpenROAD/.bazelrc. -common --repo_env=BAZEL_DO_NOT_DETECT_CPP_TOOLCHAIN=1 - -# Launch py_binary via a shell stub instead of rules_python's legacy python -# stub, whose '#!/usr/bin/env python3' shebang needs a host python3 before -# the hermetic interpreter takes over. Mirrors tools/OpenROAD/.bazelrc. -common --@rules_python//python/config_settings:bootstrap_impl=script - -# 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 diff --git a/docs/user/AutoMemories.md b/docs/user/AutoMemories.md index eddde0e660..9faa76614c 100644 --- a/docs/user/AutoMemories.md +++ b/docs/user/AutoMemories.md @@ -130,10 +130,6 @@ clear error. ## Trying it ```shell -# Unit tests (fast, no EDA tools): -bazelisk test //flow:memories_tests - -# The demo design: make DESIGN_CONFIG=designs/asap7/tinyRocket/config.mk synth floorplan ``` @@ -148,15 +144,25 @@ python3 flow/scripts/memories/gen_memories.py \ ## Consuming from bazel-orfs Everything downstream keys off generated files, so a build system can -declare them as ordinary stage outputs and transitive dependencies. In -bazel-orfs each stage runs in a sandbox where only declared outputs -survive, so it additionally needs to declare `memories.json` plus the -`memories/` directory (a directory artifact — the per-memory file -names are only known at run time) as canonicalize outputs and stage -them into every downstream stage's sandbox. The bazel-orfs change that -does this is carried alongside this feature as -`flow/scripts/memories/bazel-orfs-auto-memories.patch`, to be -upstreamed to bazel-orfs once the feature lands here. +declare them as ordinary stage outputs and transitive dependencies. + +A sandboxed build system, where only declared outputs survive a step and +only declared inputs are present, needs three things: + +- `memories.json` and the `memories/` directory declared as outputs of + canonicalization. `memories/` has to be a directory rather than a file + list: the per-memory file names are only known once the RTL is + scanned. +- both staged into every later step, because the flow reads them by + globbing the results dir (`load.tcl` takes `memories/*.lef`, + `read_liberty.tcl` takes `*.lib`) rather than through a variable. +- `memories_inferred.json` staged into synthesis as well. Nothing reads + it there, but `make` checks the whole chain + (`yosys-dependencies` -> `memories.json` -> `memories_inferred.json`), + and with the tail of it absent it re-runs detection at the wrong point + in the flow. + +bazel-orfs implements this. ## Variables diff --git a/flow/scripts/memories/bazel-orfs-auto-memories.patch b/flow/scripts/memories/bazel-orfs-auto-memories.patch deleted file mode 100644 index 408c274a9b..0000000000 --- a/flow/scripts/memories/bazel-orfs-auto-memories.patch +++ /dev/null @@ -1,170 +0,0 @@ -From 43f2d13a2669cc590d3af06c4e74647321f68095 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?=C3=98yvind=20Harboe?= -Date: Sun, 19 Jul 2026 18:36:34 +0200 -Subject: [PATCH] rules: declare and propagate AUTO_MEMORIES stage artifacts -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -ORFS's experimental AUTO_MEMORIES flow generates results/memories.json -plus a memories/ directory of generated .lib/.lef macro views during -canonicalization, and every later stage reads them from the results -dir at tcl run time. In bazel-orfs each stage runs in a sandbox where -only declared outputs survive, so without this change the generated -views are discarded after synthesis and floorplan fails to link the -blackboxed memory modules. - -Declare memories.json and the memories/ directory (a directory -artifact: the per-memory file names are only known at run time) as -canonicalize outputs when AUTO_MEMORIES=1, carry them on the new -OrfsInfo.memories field, and stage them into every downstream stage's -sandbox via source_inputs(). AUTO_MEMORIES is rejected with -SYNTH_USE_SYN, which has no yosys canonicalize step. - -User-supplied ADDITIONAL_MEMORIES files need no new machinery: they -reach the synth sandbox like any other sources= entry. - -Signed-off-by: Øyvind Harboe ---- - private/environment.bzl | 8 ++++++++ - private/providers.bzl | 1 + - private/rules.bzl | 29 ++++++++++++++++++++++++++--- - 3 files changed, 35 insertions(+), 3 deletions(-) - -diff --git a/private/environment.bzl b/private/environment.bzl -index f643501..f69359b 100644 ---- a/private/environment.bzl -+++ b/private/environment.bzl -@@ -229,6 +229,11 @@ def source_inputs(ctx): - ctx.attr.src[OrfsInfo].additional_lefs, - ctx.attr.src[OrfsInfo].additional_libs, - ctx.attr.src[OrfsInfo].additional_libs_pre_layout, -+ # AUTO_MEMORIES artifacts (memories.json + the generated -+ # .lib/.lef directory): later stages glob them from the -+ # results dir at tcl run time, so they must be staged in -+ # every downstream stage's sandbox. -+ ctx.attr.src[OrfsInfo].memories, - ctx.attr.src[PdkInfo].files, - ctx.attr.src[PdkInfo].libs, - # Accumulate all JSON reports, so depend on previous stage. -@@ -604,6 +609,9 @@ def _artifact_name(ctx, category, name = None): - def declare_artifact(ctx, category, name): - return ctx.actions.declare_file(_artifact_name(ctx, category, name)) - -+def declare_directory_artifact(ctx, category, name): -+ return ctx.actions.declare_directory(_artifact_name(ctx, category, name)) -+ - def declare_artifacts(ctx, category, names): - """Declares multiple artifacts in one call. - -diff --git a/private/providers.bzl b/private/providers.bzl -index e2eabb2..8c3e5bf 100644 ---- a/private/providers.bzl -+++ b/private/providers.bzl -@@ -17,6 +17,7 @@ OrfsInfo = provider( - "additional_libs", - "additional_libs_pre_layout", - "arguments", -+ "memories", - ], - ) - PdkInfo = provider( -diff --git a/private/rules.bzl b/private/rules.bzl -index 6f0e502..e8379ef 100644 ---- a/private/rules.bzl -+++ b/private/rules.bzl -@@ -21,6 +21,7 @@ load( - "data_inputs", - "declare_artifact", - "declare_artifacts", -+ "declare_directory_artifact", - "deps_inputs", - "environment_string", - "extensionless_basename", -@@ -262,6 +263,7 @@ def _macro_impl(ctx): - additional_lefs = depset([]), - additional_libs = depset([]), - additional_libs_pre_layout = depset([]), -+ memories = depset([]), - arguments = depset([]), - ), - TopInfo( -@@ -519,6 +521,7 @@ def _arguments_impl(ctx): - additional_lefs = src_info.additional_lefs, - additional_libs = src_info.additional_libs, - additional_libs_pre_layout = src_info.additional_libs_pre_layout, -+ memories = src_info.memories, - arguments = depset( - [computed_json], - transitive = [src_info.arguments], -@@ -1353,6 +1356,22 @@ def _yosys_impl(ctx): - # come through arguments/stage_arguments, not extra_arguments .json files. - use_syn = all_arguments.get("SYNTH_USE_SYN") == "1" - -+ # AUTO_MEMORIES: the canonicalize step generates memories.json plus a -+ # directory of .lib/.lef macro views (file names are only known at run -+ # time, hence a directory artifact). Declared as canonicalize outputs -+ # and threaded to every later stage via OrfsInfo.memories / -+ # source_inputs(), matching where the flow's tcl globs them. -+ auto_memories = all_arguments.get("AUTO_MEMORIES") == "1" -+ if auto_memories and use_syn: -+ fail("AUTO_MEMORIES is not supported with SYNTH_USE_SYN in " + -+ str(ctx.label)) -+ memories_outputs = [] -+ if auto_memories: -+ memories_outputs = [ -+ declare_artifact(ctx, "results", "memories.json"), -+ declare_directory_artifact(ctx, "results", "memories"), -+ ] -+ - canon_logs = declare_artifacts(ctx, "logs", ["1_1_yosys_canonicalize.log"]) - - canon_output = declare_artifact(ctx, "results", CANON_OUTPUT) -@@ -1393,7 +1412,7 @@ def _yosys_impl(ctx): - canon_deps, - ], - ), -- outputs = [canon_output] + canon_logs, -+ outputs = [canon_output] + canon_logs + memories_outputs, - tools = yosys_inputs(ctx), - progress_message = "Canonicalizing RTL for %s" % module_top(ctx), - ) -@@ -1513,7 +1532,8 @@ def _yosys_impl(ctx): - config_environment(config), - ), - inputs = depset( -- [canon_output, config] + ctx.files.extra_configs, -+ [canon_output, config] + memories_outputs + -+ ctx.files.extra_configs, - transitive = [ - data_inputs(ctx), - pdk_inputs(ctx), -@@ -1553,7 +1573,8 @@ def _yosys_impl(ctx): - tools = depset(transitive = [flow_inputs(ctx)]), - ) - -- outputs = [canon_output, variables] + synth_outputs.values() -+ outputs = [canon_output, variables] + synth_outputs.values() + \ -+ memories_outputs - - # Write synth's data_arguments to a JSON so downstream stages - # inherit synth-time variables (SDC_FILE, VERILOG_FILES, SYNTH_*) -@@ -1721,6 +1742,7 @@ def _yosys_impl(ctx): - if (dep[OrfsInfo].lib_pre_layout or dep[OrfsInfo].lib) - ], - ), -+ memories = depset(memories_outputs), - arguments = depset([synth_args_json]), - ), - ctx.attr.pdk[PdkInfo], -@@ -2098,6 +2120,7 @@ def _make_impl( - additional_lefs = ctx.attr.src[OrfsInfo].additional_lefs, - additional_libs = ctx.attr.src[OrfsInfo].additional_libs, - additional_libs_pre_layout = ctx.attr.src[OrfsInfo].additional_libs_pre_layout, -+ memories = ctx.attr.src[OrfsInfo].memories, - arguments = depset( - [stage_json], - transitive = [ctx.attr.src[OrfsInfo].arguments] + --- -2.53.0 - diff --git a/patches/bison/BUILD.bazel b/patches/bison/BUILD.bazel deleted file mode 100644 index 9a8f39982d..0000000000 --- a/patches/bison/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -"""bison fixes carried as single_version_override patches. - -Mirrored from tools/OpenROAD/bazel/bison-patches (overrides are -root-honored only). Drop when tools/OpenROAD drops its copy. -""" - -exports_files(glob(["*.patch"])) diff --git a/patches/fakeram/BUILD.bazel b/patches/fakeram/BUILD.bazel deleted file mode 100644 index 89af6bdfcc..0000000000 --- a/patches/fakeram/BUILD.bazel +++ /dev/null @@ -1,3 +0,0 @@ -"""FakeRAM2.0 patches carried for ORFS AUTO_MEMORIES support.""" - -exports_files(glob(["*.patch"])) diff --git a/patches/icu/BUILD.bazel b/patches/icu/BUILD.bazel deleted file mode 100644 index 6869ce9a88..0000000000 --- a/patches/icu/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -"""icu fixes carried as single_version_override patches. - -Mirrored from tools/OpenROAD/bazel/icu-patches (overrides are -root-honored only). Drop when tools/OpenROAD drops its copy. -""" - -exports_files(glob(["*.patch"])) diff --git a/patches/tcl_lang/BUILD.bazel b/patches/tcl_lang/BUILD.bazel deleted file mode 100644 index 73513a9ed2..0000000000 --- a/patches/tcl_lang/BUILD.bazel +++ /dev/null @@ -1,7 +0,0 @@ -"""tcl_lang fixes carried as single_version_override patches. - -Mirrored from tools/OpenROAD/bazel/tcl-patches (overrides are -root-honored only). Drop when tools/OpenROAD drops its copy. -""" - -exports_files(glob(["*.patch"])) From 95ad91beb476b9a61506b4de993d101251dfe440 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Wed, 9 Sep 2026 16:35:23 +0200 Subject: [PATCH 2/2] docs: correct the liberty glob, and spell the make chain as rules MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Two review notes on the AutoMemories "Consuming from bazel-orfs" section. read_liberty.tcl globs $(RESULTS_DIR)/memories/*.lib, not *.lib. The text said the latter, which reads as if the liberty views were picked up from the results dir root while the LEFs came from memories/. Both come from memories/. The dependency chain is now written as the make rules themselves. The prose form invited reading it as execution order, which is the reverse: memories_inferred.json is *built* first, but `yosys-dependencies` *depends on* memories.json, which depends on memories_inferred.json. Showing the three rules removes the ambiguity rather than restating it, and says which end of the chain goes missing in a sandbox. Co-Authored-By: Claude Opus 5 (1M context) Signed-off-by: Øyvind Harboe --- docs/user/AutoMemories.md | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/user/AutoMemories.md b/docs/user/AutoMemories.md index 9faa76614c..55a3241694 100644 --- a/docs/user/AutoMemories.md +++ b/docs/user/AutoMemories.md @@ -155,12 +155,22 @@ only declared inputs are present, needs three things: scanned. - both staged into every later step, because the flow reads them by globbing the results dir (`load.tcl` takes `memories/*.lef`, - `read_liberty.tcl` takes `*.lib`) rather than through a variable. + `read_liberty.tcl` takes `memories/*.lib`) rather than through a + variable. - `memories_inferred.json` staged into synthesis as well. Nothing reads - it there, but `make` checks the whole chain - (`yosys-dependencies` -> `memories.json` -> `memories_inferred.json`), - and with the tail of it absent it re-runs detection at the wrong point - in the flow. + it there, but `make` walks the prerequisites of `yosys-dependencies` + before running it, and each one depends on the next: + + ```make + yosys-dependencies: $(RESULTS_DIR)/memories.json + $(RESULTS_DIR)/memories.json: $(RESULTS_DIR)/memories_inferred.json ... + $(RESULTS_DIR)/memories_inferred.json: $(VERILOG_FILES) ... + ``` + + With the far end of that chain absent, make rebuilds + `memories_inferred.json` -- re-running detection at a point in the + flow where the design is no longer the original RTL -- and then tries + to rewrite `memories.json`. bazel-orfs implements this.