Skip to content

Commit 974dc61

Browse files
oharboeclaude
andcommitted
Add -bazel flag to skip OpenROAD build dependencies
Add -bazel option to DependencyInstaller.sh and setup.sh that skips OpenROAD-specific build dependencies (boost, swig, spdlog, eigen, or-tools, etc.) which Bazel manages, while still installing flow-level dependencies and building Yosys/eqy/sby. This supports the new `bazelisk run //:setup-orfs` target in OpenROAD which provides a single entry point for developer environment setup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 62c4739 commit 974dc61

5 files changed

Lines changed: 179 additions & 38 deletions

File tree

‎docs/user/BuildLocally.md‎

Lines changed: 40 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,47 @@ sudo ./setup.sh
1414

1515
## Using Bazel to build OpenROAD and run the ORFS flow
1616

17-
Long story short: OpenROAD will eventually switch to using Bazel for downloading dependencies and building OpenROAD for all the reasons that the DependencyInstaller.sh and cmake are hard to support and brittle across platforms.
17+
OpenROAD is switching to Bazel for dependency management and building.
18+
Bazel eliminates the need for the complex `DependencyInstaller.sh` and
19+
cmake toolchain for OpenROAD itself.
1820

19-
Currently the simplest way to build OpenROAD and run ORFS is to run one test, which will download all OpenROAD dependencies and build OpenROAD in the exec configuration:
21+
### Setup
22+
23+
Install ORFS flow dependencies with user permissions:
24+
25+
``` shell
26+
cd tools/OpenROAD
27+
bazelisk run //:setup-orfs
28+
```
29+
30+
If system packages are missing, the command prints the exact `sudo` command
31+
to run and exits. This way the user sees what will be installed with root
32+
privileges before it happens — nothing is silently written to system
33+
directories. In educational and corporate environments where `sudo` is
34+
controlled by IT policy, the printed command can be handed off to an
35+
administrator. Running `sudo` separately also benefits from the system's
36+
apt cache on repeated runs. User-level tools (Yosys, eqy, sby) are built
37+
into the project's `dependencies/` directory with user permissions only.
38+
39+
After installing system packages, re-run `bazelisk run //:setup-orfs` to
40+
complete setup.
41+
42+
This installs the minimum tooling that Bazel does not yet manage (currently
43+
Yosys, eqy, sby, KLayout, and Python packages). Over time, more of these
44+
may move into Bazel, but that is an implementation detail — this command
45+
remains the single entry point for developers.
46+
47+
### Build OpenROAD and run the flow
48+
49+
``` shell
50+
cd tools/OpenROAD
51+
bazelisk run --//:platform=gui //:install
52+
cd ../../flow
53+
source ../env.sh
54+
make
55+
```
56+
57+
Or without installing, run an ORFS flow using the exec-built OpenROAD:
2058

2159
``` shell
2260
cd tools/OpenROAD
@@ -25,8 +63,6 @@ cd ../../flow
2563
make OPENROAD_EXE=$(pwd)/../tools/OpenROAD/bazel-out/k8-opt-exec-ST-*/bin/openroad
2664
```
2765

28-
Bazel could similarly be used to download and make available pre-built binaries for tools such as Yosys, eqy and KLayout.
29-
3066
Running some quick tests will cause the desired exec config of OpenROAD to be built. There's no explicit Bazel way to build an exec config of an executable and we want to to use an exec config that is the same binary as is used for a local OpenROAD modify + test Bazel cycle.
3167

3268
## Build

‎env.sh‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ function __setpaths() {
1414
export PATH=${DIR}/tools/install/OpenROAD/bin:$PATH
1515
export PATH=${DIR}/tools/install/yosys/bin:$PATH
1616
export PATH=${DIR}/tools/install/kepler-formal/bin:$PATH
17+
export PATH=${DIR}/dependencies/bin:$PATH
1718

1819
if [[ "$OSTYPE" == "darwin"* ]]; then
1920
export PATH="/Applications/KLayout/klayout.app/Contents/MacOS:$PATH"

‎etc/DependencyInstaller.sh‎

Lines changed: 117 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,59 @@ _installORDependencies() {
2626
./tools/OpenROAD/etc/DependencyInstaller.sh ${OR_INSTALLER_ARGS} -yosys-ver="${YOSYS_VER}"
2727
}
2828

29+
# Install system packages for building Yosys/slang (via OR's -base),
30+
# then build Yosys/eqy/sby directly, skipping OpenROAD-specific build
31+
# dependencies (boost, swig, spdlog, eigen, or-tools, etc.) which Bazel
32+
# manages.
33+
_installBazelFlowDependencies() {
34+
if [[ ${YOSYS_VER} == "" ]]; then
35+
YOSYS_VER=v$(grep 'yosys_ver =' tools/yosys/docs/source/conf.py | awk -F'"' '{print $2}')
36+
fi
37+
# OR's -base installs system packages (build-essential, bison, flex,
38+
# tcl-dev, libreadline-dev, libffi-dev, pkg-config, python3-dev, cmake,
39+
# etc.) needed for building Yosys and yosys-slang.
40+
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
41+
./tools/OpenROAD/etc/DependencyInstaller.sh -base
42+
fi
43+
# Build Yosys/eqy/sby without the full -common pass that would also
44+
# compile boost, swig, spdlog, eigen, gtest, or-tools, abseil, etc.
45+
if [[ "${option}" == "common" || "${option}" == "all" ]]; then
46+
local yosys_prefix=${PREFIX:-"/usr/local"}
47+
local buildDir
48+
buildDir=$(mktemp -d /tmp/orfs-yosys-build-XXXXXX)
49+
50+
echo "Building Yosys ${YOSYS_VER} ..."
51+
(
52+
cd "${buildDir}"
53+
git clone --depth=1 -b "${YOSYS_VER}" --recursive https://github.com/YosysHQ/yosys
54+
cd yosys
55+
make -j "${numThreads}" PREFIX="${yosys_prefix}" ABC_ARCHFLAGS=-Wno-register
56+
make install PREFIX="${yosys_prefix}"
57+
)
58+
59+
echo "Building eqy ${YOSYS_VER} ..."
60+
(
61+
cd "${buildDir}"
62+
git clone --depth=1 -b "${YOSYS_VER}" https://github.com/YosysHQ/eqy
63+
cd eqy
64+
export PATH="${yosys_prefix}/bin:${PATH}"
65+
make -j "${numThreads}" PREFIX="${yosys_prefix}"
66+
make install PREFIX="${yosys_prefix}"
67+
)
68+
69+
echo "Building sby ${YOSYS_VER} ..."
70+
(
71+
cd "${buildDir}"
72+
git clone --depth=1 -b "${YOSYS_VER}" --recursive https://github.com/YosysHQ/sby
73+
cd sby
74+
export PATH="${yosys_prefix}/bin:${PATH}"
75+
make -j "${numThreads}" PREFIX="${yosys_prefix}" install
76+
)
77+
78+
rm -rf "${buildDir}"
79+
fi
80+
}
81+
2982
_installPipCommon() {
3083
if [[ -f /opt/rh/rh-python38/enable ]]; then
3184
set +u
@@ -150,41 +203,51 @@ _installKlayoutDependenciesUbuntuAarch64() {
150203
_installUbuntuPackages() {
151204
export DEBIAN_FRONTEND="noninteractive"
152205
apt-get -y update
206+
207+
# Flow-level packages needed regardless of how OpenROAD is built
153208
apt-get -y install --no-install-recommends \
154-
bison \
155209
curl \
156-
flex \
157-
help2man \
158-
libfl-dev \
159-
libfl2 \
160-
libgit2-dev \
161-
libgoogle-perftools-dev \
162-
libqt5multimediawidgets5 \
163-
libqt5opengl5 \
164-
libqt5svg5-dev \
165-
libqt5xmlpatterns5-dev \
166-
libz-dev \
167210
perl \
168211
python3-pip \
169212
python3-venv \
170-
qtmultimedia5-dev \
171-
qttools5-dev \
172213
ruby \
173214
ruby-dev \
174-
time \
175-
zlib1g \
176-
zlib1g-dev
177-
178-
packages=()
179-
# Choose libstdc++ version
180-
if _versionCompare $1 -ge 25.04; then
181-
packages+=("libstdc++-15-dev")
182-
elif _versionCompare $1 -ge 24.04; then
183-
packages+=("libstdc++-14-dev")
184-
elif _versionCompare $1 -ge 22.10; then
185-
packages+=("libstdc++-12-dev")
215+
time
216+
217+
if [[ "${BAZEL}" == "no" ]]; then
218+
# Additional packages only needed when building OpenROAD from source
219+
# (not with Bazel). OR's -base already installs core build tools
220+
# (build-essential, bison, flex, etc.). This list covers ORFS-specific
221+
# extras like KLayout Qt deps and profiling.
222+
apt-get -y install --no-install-recommends \
223+
bison \
224+
flex \
225+
help2man \
226+
libfl-dev \
227+
libfl2 \
228+
libgit2-dev \
229+
libgoogle-perftools-dev \
230+
libqt5multimediawidgets5 \
231+
libqt5opengl5 \
232+
libqt5svg5-dev \
233+
libqt5xmlpatterns5-dev \
234+
libz-dev \
235+
qtmultimedia5-dev \
236+
qttools5-dev \
237+
zlib1g \
238+
zlib1g-dev
239+
240+
packages=()
241+
# Choose libstdc++ version
242+
if _versionCompare $1 -ge 25.04; then
243+
packages+=("libstdc++-15-dev")
244+
elif _versionCompare $1 -ge 24.04; then
245+
packages+=("libstdc++-14-dev")
246+
elif _versionCompare $1 -ge 22.10; then
247+
packages+=("libstdc++-12-dev")
248+
fi
249+
apt-get install -y --no-install-recommends ${packages[@]}
186250
fi
187-
apt-get install -y --no-install-recommends ${packages[@]}
188251

189252
# install KLayout
190253
if [[ $1 == "rodete" ]]; then
@@ -316,6 +379,13 @@ Usage: $0 [-all|-base|-common] [-<ARGS>]
316379
$0 -constant-build-dir
317380
# Use constant build directory, instead of
318381
# random one.
382+
$0 -bazel
383+
# Skip OpenROAD build dependencies. Only
384+
# install flow-level dependencies
385+
# (klayout, ruby, docker, pip packages).
386+
# Use this when building OpenROAD with
387+
# Bazel, which manages its own build
388+
# dependencies.
319389
EOF
320390
exit "${1:-1}"
321391
}
@@ -331,6 +401,7 @@ option="none"
331401
isLocal="false"
332402
constantBuildDir="false"
333403
CI="no"
404+
BAZEL="no"
334405

335406
# default values, can be overwritten by cmdline args
336407
while [ "$#" -gt 0 ]; do
@@ -374,6 +445,9 @@ while [ "$#" -gt 0 ]; do
374445
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1"
375446
constantBuildDir="true"
376447
;;
448+
-bazel)
449+
BAZEL="yes"
450+
;;
377451
-threads=*)
378452
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1"
379453
numThreads=${1#*=}
@@ -431,8 +505,12 @@ case "${os}" in
431505
fi
432506

433507
# First install OpenROAD base
434-
_installORDependencies
435-
508+
if [[ "${BAZEL}" == "yes" ]]; then
509+
_installBazelFlowDependencies
510+
else
511+
_installORDependencies
512+
fi
513+
436514
# Determine between EL7 vs EL8/9, since yum vs dnf should be used, and different Klayout builds exist
437515
case "${elVersion}" in
438516
"7")
@@ -468,7 +546,11 @@ case "${os}" in
468546
echo "Installing CI Tools"
469547
_installCI
470548
fi
471-
_installORDependencies
549+
if [[ "${BAZEL}" == "yes" ]]; then
550+
_installBazelFlowDependencies
551+
else
552+
_installORDependencies
553+
fi
472554
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
473555
_installUbuntuPackages "${version}"
474556
_installUbuntuCleanUp
@@ -487,7 +569,11 @@ case "${os}" in
487569
if [[ ${CI} == "yes" ]]; then
488570
echo "WARNING: Installing CI dependencies is only supported on Ubuntu 22.04" >&2
489571
fi
490-
_installORDependencies
572+
if [[ "${BAZEL}" == "yes" ]]; then
573+
_installBazelFlowDependencies
574+
else
575+
_installORDependencies
576+
fi
491577
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
492578
_installDarwinPackages
493579
fi

‎flow/scripts/variables.mk‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,10 @@ export OPENROAD_GUI_CMD = $(OPENROAD_EXE) -gui $(OR_ARGS)
107107
ifneq (${IN_NIX_SHELL},)
108108
YOSYS_EXE ?= $(shell command -v yosys)
109109
else
110-
YOSYS_EXE ?= $(abspath $(FLOW_HOME)/../tools/install/yosys/bin/yosys)
110+
# Check build_openroad.sh location first, then Bazel setup-orfs location
111+
_YOSYS_BUILD := $(abspath $(FLOW_HOME)/../tools/install/yosys/bin/yosys)
112+
_YOSYS_DEPS := $(abspath $(FLOW_HOME)/../dependencies/bin/yosys)
113+
YOSYS_EXE ?= $(if $(shell test -x $(_YOSYS_BUILD) && echo y),$(_YOSYS_BUILD),$(_YOSYS_DEPS))
111114
endif
112115
export YOSYS_EXE
113116

‎setup.sh‎

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,21 @@ if [ $EUID -ne 0 ]; then
1010
exit 1
1111
fi
1212

13+
BAZEL_ARG=""
14+
for arg in "$@"; do
15+
case "${arg}" in
16+
--bazel|-bazel)
17+
BAZEL_ARG="-bazel"
18+
;;
19+
*)
20+
echo "unknown option: ${arg}" >&2
21+
echo "Usage: $0 [--bazel]"
22+
echo " --bazel Skip OpenROAD build dependencies (use when building OpenROAD with Bazel)"
23+
exit 1
24+
;;
25+
esac
26+
done
27+
1328
tmpfile=$(mktemp)
1429
# any error messages from this command will stand out
1530
# more clearly when run as a separate command rather than
@@ -26,5 +41,5 @@ elif grep -q "^+" "$tmpfile"; then
2641
exit 1
2742
fi
2843

29-
"$DIR/etc/DependencyInstaller.sh" -base
30-
sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies"
44+
"$DIR/etc/DependencyInstaller.sh" -base ${BAZEL_ARG}
45+
sudo -u $SUDO_USER "$DIR/etc/DependencyInstaller.sh" -common -prefix="$DIR/dependencies" ${BAZEL_ARG}

0 commit comments

Comments
 (0)