From c50a4a077f87faf33a0ed291b253f516adf1f512 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Mon, 16 Mar 2026 06:40:54 +0100 Subject: [PATCH 1/4] Add bazelisk run //:install MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit bazelisk run //:install Builds and installs OpenROAD (with GUI), Yosys, and yosys-slang to tools/install/. Re-runs are instant (stamp file per submodule commit). No sudo required. On Ubuntu, checks for missing -dev packages before building and fails fast with the apt install command. Other platforms not checked (we can't test them, contributions welcome). Docs updated to present Bazel / Nix / CMake as three equal paths. Zero churn: no changes to DependencyInstaller.sh, flow/, setup.sh, build_openroad.sh, or Nix flakes. Tested: gcd/nangate45 synth, asap7/uart synth (yosys-slang). Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Øyvind Harboe --- BUILD.bazel | 6 ++ MODULE.bazel | 1 + MODULE.bazel.lock | 3 +- bazel/install.sh | 164 ++++++++++++++++++++++++++++++++++++++ docs/user/BuildLocally.md | 71 +++++++++-------- 5 files changed, 210 insertions(+), 35 deletions(-) create mode 100644 BUILD.bazel create mode 100755 bazel/install.sh diff --git a/BUILD.bazel b/BUILD.bazel new file mode 100644 index 0000000000..f0f4077bf3 --- /dev/null +++ b/BUILD.bazel @@ -0,0 +1,6 @@ +load("@rules_shell//shell:sh_binary.bzl", "sh_binary") + +sh_binary( + name = "install", + srcs = ["bazel/install.sh"], +) diff --git a/MODULE.bazel b/MODULE.bazel index 574d678f5d..9687e51c48 100644 --- a/MODULE.bazel +++ b/MODULE.bazel @@ -16,6 +16,7 @@ git_override( ) bazel_dep(name = "rules_python", version = "1.2.0") +bazel_dep(name = "rules_shell", version = "0.6.1") python = use_extension("@rules_python//python/extensions:python.bzl", "python") python.toolchain( diff --git a/MODULE.bazel.lock b/MODULE.bazel.lock index 45ece7112e..ffe386712a 100644 --- a/MODULE.bazel.lock +++ b/MODULE.bazel.lock @@ -124,7 +124,8 @@ "https://bcr.bazel.build/modules/rules_python/1.2.0/MODULE.bazel": "5aeeb48b2a6c19d668b48adf2b8a2b209a6310c230db0ce77450f148a89846e4", "https://bcr.bazel.build/modules/rules_python/1.2.0/source.json": "5b7892685c9a843526fd5a31e7d7a93eb819c59fd7b7fc444b5b143558e1b073", "https://bcr.bazel.build/modules/rules_shell/0.2.0/MODULE.bazel": "fda8a652ab3c7d8fee214de05e7a9916d8b28082234e8d2c0094505c5268ed3c", - "https://bcr.bazel.build/modules/rules_shell/0.2.0/source.json": "7f27af3c28037d9701487c4744b5448d26537cc66cdef0d8df7ae85411f8de95", + "https://bcr.bazel.build/modules/rules_shell/0.6.1/MODULE.bazel": "72e76b0eea4e81611ef5452aa82b3da34caca0c8b7b5c0c9584338aa93bae26b", + "https://bcr.bazel.build/modules/rules_shell/0.6.1/source.json": "20ec05cd5e592055e214b2da8ccb283c7f2a421ea0dc2acbf1aa792e11c03d0c", "https://bcr.bazel.build/modules/stardoc/0.5.1/MODULE.bazel": "1a05d92974d0c122f5ccf09291442580317cdd859f07a8655f1db9a60374f9f8", "https://bcr.bazel.build/modules/stardoc/0.5.3/MODULE.bazel": "c7f6948dae6999bf0db32c1858ae345f112cacf98f174c7a8bb707e41b974f1c", "https://bcr.bazel.build/modules/stardoc/0.6.2/MODULE.bazel": "7060193196395f5dd668eda046ccbeacebfd98efc77fed418dbe2b82ffaa39fd", diff --git a/bazel/install.sh b/bazel/install.sh new file mode 100755 index 0000000000..9b548e4386 --- /dev/null +++ b/bazel/install.sh @@ -0,0 +1,164 @@ +#!/bin/bash +set -e + +# ORFS install script +# Single user-facing entry point: bazelisk run //:install +# +# Builds and installs tools to tools/install/ where flow/Makefile expects them. +# Uses stamp files for fast no-op re-runs (seconds when nothing changed). + +WORKSPACE="${BUILD_WORKSPACE_DIRECTORY:-.}" +INSTALL_DIR="${WORKSPACE}/tools/install" +NUM_THREADS=$(nproc) + +usage() { + cat <<'EOF' +Usage: bazelisk run //:install [-- OPTIONS] + +Installs tools required for the ORFS flow/Makefile. + +Installed: + openroad OpenROAD with GUI support + yosys Yosys synthesis tool + yosys-slang Yosys SystemVerilog plugin + +Not yet supported (use sudo ./setup.sh): + klayout KLayout layout viewer + kepler Kepler formal verification + +Nix users: nix develop already provides all tools. See flake.nix. + +Options: + --help, -h Show this help + --skip-openroad Skip OpenROAD build + --threads N Compilation threads (default: nproc) +EOF + exit 0 +} + +# Check for required system dependencies before expensive builds. +# ORFS checks deps for what it builds (yosys/slang). OpenROAD checks +# its own deps in tools/OpenROAD/bazel/install.sh (separation of concerns). +# +# Currently only Ubuntu/Debian is checked. Dependency checking for +# other platforms (macOS, RHEL, Fedora, etc.) is not implemented +# because we cannot test them. Contributions welcome. +check_ubuntu_deps() { + local missing_cmds=() + local missing_pkgs=() + + # Commands needed for yosys build + command -v bison &>/dev/null || { missing_cmds+=(bison); missing_pkgs+=(bison); } + command -v flex &>/dev/null || { missing_cmds+=(flex); missing_pkgs+=(flex); } + command -v gawk &>/dev/null || { missing_cmds+=(gawk); missing_pkgs+=(gawk); } + command -v g++ &>/dev/null || { missing_cmds+=(g++); missing_pkgs+=(g++); } + command -v pkg-config &>/dev/null || { missing_cmds+=(pkg-config); missing_pkgs+=(pkg-config); } + command -v tclsh &>/dev/null || { missing_cmds+=(tclsh); missing_pkgs+=(tcl); } + command -v git &>/dev/null || { missing_cmds+=(git); missing_pkgs+=(git); } + command -v cmake &>/dev/null || { missing_cmds+=(cmake); missing_pkgs+=(cmake); } + + # Dev libraries needed for yosys/slang compilation (check via dpkg) + for pkg in tcl-dev libffi-dev libreadline-dev zlib1g-dev; do + if ! dpkg -s "$pkg" &>/dev/null 2>&1; then + missing_pkgs+=("$pkg") + fi + done + + if [[ ${#missing_pkgs[@]} -gt 0 ]]; then + echo "ERROR: Missing dependencies for Yosys build." + if [[ ${#missing_cmds[@]} -gt 0 ]]; then + echo " Missing commands: ${missing_cmds[*]}" + fi + echo "" + echo "On Ubuntu this would be:" + echo " sudo apt install ${missing_pkgs[*]}" + exit 1 + fi +} + +if command -v dpkg &>/dev/null; then + check_ubuntu_deps +fi + +BUILD_OPENROAD=1 + +while [[ $# -gt 0 ]]; do + case "$1" in + --help|-h) + usage + ;; + --skip-openroad) + BUILD_OPENROAD=0 + ;; + --threads) + NUM_THREADS="$2" + shift + ;; + *) + echo "Unknown option: $1" + usage + ;; + esac + shift +done + +# --- Check submodules are initialized --- +for sub in tools/OpenROAD tools/yosys tools/yosys-slang; do + if [[ ! -d "${WORKSPACE}/${sub}" ]] || [[ -z "$(ls -A "${WORKSPACE}/${sub}" 2>/dev/null)" ]]; then + echo "ERROR: ${sub} not initialized." + echo "Run: git submodule update --init --recursive" + exit 1 + fi +done + +# --- OpenROAD (delegates to its own //:install) --- +if [[ $BUILD_OPENROAD -eq 1 ]]; then + echo "=== Building OpenROAD with GUI support ===" + (cd "${WORKSPACE}/tools/OpenROAD" && bazelisk run --//:platform=gui //:install) +fi + +# --- Yosys --- +# Uses stamp file for fast no-op: if the yosys submodule commit hasn't +# changed, skip the build entirely. +YOSYS_INSTALL="${INSTALL_DIR}/yosys" +YOSYS_STAMP="${YOSYS_INSTALL}/.yosys_commit" +YOSYS_COMMIT="$(git -C "${WORKSPACE}/tools/yosys" rev-parse HEAD)" + +if [[ -f "${YOSYS_STAMP}" ]] && [[ "$(cat "${YOSYS_STAMP}")" == "${YOSYS_COMMIT}" ]]; then + echo "=== Yosys already up to date (${YOSYS_COMMIT:0:12}) ===" +else + echo "=== Building Yosys ===" + ( + cd "${WORKSPACE}/tools/yosys" + make -j "${NUM_THREADS}" PREFIX="${YOSYS_INSTALL}" ABC_ARCHFLAGS=-Wno-register + make install PREFIX="${YOSYS_INSTALL}" + ) + echo "${YOSYS_COMMIT}" > "${YOSYS_STAMP}" + echo "Yosys installed to ${YOSYS_INSTALL}/bin/yosys" +fi + +# --- yosys-slang --- +SLANG_STAMP="${YOSYS_INSTALL}/.slang_commit" +SLANG_COMMIT="$(git -C "${WORKSPACE}/tools/yosys-slang" rev-parse HEAD)" + +if [[ -f "${SLANG_STAMP}" ]] && [[ "$(cat "${SLANG_STAMP}")" == "${SLANG_COMMIT}" ]]; then + echo "=== yosys-slang already up to date (${SLANG_COMMIT:0:12}) ===" +else + echo "=== Building yosys-slang ===" + ( + cd "${WORKSPACE}/tools/yosys-slang" + cmake -S . -B build \ + -DYOSYS_CONFIG="${YOSYS_INSTALL}/bin/yosys-config" \ + -DCMAKE_BUILD_TYPE=Release \ + -DYOSYS_SLANG_REVISION=unknown \ + -DSLANG_REVISION=unknown + cmake --build build -j "${NUM_THREADS}" + cmake --install build --prefix "${YOSYS_INSTALL}" + ) + echo "${SLANG_COMMIT}" > "${SLANG_STAMP}" + echo "yosys-slang installed to ${YOSYS_INSTALL}/share/yosys/plugins/" +fi + +echo "" +echo "=== Done ===" +echo "cd flow && make" diff --git a/docs/user/BuildLocally.md b/docs/user/BuildLocally.md index 79a2dd09aa..f388d64f3e 100644 --- a/docs/user/BuildLocally.md +++ b/docs/user/BuildLocally.md @@ -1,33 +1,49 @@ # Build from sources locally -## Clone and Install Dependencies +## Choose Your Build Path -The `setup.sh` script installs all of the dependencies, including OpenROAD dependencies, if they are not already installed. +| Path | Prerequisites | sudo? | Best for | +|------|--------------|-------|----------| +| **Bazel** | [Bazelisk](https://bazel.build/install/bazelisk) | No | Most users | +| **Nix** | [Nix](https://github.com/DeterminateSystems/nix-installer) | No | Nix users | +| **CMake** | `sudo ./setup.sh` | Yes | Existing CMake developers | -Supported configurations are: Ubuntu 20.04, Ubuntu 22.04, Ubuntu 22.04(aarch64), RHEL 8, RockyLinux 9 and Debian 11. +### Bazel (recommended) + +Install [Bazelisk](https://bazel.build/install/bazelisk) following the +[official instructions](https://bazel.build/install/bazelisk). ``` shell git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts cd OpenROAD-flow-scripts -sudo ./setup.sh +bazelisk run //:install +cd flow && make ``` -## Using Bazel to build OpenROAD and run the ORFS flow - -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. +For options: `bazelisk run //:install -- --help` -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: +### Nix ``` shell -cd tools/OpenROAD -bazelisk test src/drt/... -cd ../../flow -make OPENROAD_EXE=$(pwd)/../tools/OpenROAD/bazel-out/k8-opt-exec-ST-*/bin/openroad +git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts +cd OpenROAD-flow-scripts +nix develop +cd flow && make ``` -Bazel could similarly be used to download and make available pre-built binaries for tools such as Yosys, eqy and KLayout. +### CMake (existing path) + +## Clone and Install Dependencies + +The `setup.sh` script installs all of the dependencies, including OpenROAD dependencies, if they are not already installed. + +Supported configurations are: Ubuntu 20.04, Ubuntu 22.04, Ubuntu 22.04(aarch64), RHEL 8, RockyLinux 9 and Debian 11. -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. +``` shell +git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts +cd OpenROAD-flow-scripts +sudo ./setup.sh +``` ## Build @@ -72,35 +88,22 @@ Set up environment variables using `dev_env.sh`, then start Visual Studio Code. code tools/OpenROAD/ ``` -## Build OpenROAD and run a few ORFS flows with Bazel - -Local use case: +## Build and run ORFS flows with Bazel -- Install Bazelisk and no other dependencies, no need to run `sudo ./setup.sh` -- Modify & build OpenROAD -- Test built OpenROAD with a few ORFS flows +ORFS uses [bazel-orfs](https://github.com/The-OpenROAD-Project/bazel-orfs) to run +the flow entirely within Bazel. This is separate from `bazelisk run //:install` above +which installs tools for the Makefile-based flow. -The Bazel support in OpenROAD and ORFS is work in progress and some Bazel experience is recommended before going spelunking in the Bazel builds. - -Contributions welcome! - -To build `designs/asap7/gcd:gcd_floorplan`: - - cd flow - (cd ../tools/OpenROAD && bazel build :openroad -c opt) && bazelisk build designs/asap7/gcd:gcd_floorplan - -Or to run all flows currently available in Bazel +To build a design with Bazel: cd flow - (cd ../tools/OpenROAD && bazel build :openroad -c opt) && bazelisk build ... + bazelisk build designs/asap7/gcd:gcd_floorplan -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: +Or to run all flows currently available in Bazel: cd flow bazelisk build ... -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. - ### Upgrading MODULE.bazel with the latest bazel-orfs and ORFS Docker image Run: From 3d9a3f7b533a52255d9a2617180bf8ccbb93a159 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Tue, 17 Mar 2026 21:45:35 +0100 Subject: [PATCH 2/4] Strip //:install to developer-only MVP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Remove Ubuntu dep checking, --skip-openroad flag, and verbose help text. Docs: position Bazel as unsupported developer-only option, CMake first. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Øyvind Harboe --- bazel/install.sh | 67 +++------------------------------------ docs/user/BuildLocally.md | 50 +++++++++++++---------------- 2 files changed, 27 insertions(+), 90 deletions(-) diff --git a/bazel/install.sh b/bazel/install.sh index 9b548e4386..983dcf9d9c 100755 --- a/bazel/install.sh +++ b/bazel/install.sh @@ -1,33 +1,22 @@ #!/bin/bash set -e -# ORFS install script -# Single user-facing entry point: bazelisk run //:install +# ORFS developer install script +# Builds and installs OpenROAD, Yosys, and yosys-slang to tools/install/ +# where flow/Makefile expects them. # -# Builds and installs tools to tools/install/ where flow/Makefile expects them. # Uses stamp files for fast no-op re-runs (seconds when nothing changed). WORKSPACE="${BUILD_WORKSPACE_DIRECTORY:-.}" INSTALL_DIR="${WORKSPACE}/tools/install" NUM_THREADS=$(nproc) +BUILD_OPENROAD=1 + usage() { cat <<'EOF' Usage: bazelisk run //:install [-- OPTIONS] -Installs tools required for the ORFS flow/Makefile. - -Installed: - openroad OpenROAD with GUI support - yosys Yosys synthesis tool - yosys-slang Yosys SystemVerilog plugin - -Not yet supported (use sudo ./setup.sh): - klayout KLayout layout viewer - kepler Kepler formal verification - -Nix users: nix develop already provides all tools. See flake.nix. - Options: --help, -h Show this help --skip-openroad Skip OpenROAD build @@ -36,52 +25,6 @@ EOF exit 0 } -# Check for required system dependencies before expensive builds. -# ORFS checks deps for what it builds (yosys/slang). OpenROAD checks -# its own deps in tools/OpenROAD/bazel/install.sh (separation of concerns). -# -# Currently only Ubuntu/Debian is checked. Dependency checking for -# other platforms (macOS, RHEL, Fedora, etc.) is not implemented -# because we cannot test them. Contributions welcome. -check_ubuntu_deps() { - local missing_cmds=() - local missing_pkgs=() - - # Commands needed for yosys build - command -v bison &>/dev/null || { missing_cmds+=(bison); missing_pkgs+=(bison); } - command -v flex &>/dev/null || { missing_cmds+=(flex); missing_pkgs+=(flex); } - command -v gawk &>/dev/null || { missing_cmds+=(gawk); missing_pkgs+=(gawk); } - command -v g++ &>/dev/null || { missing_cmds+=(g++); missing_pkgs+=(g++); } - command -v pkg-config &>/dev/null || { missing_cmds+=(pkg-config); missing_pkgs+=(pkg-config); } - command -v tclsh &>/dev/null || { missing_cmds+=(tclsh); missing_pkgs+=(tcl); } - command -v git &>/dev/null || { missing_cmds+=(git); missing_pkgs+=(git); } - command -v cmake &>/dev/null || { missing_cmds+=(cmake); missing_pkgs+=(cmake); } - - # Dev libraries needed for yosys/slang compilation (check via dpkg) - for pkg in tcl-dev libffi-dev libreadline-dev zlib1g-dev; do - if ! dpkg -s "$pkg" &>/dev/null 2>&1; then - missing_pkgs+=("$pkg") - fi - done - - if [[ ${#missing_pkgs[@]} -gt 0 ]]; then - echo "ERROR: Missing dependencies for Yosys build." - if [[ ${#missing_cmds[@]} -gt 0 ]]; then - echo " Missing commands: ${missing_cmds[*]}" - fi - echo "" - echo "On Ubuntu this would be:" - echo " sudo apt install ${missing_pkgs[*]}" - exit 1 - fi -} - -if command -v dpkg &>/dev/null; then - check_ubuntu_deps -fi - -BUILD_OPENROAD=1 - while [[ $# -gt 0 ]]; do case "$1" in --help|-h) diff --git a/docs/user/BuildLocally.md b/docs/user/BuildLocally.md index f388d64f3e..df09d2de0b 100644 --- a/docs/user/BuildLocally.md +++ b/docs/user/BuildLocally.md @@ -4,23 +4,29 @@ | Path | Prerequisites | sudo? | Best for | |------|--------------|-------|----------| -| **Bazel** | [Bazelisk](https://bazel.build/install/bazelisk) | No | Most users | +| **CMake** | `sudo ./setup.sh` | Yes | Most users | | **Nix** | [Nix](https://github.com/DeterminateSystems/nix-installer) | No | Nix users | -| **CMake** | `sudo ./setup.sh` | Yes | Existing CMake developers | +| **Bazel** | [Bazelisk](https://bazel.build/install/bazelisk) | No | ORFS/OpenROAD developers only, unsupported | -### Bazel (recommended) +### CMake -Install [Bazelisk](https://bazel.build/install/bazelisk) following the -[official instructions](https://bazel.build/install/bazelisk). +The `setup.sh` script installs all of the dependencies, including OpenROAD dependencies, if they are not already installed. + +Supported configurations are: Ubuntu 20.04, Ubuntu 22.04, Ubuntu 22.04(aarch64), RHEL 8, RockyLinux 9 and Debian 11. ``` shell git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts cd OpenROAD-flow-scripts -bazelisk run //:install -cd flow && make +sudo ./setup.sh +./build_openroad.sh --local ``` -For options: `bazelisk run //:install -- --help` +:::{Note} +There is a `build_openroad.log` file that is generated with every +build in the main directory. In case of filing issues, it can be uploaded +in the "Relevant log output" section of OpenROAD-flow-scripts repo +[issue form](https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/issues/new?assignees=&labels=&template=bug_report_with_orfs.yml). +::: ### Nix @@ -31,36 +37,24 @@ nix develop cd flow && make ``` -### CMake (existing path) - -## Clone and Install Dependencies +### Bazel -The `setup.sh` script installs all of the dependencies, including OpenROAD dependencies, if they are not already installed. - -Supported configurations are: Ubuntu 20.04, Ubuntu 22.04, Ubuntu 22.04(aarch64), RHEL 8, RockyLinux 9 and Debian 11. +For ORFS/OpenROAD developers. Most of `./setup.sh` isn't needed when +building OpenROAD with Bazel — this provides the bare minimum to build +OpenROAD and test ORFS flows. No sudo required. +Install [Bazelisk](https://bazel.build/install/bazelisk) first. ``` shell git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts cd OpenROAD-flow-scripts -sudo ./setup.sh -``` - -## Build - -``` shell -./build_openroad.sh --local +bazelisk run //:install +cd flow && make ``` -:::{Note} -There is a `build_openroad.log` file that is generated with every -build in the main directory. In case of filing issues, it can be uploaded -in the "Relevant log output" section of OpenROAD-flow-scripts repo -[issue form](https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/issues/new?assignees=&labels=&template=bug_report_with_orfs.yml). -::: ## Verify Installation The binaries should be available on your `$PATH` after setting -up the environment. The `make` command runs from RTL-GDSII generation for default design `gcd` with `nangate45` PDK. +up the environment. The `make` command runs from RTL-GDSII generation for default design `gcd` with `nangate45` PDK. ``` shell source ./env.sh From d523296236393aa710d84eb20b9aa776162b5274 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Tue, 17 Mar 2026 22:53:22 +0100 Subject: [PATCH 3/4] Strip //:install to developer-only MVP MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add cross-platform dep checking (Ubuntu, RHEL, macOS, openSUSE). Remove verbose help text. Docs: replace outdated Bazel section with //:install, mark as unsupported developer-only path. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Øyvind Harboe --- bazel/install.sh | 34 +++++++++++++++++++ docs/user/BuildLocally.md | 70 +++++++++++++++++++-------------------- 2 files changed, 69 insertions(+), 35 deletions(-) diff --git a/bazel/install.sh b/bazel/install.sh index 983dcf9d9c..7c076b7480 100755 --- a/bazel/install.sh +++ b/bazel/install.sh @@ -11,6 +11,40 @@ WORKSPACE="${BUILD_WORKSPACE_DIRECTORY:-.}" INSTALL_DIR="${WORKSPACE}/tools/install" NUM_THREADS=$(nproc) +# --- Check system dependencies for yosys/slang builds --- +check_deps() { + local missing_cmds=() + + for cmd in bison flex gawk g++ pkg-config tclsh git cmake; do + if ! command -v "$cmd" &>/dev/null; then + missing_cmds+=("$cmd") + fi + done + + if [[ ${#missing_cmds[@]} -eq 0 ]]; then + return + fi + + echo "ERROR: Missing commands: ${missing_cmds[*]}" + echo "" + + # Platform-specific install hint + if [[ "$(uname -s)" == "Darwin" ]]; then + echo " brew install bison flex gawk cmake pkg-config tcl-tk" + elif command -v apt-get &>/dev/null; then + echo " sudo apt-get install bison flex gawk g++ pkg-config tcl cmake git" + elif command -v dnf &>/dev/null; then + echo " sudo dnf install bison flex gawk gcc-c++ pkgconf tcl cmake git" + elif command -v yum &>/dev/null; then + echo " sudo yum install bison flex gawk gcc-c++ pkgconf tcl cmake git" + elif command -v zypper &>/dev/null; then + echo " sudo zypper install bison flex gawk gcc-c++ pkg-config tcl cmake git" + fi + exit 1 +} + +check_deps + BUILD_OPENROAD=1 usage() { diff --git a/docs/user/BuildLocally.md b/docs/user/BuildLocally.md index df09d2de0b..17ed45db5b 100644 --- a/docs/user/BuildLocally.md +++ b/docs/user/BuildLocally.md @@ -1,14 +1,6 @@ # Build from sources locally -## Choose Your Build Path - -| Path | Prerequisites | sudo? | Best for | -|------|--------------|-------|----------| -| **CMake** | `sudo ./setup.sh` | Yes | Most users | -| **Nix** | [Nix](https://github.com/DeterminateSystems/nix-installer) | No | Nix users | -| **Bazel** | [Bazelisk](https://bazel.build/install/bazelisk) | No | ORFS/OpenROAD developers only, unsupported | - -### CMake +## Clone and Install Dependencies The `setup.sh` script installs all of the dependencies, including OpenROAD dependencies, if they are not already installed. @@ -18,26 +10,9 @@ Supported configurations are: Ubuntu 20.04, Ubuntu 22.04, Ubuntu 22.04(aarch64), git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts cd OpenROAD-flow-scripts sudo ./setup.sh -./build_openroad.sh --local -``` - -:::{Note} -There is a `build_openroad.log` file that is generated with every -build in the main directory. In case of filing issues, it can be uploaded -in the "Relevant log output" section of OpenROAD-flow-scripts repo -[issue form](https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/issues/new?assignees=&labels=&template=bug_report_with_orfs.yml). -::: - -### Nix - -``` shell -git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts -cd OpenROAD-flow-scripts -nix develop -cd flow && make ``` -### Bazel +## Using Bazel to build OpenROAD and run the ORFS flow (unsupported) For ORFS/OpenROAD developers. Most of `./setup.sh` isn't needed when building OpenROAD with Bazel — this provides the bare minimum to build @@ -51,10 +26,22 @@ bazelisk run //:install cd flow && make ``` +## Build + +``` shell +./build_openroad.sh --local +``` +:::{Note} +There is a `build_openroad.log` file that is generated with every +build in the main directory. In case of filing issues, it can be uploaded +in the "Relevant log output" section of OpenROAD-flow-scripts repo +[issue form](https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts/issues/new?assignees=&labels=&template=bug_report_with_orfs.yml). +::: + ## Verify Installation The binaries should be available on your `$PATH` after setting -up the environment. The `make` command runs from RTL-GDSII generation for default design `gcd` with `nangate45` PDK. +up the environment. The `make` command runs from RTL-GDSII generation for default design `gcd` with `nangate45` PDK. ``` shell source ./env.sh @@ -82,22 +69,35 @@ Set up environment variables using `dev_env.sh`, then start Visual Studio Code. code tools/OpenROAD/ ``` -## Build and run ORFS flows with Bazel +## Build OpenROAD and run a few ORFS flows with Bazel + +Local use case: + +- Install Bazelisk and no other dependencies, no need to run `sudo ./setup.sh` +- Modify & build OpenROAD +- Test built OpenROAD with a few ORFS flows + +The Bazel support in OpenROAD and ORFS is work in progress and some Bazel experience is recommended before going spelunking in the Bazel builds. -ORFS uses [bazel-orfs](https://github.com/The-OpenROAD-Project/bazel-orfs) to run -the flow entirely within Bazel. This is separate from `bazelisk run //:install` above -which installs tools for the Makefile-based flow. +Contributions welcome! -To build a design with Bazel: +To build `designs/asap7/gcd:gcd_floorplan`: cd flow - bazelisk build designs/asap7/gcd:gcd_floorplan + (cd ../tools/OpenROAD && bazel build :openroad -c opt) && bazelisk build designs/asap7/gcd:gcd_floorplan -Or to run all flows currently available in Bazel: +Or to run all flows currently available in Bazel + + cd flow + (cd ../tools/OpenROAD && bazel build :openroad -c opt) && bazelisk build ... + +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: cd flow bazelisk build ... +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. + ### Upgrading MODULE.bazel with the latest bazel-orfs and ORFS Docker image Run: From 5d9832d326b4a21dd16b302ee5911301444b0540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=98yvind=20Harboe?= Date: Thu, 19 Mar 2026 00:04:13 +0100 Subject: [PATCH 4/4] Rename //:install to //:install_for_bazel MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Address review feedback: make it clear this is not a general-purpose installer but specifically for bazel-orfs developers. Co-Authored-By: Claude Opus 4.6 (1M context) Signed-off-by: Øyvind Harboe --- BUILD.bazel | 2 +- bazel/install.sh | 2 +- docs/user/BuildLocally.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BUILD.bazel b/BUILD.bazel index f0f4077bf3..21e694405f 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -1,6 +1,6 @@ load("@rules_shell//shell:sh_binary.bzl", "sh_binary") sh_binary( - name = "install", + name = "install_for_bazel", srcs = ["bazel/install.sh"], ) diff --git a/bazel/install.sh b/bazel/install.sh index 7c076b7480..21a3f48c01 100755 --- a/bazel/install.sh +++ b/bazel/install.sh @@ -49,7 +49,7 @@ BUILD_OPENROAD=1 usage() { cat <<'EOF' -Usage: bazelisk run //:install [-- OPTIONS] +Usage: bazelisk run //:install_for_bazel [-- OPTIONS] Options: --help, -h Show this help diff --git a/docs/user/BuildLocally.md b/docs/user/BuildLocally.md index 17ed45db5b..120b4f943e 100644 --- a/docs/user/BuildLocally.md +++ b/docs/user/BuildLocally.md @@ -22,7 +22,7 @@ Install [Bazelisk](https://bazel.build/install/bazelisk) first. ``` shell git clone --recursive https://github.com/The-OpenROAD-Project/OpenROAD-flow-scripts cd OpenROAD-flow-scripts -bazelisk run //:install +bazelisk run //:install_for_bazel cd flow && make ```