Skip to content

Commit a7836dc

Browse files
committed
bazel-orfs: bump
Upstream bazel-orfs dropped the docker_orfs image in favor of source-built tools (orfs/openroad/qt-bazel pulled directly as Bazel modules). Adapt the root MODULE.bazel to the new graph: - Switch orfs.default() to the new signature (drop image/sha256, keep only openroad override). - Add root git_override for orfs and single_version_override for yosys with the patches bazel-orfs applies upstream. Non-root overrides are ignored, so they must be mirrored here. - Copy the four bazel-orfs patches needed by those overrides into bazel/bazel-orfs-patches/, plus a new yosys-backend-aiger2 patch that compiles in backends/aiger2/aiger.cc so write_xaiger2 is available to the abc_new pass used by synth.tcl when SWAP_ARITH_OPERATORS is set. - Replace @docker_orfs stdcell references with local copies of dff.v and empty.v under test/orfs/asap7/. Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
1 parent 3ab0dea commit a7836dc

15 files changed

Lines changed: 584 additions & 53 deletions

MODULE.bazel

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ bazel_dep(name = "verilator", version = "5.036.bcr.3", dev_dependency = True)
100100
bazel_dep(name = "bazel-orfs", dev_dependency = True)
101101
bazel_dep(name = "bazel-orfs-verilog", dev_dependency = True)
102102

103-
BAZEL_ORFS_COMMIT = "f5e20547f93729a4f67929902aaa3386d933bad0"
103+
BAZEL_ORFS_COMMIT = "232b2ea4bea81beb74c37395540d23fd5f00d282"
104104

105105
BAZEL_ORFS_REMOTE = "https://github.com/The-OpenROAD-Project/bazel-orfs.git"
106106

@@ -118,6 +118,34 @@ git_override(
118118
strip_prefix = "verilog",
119119
)
120120

121+
# bazel-orfs pulls in orfs without a version and patches yosys, relying on
122+
# overrides that only apply when bazel-orfs is the root module. Mirror them
123+
# here so OpenROAD-as-root can resolve the module graph.
124+
bazel_dep(name = "orfs", dev_dependency = True)
125+
git_override(
126+
module_name = "orfs",
127+
commit = "2f4de31a0f3f6402ca74887f67b75a9303c6e061",
128+
patch_strip = 1,
129+
patches = [
130+
"//bazel/bazel-orfs-patches:0035-fix-remove-non-root-overrides-from-MODULE.bazel.patch",
131+
"//bazel/bazel-orfs-patches:orfs-preserve-tool-exe-env.patch",
132+
"//bazel/bazel-orfs-patches:orfs-log-cmd-clock-fallback.patch",
133+
],
134+
remote = "https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts.git",
135+
)
136+
137+
bazel_dep(name = "yosys", version = "0.62", dev_dependency = True)
138+
single_version_override(
139+
module_name = "yosys",
140+
patch_strip = 1,
141+
patches = [
142+
"//bazel/bazel-orfs-patches:yosys-visibility.patch",
143+
"//bazel/bazel-orfs-patches:yosys-hdrs.patch",
144+
"//bazel/bazel-orfs-patches:yosys-tcl9-mp-to-ubin.patch",
145+
"//bazel/bazel-orfs-patches:yosys-backend-aiger2.patch",
146+
],
147+
)
148+
121149
# --- Extensions ---
122150

123151
llvm = use_extension(
@@ -172,16 +200,10 @@ npm.npm_translate_lock(
172200
use_repo(npm, "npm")
173201

174202
orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories", dev_dependency = True)
175-
176-
# To bump version, run: bazelisk run @bazel-orfs//:bump
177203
orfs.default(
178-
# Official image https://hub.docker.com/r/openroad/orfs/tags
179-
image = "docker.io/openroad/orfs:26Q1-816-gf40d2f346",
180-
# Use OpenROAD of this repo instead of from the docker image
204+
# Use OpenROAD of this repo instead of the one bundled with @orfs
181205
openroad = "//:openroad",
182-
sha256 = "2b05a14ae8062b4af82b245d648e95fa0293e09b61b57468518b66578744afb8",
183206
)
184-
use_repo(orfs, "docker_orfs")
185207

186208
# --- Overrides ---
187209

MODULE.bazel.lock

Lines changed: 248 additions & 39 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: =?UTF-8?q?=C3=98yvind=20Harboe?= <oyvind.harboe@zylin.com>
3+
Date: Wed, 2 Apr 2026 22:00:00 +0200
4+
Subject: [PATCH] fix: remove non-root overrides from MODULE.bazel
5+
6+
When ORFS is fetched as a non-root dependency, git_override and
7+
orfs.default() directives are ignored/illegal. Remove them so
8+
the module can be used as a dependency without errors.
9+
10+
Signed-off-by: =?UTF-8?q?=C3=98yvind=20Harboe?= <oyvind.harboe@zylin.com>
11+
---
12+
MODULE.bazel | 19 -------------------
13+
1 file changed, 19 deletions(-)
14+
15+
diff --git a/MODULE.bazel b/MODULE.bazel
16+
--- a/MODULE.bazel
17+
+++ b/MODULE.bazel
18+
@@ -8,13 +8,6 @@
19+
20+
bazel_dep(name = "bazel-orfs")
21+
22+
-# To bump version, run: bazelisk run @bazel-orfs//:bump
23+
-git_override(
24+
- module_name = "bazel-orfs",
25+
- commit = "f8a4b694b37c8f5322323eba9a9ae37f9541ee17",
26+
- remote = "https://github.com/The-OpenROAD-Project/bazel-orfs.git",
27+
-)
28+
-
29+
bazel_dep(name = "rules_python", version = "1.8.5")
30+
bazel_dep(name = "rules_shell", version = "0.6.1")
31+
32+
@@ -36,15 +29,3 @@
33+
use_repo(pip, "orfs-pip")
34+
35+
orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories")
36+
-
37+
-# To bump version, run: bazelisk run @bazel-orfs//:bump
38+
-orfs.default(
39+
- image = "docker.io/openroad/orfs:v3.0-3273-gedf3d6bf",
40+
- # Use local files instead of docker image
41+
- makefile = "//flow:makefile",
42+
- makefile_yosys = "//flow:makefile_yosys",
43+
- pdk = "//flow:asap7",
44+
- sha256 = "f5692c6325ebcf27cc348e033355ec95c82c35ace1af7e72a0d352624ada143e",
45+
-)
46+
-use_repo(orfs, "com_github_nixos_patchelf_download")
47+
-use_repo(orfs, "docker_orfs")
48+
--
49+
2.51.0
50+

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"]))
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
log_cmd: skip timing when [clock] is unavailable.
2+
3+
Tcl's clock command lives in clock.tcl, auto-loaded from TCL_LIBRARY.
4+
BCR yosys (cc_binary against @tcl_lang) doesn't ship tcl_lang's library/
5+
dir in runfiles, so Tcl_Init fails and `clock` never gets defined.
6+
7+
log_cmd's clock usage is cosmetic — it prints "Took N seconds" when a
8+
command runs longer than 5s. Guarding it lets log_cmd still run the
9+
underlying command under yosys even when the clock command is missing.
10+
--- a/flow/scripts/util.tcl
11+
+++ b/flow/scripts/util.tcl
12+
@@ -7,11 +7,16 @@ proc log_cmd { cmd args } {
13+
# log the command, escape arguments with spaces
14+
set log_cmd "$cmd[join [lmap arg $args { format " %s" [expr { [string match {* *} $arg] ? "\"$arg\"" : "$arg" }] }] ""]" ;# tclint-disable-line line-length
15+
puts $log_cmd
16+
- set start [clock seconds]
17+
+ set has_clock [expr { [info commands clock] ne "" }]
18+
+ if { $has_clock } {
19+
+ set start [clock seconds]
20+
+ }
21+
set result [uplevel 1 [list $cmd {*}$args]]
22+
- set time [expr { [clock seconds] - $start }]
23+
- if { $time >= 5 } {
24+
- # Ideally we'd use a single line, but the command can output text
25+
- # and we don't want to mix it with the log, so output the time it took afterwards.
26+
- puts "Took $time seconds: $log_cmd"
27+
+ if { $has_clock } {
28+
+ set time [expr { [clock seconds] - $start }]
29+
+ if { $time >= 5 } {
30+
+ # Ideally we'd use a single line, but the command can output text
31+
+ # and we don't want to mix it with the log, so output the time it took afterwards.
32+
+ puts "Took $time seconds: $log_cmd"
33+
+ }
34+
}
35+
return $result
36+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/flow/scripts/variables.mk b/flow/scripts/variables.mk
2+
--- a/flow/scripts/variables.mk
3+
+++ b/flow/scripts/variables.mk
4+
@@ -188,7 +188,7 @@ export RESULTS_V = $(notdir $(sort $(wildcard $(RESULTS_DIR)/*.v)))
5+
export GDS_MERGED_FILE = $(RESULTS_DIR)/6_1_merged.$(STREAM_SYSTEM_EXT)
6+
7+
define get_variables
8+
-$(foreach V, $(.VARIABLES),$(if $(filter-out $(1), $(origin $V)), $(if $(filter-out .% %QT_QPA_PLATFORM% KLAYOUT% GENERATE_ABSTRACT_RULE% do-step% do-copy% OPEN_GUI% OPEN_GUI_SHORTCUT% SUB_MAKE% UNSET_VARS% export%, $(V)), $V$ )))
9+
+$(foreach V, $(.VARIABLES),$(if $(filter-out $(1), $(origin $V)), $(if $(filter-out .% %QT_QPA_PLATFORM% KLAYOUT% OPENROAD% OPENSTA% YOSYS% GENERATE_ABSTRACT_RULE% do-step% do-copy% OPEN_GUI% OPEN_GUI_SHORTCUT% SUB_MAKE% UNSET_VARS% export%, $(V)), $V$ )))
10+
endef
11+
12+
export UNSET_VARIABLES_NAMES := $(call get_variables,command% line environment% default automatic)
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
diff --git a/interface_libs/xcb/BUILD.bazel b/interface_libs/xcb/BUILD.bazel
2+
index c1c5b6b6..3a659170 100644
3+
--- a/interface_libs/xcb/BUILD.bazel
4+
+++ b/interface_libs/xcb/BUILD.bazel
5+
@@ -67,10 +67,41 @@ cc_import(
6+
system_provided = True,
7+
)
8+
9+
-cc_import(
10+
- name = "xcb_cursor_ifso",
11+
- interface_library = "libxcb-cursor.ifso",
12+
- system_provided = True,
13+
+# Headers-only target for xcb utility headers. Used by :xcb_cursor to
14+
+# get xcb_renderutil.h, xcb_image.h, render.h etc. without depending on
15+
+# the full :xcb target (which would create a circular dependency).
16+
+cc_library(
17+
+ name = "xcb_hdrs",
18+
+ hdrs = glob(["xcb/*.h"]),
19+
+ includes = ["."],
20+
+ strip_include_prefix = ".",
21+
+)
22+
+
23+
+# Build xcb-util-cursor from source instead of relying on a system-provided
24+
+# shared library. The source is downloaded into cursor/ by patch_cmds in
25+
+# the consumer's MODULE.bazel. This makes the Qt xcb platform plugin
26+
+# self-contained — no host libxcb-cursor0 package required.
27+
+cc_library(
28+
+ name = "xcb_cursor",
29+
+ srcs = [
30+
+ "cursor/cursor.c",
31+
+ "cursor/cursor.h",
32+
+ "cursor/load_cursor.c",
33+
+ "cursor/parse_cursor_file.c",
34+
+ "cursor/shape_to_id.c",
35+
+ ],
36+
+ hdrs = ["cursor/xcb_cursor.h"],
37+
+ copts = [
38+
+ # asprintf() is a GNU extension; glibc gates it behind _GNU_SOURCE.
39+
+ "-D_GNU_SOURCE",
40+
+ "-DXCURSORPATH='\"~/.icons:/usr/share/icons:/usr/share/pixmaps:/usr/X11R6/lib/X11/icons\"'",
41+
+ ],
42+
+ include_prefix = "xcb",
43+
+ strip_include_prefix = "cursor",
44+
+ deps = [
45+
+ ":xcb_hdrs",
46+
+ "@libxcb",
47+
+ ],
48+
)
49+
50+
cc_import(
51+
@@ -94,7 +125,7 @@ cc_library(
52+
deps = select({
53+
"@platforms//cpu:aarch64": [],
54+
"//conditions:default": [
55+
- ":xcb_cursor_ifso",
56+
+ ":xcb_cursor",
57+
":xcb_icccm_ifso",
58+
":xcb_ifso",
59+
":xcb_image_ifso",
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
Add backends/aiger2 target so write_xaiger2 is available.
2+
3+
The abc_new pass in passes/techmap/abc_new.cc shells out to
4+
write_xaiger2 when orfs synth.tcl runs with SWAP_ARITH_OPERATORS
5+
or SYNTH_WRAPPED_OPERATORS. The BCR yosys BUILD.bazel only compiled
6+
frontends/aiger2 and backends/aiger; add backends/aiger2/aiger.cc
7+
so the command is registered at startup.
8+
9+
--- a/BUILD.bazel
10+
+++ b/BUILD.bazel
11+
@@ -1036,6 +1036,19 @@ cc_library(
12+
)
13+
14+
cc_library(
15+
+ name = "backend_aiger2",
16+
+ srcs = [
17+
+ "backends/aiger2/aiger.cc",
18+
+ ],
19+
+ conlyopts = COMMON_COPTS,
20+
+ cxxopts = COMMON_CXXOPTS,
21+
+ local_defines = COMMON_DEFINES,
22+
+ visibility = ["//visibility:public"],
23+
+ deps = [":kernel"],
24+
+ alwayslink = True,
25+
+)
26+
+
27+
+cc_library(
28+
name = "backend_json",
29+
srcs = ["backends/json/json.cc"],
30+
conlyopts = COMMON_COPTS,
31+
@@ -1087,6 +1100,7 @@ cc_binary(
32+
visibility = ["//visibility:public"],
33+
deps = [
34+
":backend_aiger",
35+
+ ":backend_aiger2",
36+
":backend_json",
37+
":backend_rtlil",
38+
":backend_verilog",
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--- a/BUILD.bazel
2+
+++ b/BUILD.bazel
3+
@@ -691,3 +691,12 @@
4+
"passes/cmds/sdc/graph-stubs.sdc:sdc/graph-stubs.sdc",
5+
],
6+
)
7+
+
8+
+# Header-only target for building out-of-tree yosys plugins.
9+
+cc_library(
10+
+ name = "hdrs",
11+
+ hdrs = glob(["kernel/*.h", "kernel/*.inc"]),
12+
+ defines = COMMON_DEFINES,
13+
+ includes = ["."],
14+
+ visibility = ["//visibility:public"],
15+
+)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Use mp_to_ubin / mp_ubin_size for Tcl 9 compatibility.
2+
3+
Tcl 9's libtommath stubs no longer export the deprecated
4+
TclBN_mp_to_unsigned_bin / TclBN_mp_unsigned_bin_size, though
5+
tclTomMathDecls.h still redirects the unprefixed names to them.
6+
Switch to the non-deprecated mp_to_ubin / mp_ubin_size which are
7+
present in both the Tcl 9 stubs and upstream libtommath.
8+
--- a/kernel/tclapi.cc
9+
+++ b/kernel/tclapi.cc
10+
@@ -211,8 +211,9 @@ bool mp_int_to_const(mp_int *a, Const &b, bool is_signed)
11+
}
12+
13+
std::vector<unsigned char> buf;
14+
- buf.resize(mp_unsigned_bin_size(a));
15+
- mp_to_unsigned_bin(a, buf.data());
16+
+ buf.resize(mp_ubin_size(a));
17+
+ size_t written = 0;
18+
+ mp_to_ubin(a, buf.data(), buf.size(), &written);
19+
20+
Const::Builder b_bits(mp_count_bits(a) + is_signed);
21+
for (int i = 0; i < mp_count_bits(a);) {

0 commit comments

Comments
 (0)