Skip to content

Commit ae57840

Browse files
committed
bazel: use locally built openroad instead of OpenROAD from docker image
better for OpenROAD development, which is the main use-case for ORFS. bazel-orfs used on other projects, probably want to use a bazel- Signed-off-by: Øyvind Harboe <[email protected]>
1 parent f25bfc0 commit ae57840

File tree

7 files changed

+109
-30
lines changed

7 files changed

+109
-30
lines changed

docs/user/BuildLocally.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,40 @@ Set up environment variables using `dev_env.sh`, then start Visual Studio Code.
5353
. ./dev_env.sh
5454
code tools/OpenROAD/
5555
```
56+
57+
## Build OpenROAD and run a few ORFS flows with Bazel
58+
59+
Local use case:
60+
61+
- Install Bazelisk and no other dependencies, no need to run `sudo ./setup.sh`
62+
- Modify & build OpenROAD
63+
- Test built OpenROAD with a few ORFS flows
64+
65+
The Bazel support in OpenROAD and ORFS is work in progress and some Bazel experience is recommended before going spelunking in the Bazel builds.
66+
67+
Contributions welcome!
68+
69+
To build `designs/asap7/gcd:gcd_floorplan`:
70+
71+
cd flow
72+
(cd ../tools/OpenROAD && bazel build :openroad -c opt) && bazelisk build designs/asap7/gcd:gcd_floorplan
73+
74+
Or to run all flows currently available in Bazel
75+
76+
cd flow
77+
(cd ../tools/OpenROAD && bazel build :openroad -c opt) && bazelisk build ...
78+
79+
Note! ORFS uses the OpenROAD Bazel built binary in stop-gap way until OpenROAD has been switched to bzlmod, after which to build all flows becomes simpler as ORFS will build the requisite OpenROAD directly:
80+
81+
cd flow
82+
bazelisk build ...
83+
84+
ORFS uses [bazel-orfs](https://github.com/The-OpenROAD-Project/bazel-orfs) to implement the flow and gets some depedencies, like yosys, from the Docker image. Over time, all dependencies should be built with Bazel and the dependency on the ORFS Docker image will be phased out.
85+
86+
### Upgrading MODULE.bazel with the latest bazel-orfs and ORFS Docker image
87+
88+
Run:
89+
90+
bazelisk run @bazel-orfs//:bump
91+
92+
Then commit MODULE.bazel and MODULE.bazel.lock.

flow/BUILD.bazel

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ filegroup(
1616
"scripts/*.script",
1717
"scripts/util.tcl",
1818
"scripts/synth*.tcl",
19-
"platforms/common/**/*.v",
20-
]) +
21-
["//util:makefile_yosys"],
19+
"platforms/common/**/*.v",
20+
]) + [
21+
"//util:makefile_yosys",
22+
],
2223
visibility = ["//visibility:public"],
2324
)
2425

@@ -28,7 +29,7 @@ filegroup(
2829
srcs = ["Makefile"],
2930
data = glob(MAKEFILE_SHARED + [
3031
"scripts/*.tcl",
31-
"platforms/common/**/*.v",
32+
"platforms/common/**/*.v",
3233
]) + [
3334
"//util:makefile",
3435
],
@@ -38,23 +39,26 @@ filegroup(
3839
# These are the only PDKs for which we have BUILD.bazel files for now
3940
[orfs_pdk(
4041
name = pdk,
41-
config = ":platforms/{pdk}/config.mk".format(pdk = pdk),
4242
srcs = glob([
43-
"platforms/{pdk}/**/*.{ext}".format(pdk = pdk, ext = ext)
44-
for ext in [
45-
"gds",
46-
"lib.gz",
47-
"lef",
48-
"lib",
49-
"lyt",
50-
"mk",
51-
"rules",
52-
"sdc",
53-
"tcl",
54-
"v",
55-
"tlef",
56-
]
57-
]),
43+
"platforms/{pdk}/**/*.{ext}".format(
44+
ext = ext,
45+
pdk = pdk,
46+
)
47+
for ext in [
48+
"gds",
49+
"lib.gz",
50+
"lef",
51+
"lib",
52+
"lyt",
53+
"mk",
54+
"rules",
55+
"sdc",
56+
"tcl",
57+
"v",
58+
"tlef",
59+
]
60+
]),
61+
config = ":platforms/{pdk}/config.mk".format(pdk = pdk),
5862
visibility = ["//visibility:public"],
5963
) for pdk in [
6064
"asap7",

flow/MODULE.bazel

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ module(
77
)
88

99
bazel_dep(name = "bazel-orfs")
10+
1011
# To bump version, run: bazelisk run @bazel-orfs//:bump
1112
git_override(
1213
module_name = "bazel-orfs",
@@ -41,7 +42,26 @@ pip.parse(
4142
)
4243
use_repo(pip, "orfs-pip")
4344

45+
# HACK! While we're waiting for OpenROAD to switch to bzlmod
46+
new_local_repository = use_repo_rule("@bazel_tools//tools/build_defs/repo:local.bzl", "new_local_repository")
47+
48+
new_local_repository(
49+
name = "openroad",
50+
build_file_content = """
51+
exports_files(["openroad"],
52+
visibility = ["//visibility:public"],
53+
)
54+
filegroup(
55+
name = "all",
56+
data = glob(["**/*"]),
57+
visibility = ["//visibility:public"],
58+
)
59+
""",
60+
path = "../tools/OpenROAD/bazel-out/k8-opt/bin",
61+
)
62+
4463
orfs = use_extension("@bazel-orfs//:extension.bzl", "orfs_repositories")
64+
4565
# To bump version, run: bazelisk run @bazel-orfs//:bump
4666
orfs.default(
4767
# Check out the version you want to test and make any modifications locally:
@@ -59,8 +79,16 @@ orfs.default(
5979
# TODO once openroad is switched to MODULE.bazel, use
6080
# local_path_override(module_name = "openroad", path = "../tools/OpenROAD")
6181
# to point to the local openroad Bazel module instead of
62-
# getting the openroad binary from the docker image.
63-
openroad = "@docker_orfs//:openroad",
82+
# getting the openroad binary from the docker image, supports GUI.
83+
#
84+
# openroad = "@docker_orfs//:openroad",
85+
86+
# Use locally built OpenROAD while we're waiting for OpenROAD
87+
# to bzlmod, no GUI for now.
88+
#
89+
# cd ../tools/OpenROAD
90+
# bazelisk build -c opt :openroad
91+
openroad = "//test:openroad",
6492
pdk = "//:asap7",
6593
sha256 = "3e42fe9dc5c71a79ccfce479a841a5f4d4ee327347483b2e0a64b3de9af4d390",
6694
)

flow/MODULE.bazel.lock

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

flow/test/BUILD

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sh_binary(
2+
name = "openroad",
3+
srcs = ["openroad.sh"],
4+
data = [
5+
"@openroad",
6+
"@openroad//:all",
7+
],
8+
visibility = ["//visibility:public"],
9+
)

flow/test/openroad.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
set -e
3+
# HACK while we're waiting for OpenROAD to be switched to MODULE.bazel
4+
# OpenROAD has its own TCL library
5+
unset TCL_LIBRARY
6+
./external/_main~_repo_rules~openroad/openroad "$@"

flow/util/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ filegroup(
3636
filegroup(
3737
name = "makefile_yosys",
3838
srcs = glob(MAKEFILE_SHARED) + [
39-
"preprocessLib.py",
4039
"mergeLib.pl",
40+
"preprocessLib.py",
4141
],
4242
visibility = ["//visibility:public"],
4343
)

0 commit comments

Comments
 (0)