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..55a3241694 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,35 @@ 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 `memories/*.lib`) rather than through a + variable. +- `memories_inferred.json` staged into synthesis as well. Nothing reads + 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. ## 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"]))