From bba680a85c3bd4ffcc4e2cff47b3677dffa7ea26 Mon Sep 17 00:00:00 2001 From: Vitor Bandeira Date: Wed, 9 Sep 2026 15:32:56 -0300 Subject: [PATCH 1/5] build: install OpenROAD with Bazel OpenROAD Build.sh owns both compilation and installation. Remove the CMake-only argument path and use its Bazel install prefix in the ORFS images. Signed-off-by: Vitor Bandeira --- Dockerfile | 4 ++- build_openroad.sh | 57 +++++++++++++++------------------------ docker/Dockerfile.builder | 3 +-- etc/DockerHelper.sh | 3 --- 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/Dockerfile b/Dockerfile index 98864db40d..d533dac4d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,9 @@ WORKDIR /OpenROAD-flow-scripts COPY --from=openroad/yosys /install ./tools/install/yosys # openroad binary -COPY --from=openroad/ubuntu22.04-builder-gcc /OpenROAD/build/src/openroad ./tools/install/OpenROAD/bin/openroad +COPY --from=openroad/ubuntu22.04-builder-gcc \ + /OpenROAD/install/bin/openroad \ + ./tools/install/OpenROAD/bin/openroad # flow files COPY ./env.sh . diff --git a/build_openroad.sh b/build_openroad.sh index 3c8ec800ad..745b6a12b8 100755 --- a/build_openroad.sh +++ b/build_openroad.sh @@ -23,8 +23,8 @@ INSTALL_PATH="$(pwd)/tools/install" YOSYS_USER_ARGS="" YOSYS_ARGS="" -OPENROAD_APP_USER_ARGS="" -OPENROAD_APP_ARGS="" +OPENROAD_APP_USER_ARGS=() +OPENROAD_APP_ARGS=() DOCKER_OS_NAME="ubuntu22.04" PROC=-1 @@ -77,11 +77,10 @@ Options: to the Verific source folder. --openroad-args-overwrite - Do not use default flags set by this script during - OpenROAD app compilation. + Do not use the default OpenROAD Build.sh arguments. - --openroad-args STRING Additional compilation flags for OpenROAD app - compilation. + --openroad-args STRING Additional arguments for OpenROAD Build.sh. + For example: '-no-gui -lto'. --install-path PATH Path to install tools. Default is ${INSTALL_PATH}. @@ -163,7 +162,15 @@ while (( "$#" )); do OPENROAD_APP_OVERWRITE_ARGS=1 ;; --openroad-args) - OPENROAD_APP_USER_ARGS="$2" + if ! parsed_args=$(printf '%s\n' "$2" | xargs printf '%s\n'); then + echo "[ERROR] Invalid OpenROAD build arguments: $2" >&2 + exit 1 + fi + while IFS= read -r arg; do + if [ -n "$arg" ]; then + OPENROAD_APP_USER_ARGS+=("$arg") + fi + done <<< "$parsed_args" shift ;; --install-path) @@ -207,11 +214,10 @@ echo "[INFO FLW-0028] Compiling with ${PROC} threads." # Only add install prefix variables after parsing arguments. YOSYS_ARGS+=" -DCMAKE_INSTALL_PREFIX=\"${INSTALL_PATH}/yosys\"" -OPENROAD_APP_ARGS+=" -D CMAKE_INSTALL_PREFIX=${INSTALL_PATH}/OpenROAD" -if [ -n "$CMAKE_INSTALL_RPATH" ]; then - OPENROAD_APP_ARGS+=" -D CMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH}" - OPENROAD_APP_ARGS+=" -D CMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE" -fi +OPENROAD_APP_ARGS=( + "-prefix=${INSTALL_PATH}/OpenROAD" + "-threads=${PROC}" +) __args_setup() { if [ ! -z "${YOSYS_OVERWRITE_ARGS+x}" ]; then @@ -222,10 +228,10 @@ __args_setup() { fi if [ ! -z "${OPENROAD_APP_OVERWRITE_ARGS+x}" ]; then - echo "[INFO FLW-0015] Overwriting OpenROAD app compilation flags." - OPENROAD_APP_ARGS="${OPENROAD_APP_USER_ARGS}" + echo "[INFO FLW-0015] Overwriting OpenROAD build arguments." + OPENROAD_APP_ARGS=("${OPENROAD_APP_USER_ARGS[@]}") else - OPENROAD_APP_ARGS+=" ${OPENROAD_APP_USER_ARGS}" + OPENROAD_APP_ARGS+=("${OPENROAD_APP_USER_ARGS[@]}") fi } @@ -325,26 +331,7 @@ __local_build() if [ -z "${SKIP_OPENROAD+x}" ]; then echo "[INFO FLW-0018] Compiling OpenROAD." - if [ -f "${DIR}/openroad_deps_prefixes.txt" ]; then - DEPS_PREFIX_ARG="${DIR}/openroad_deps_prefixes.txt" - elif [ -f "${DIR}/tools/OpenROAD/etc/openroad_deps_prefixes.txt" ]; then - DEPS_PREFIX_ARG="${DIR}/tools/OpenROAD/etc/openroad_deps_prefixes.txt" - elif [ -f /etc/openroad_deps_prefixes.txt ]; then - DEPS_PREFIX_ARG="/etc/openroad_deps_prefixes.txt" - else - DEPS_PREFIX_ARG="" - fi - if [[ -n "${DEPS_PREFIX_ARG}" ]]; then - echo "[INFO FLW-0029] Found OpenROAD dependencies prefixes file: '${DEPS_PREFIX_ARG}'." - DEPS_PREFIX_ARG="-deps-prefixes-file=${DEPS_PREFIX_ARG}" - fi - eval ${NICE} ./tools/OpenROAD/etc/Build.sh \ - -cmake-build \ - -dir="$DIR/tools/OpenROAD/build" \ - -threads=${PROC} \ - -cmake=\'${OPENROAD_APP_ARGS}\' \ - ${DEPS_PREFIX_ARG} - ${NICE} cmake --build tools/OpenROAD/build --target install -j "${PROC}" + ${NICE} ./tools/OpenROAD/etc/Build.sh "${OPENROAD_APP_ARGS[@]}" fi YOSYS_ABC_PATH=tools/yosys/abc diff --git a/docker/Dockerfile.builder b/docker/Dockerfile.builder index a5a18d80b6..2369f3b0f5 100644 --- a/docker/Dockerfile.builder +++ b/docker/Dockerfile.builder @@ -24,12 +24,12 @@ ENV PATH="/usr/local/bin/wrapped-cc:$PATH" COPY --link tools tools ARG numThreads=$(nproc) -ARG openroadVersion=NotSet ARG verificPath="" RUN < tools/yosys/abc/.gitcommit +./tools/OpenROAD/etc/DependencyInstaller.sh -bazel if [ -n "${verificPath}" ]; then verificArgs="--with-verific ${verificPath}" else @@ -38,7 +38,6 @@ fi ./build_openroad.sh --no_init \ --local \ --threads ${numThreads} \ - --openroad-args -DOPENROAD_VERSION=${openroadVersion} \ ${verificArgs} if [ -n "${verificPath}" ]; then rm -rf "${verificPath}" diff --git a/etc/DockerHelper.sh b/etc/DockerHelper.sh index 1d31edbb69..d8b1187407 100755 --- a/etc/DockerHelper.sh +++ b/etc/DockerHelper.sh @@ -66,9 +66,6 @@ _setup() { fromImage="${FROM_IMAGE_OVERRIDE:-"${org}/flow-${os}-dev"}:${imageTag}" context="." buildArgs+=" --build-arg numThreads=${numThreads}" - orVersion=$(git -C tools/OpenROAD describe --tags) - echo "OpenROAD version: ${orVersion}" - buildArgs+=" --build-arg openroadVersion=${orVersion}" ;; "dev" ) fromImage="${FROM_IMAGE_OVERRIDE:-$osBaseImage}" From 4e30d84a9063bad222936cbf6b700abf806547c4 Mon Sep 17 00:00:00 2001 From: Vitor Bandeira Date: Wed, 9 Sep 2026 18:14:25 -0300 Subject: [PATCH 2/5] build: install Bazel in the dev image, not the builder stage The builder stage ran the OpenROAD installer with -bazel before build_openroad.sh. That step runs apt-get update inside the builder image. On the CI Docker hosts, apt could not create its temporary file under /tmp, and the image build failed. The dev image already runs apt to install every other base dependency. Bazel is now part of -base and -all in the ORFS installer, so bazelisk and its runtime libraries land in the dev image. The dev image tag changes with the installer, so CI rebuilds it. Signed-off-by: Vitor Bandeira --- docker/Dockerfile.builder | 1 - etc/DependencyInstaller.sh | 11 +++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/docker/Dockerfile.builder b/docker/Dockerfile.builder index 2369f3b0f5..7e8275b284 100644 --- a/docker/Dockerfile.builder +++ b/docker/Dockerfile.builder @@ -29,7 +29,6 @@ ARG verificPath="" RUN < tools/yosys/abc/.gitcommit -./tools/OpenROAD/etc/DependencyInstaller.sh -bazel if [ -n "${verificPath}" ]; then verificArgs="--with-verific ${verificPath}" else diff --git a/etc/DependencyInstaller.sh b/etc/DependencyInstaller.sh index 8d5ce5189f..e48baab34d 100755 --- a/etc/DependencyInstaller.sh +++ b/etc/DependencyInstaller.sh @@ -339,8 +339,9 @@ Usage: $0 [-all|-base|-common] [-] # $0 -base # Installs OpenROAD's dependencies using - # package managers (-common must be - # executed in another command). + # package managers, including Bazel + # (bazelisk). -common must be executed + # in another command. $0 -common # Installs OpenROAD's common dependencies # (-base must be executed in another @@ -443,6 +444,12 @@ if [[ "${option}" == "none" ]]; then fi OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -${option}" +# build_openroad.sh builds OpenROAD with Bazel, so bazelisk and its runtime +# libraries are base dependencies. They need root, and -common may run +# unprivileged, so they ride along with -base only. +if [[ "${option}" == "base" || "${option}" == "all" ]]; then + OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -bazel" +fi platform="$(uname -s)" case "${platform}" in From af01027ac3c5dd40f9630c449ee4def7756af593 Mon Sep 17 00:00:00 2001 From: Vitor Bandeira Date: Thu, 10 Sep 2026 11:43:33 -0300 Subject: [PATCH 3/5] fix(docker): include OpenROAD version in dev tags Signed-off-by: Vitor Bandeira --- etc/DockerHelper.sh | 3 ++- etc/DockerTag.sh | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/etc/DockerHelper.sh b/etc/DockerHelper.sh index d8b1187407..430e349bcd 100755 --- a/etc/DockerHelper.sh +++ b/etc/DockerHelper.sh @@ -28,7 +28,8 @@ usage: $0 [CMD] [OPTIONS] copy source code and build app -threads=N Max number of threads to use if compiling. Default = \$(nproc) - -tag=TAG Use as the image tag. Default is git commit sha. + -tag=TAG Use as the image tag. Default includes the + OpenROAD version and image content hash. -username=USERNAME Username to loging at the docker registry. -password=PASSWORD Password to loging at the docker registry. -ci Install CI tools in image diff --git a/etc/DockerTag.sh b/etc/DockerTag.sh index 3234061637..70e87e1e3d 100755 --- a/etc/DockerTag.sh +++ b/etc/DockerTag.sh @@ -12,7 +12,9 @@ if [[ "$@" == "-dev" ]]; then "./etc/requirements-pip_lock.txt" "./tools/OpenROAD/etc/DependencyInstaller.sh" ) - cat "${file_list[@]}" | sha256sum | awk '{print substr($1, 1, 6)}' + or_version=$(git -C tools/OpenROAD describe --tags --always) + image_hash=$(cat "${file_list[@]}" | sha256sum | awk '{print substr($1, 1, 6)}') + echo "${or_version}-${image_hash}" elif [[ "$@" == "-master" ]]; then git fetch --tags >&2 git -C tools/OpenROAD fetch --tags >&2 From e7d41e0d45d77fc09fbc41b432fa520a723652f3 Mon Sep 17 00:00:00 2001 From: Vitor Bandeira Date: Thu, 10 Sep 2026 12:03:12 -0300 Subject: [PATCH 4/5] build: enable LTO for the Bazel OpenROAD build The Bazel build defaults to -O2 without LTO. The CMake RELEASE build used -O3 with LTO. The two binaries give different QoR from CTS onward, and CI compared the Bazel binary against a CMake baseline. Pass -lto so Build.sh uses --config=opt and the binary is closer to the previous one. Signed-off-by: Vitor Bandeira --- build_openroad.sh | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/build_openroad.sh b/build_openroad.sh index 745b6a12b8..01dface4c3 100755 --- a/build_openroad.sh +++ b/build_openroad.sh @@ -80,7 +80,7 @@ Options: Do not use the default OpenROAD Build.sh arguments. --openroad-args STRING Additional arguments for OpenROAD Build.sh. - For example: '-no-gui -lto'. + For example: '-no-gui'. --install-path PATH Path to install tools. Default is ${INSTALL_PATH}. @@ -214,9 +214,13 @@ echo "[INFO FLW-0028] Compiling with ${PROC} threads." # Only add install prefix variables after parsing arguments. YOSYS_ARGS+=" -DCMAKE_INSTALL_PREFIX=\"${INSTALL_PATH}/yosys\"" +# -lto selects Bazel --config=opt (-O3 and LTO). The default Bazel build is +# -O2 without LTO, which produces a slower binary with different QoR than the +# previous CMake RELEASE build. OPENROAD_APP_ARGS=( "-prefix=${INSTALL_PATH}/OpenROAD" "-threads=${PROC}" + "-lto" ) __args_setup() { From 84d3ba1eb2a070d1fea0a25fe289c873f291db77 Mon Sep 17 00:00:00 2001 From: Vitor Bandeira Date: Fri, 11 Sep 2026 00:35:30 -0300 Subject: [PATCH 5/5] fix(build): keep backslashes in --openroad-args The parser used xargs, which removes backslashes. A path such as C:\projects became C:projects. A pure-bash tokenizer now splits the string. Quotes still group one argument that holds spaces. Every other character stays literal, and nothing is expanded. Signed-off-by: Vitor Bandeira --- build_openroad.sh | 57 ++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/build_openroad.sh b/build_openroad.sh index 01dface4c3..9566ee5dcc 100755 --- a/build_openroad.sh +++ b/build_openroad.sh @@ -80,7 +80,9 @@ Options: Do not use the default OpenROAD Build.sh arguments. --openroad-args STRING Additional arguments for OpenROAD Build.sh. - For example: '-no-gui'. + For example: '-no-gui'. Quotes group one argument + that holds spaces. All other characters, a + backslash included, are literal. --install-path PATH Path to install tools. Default is ${INSTALL_PATH}. @@ -103,6 +105,49 @@ Options valid only for Docker builds: EOF } +# Split a shell-like string into words and add them to +# OPENROAD_APP_USER_ARGS. A single or double quote groups a word. Every other +# character, a backslash included, is literal, and there is no escape +# character. A quoted word therefore cannot hold its own quote character. +# Nothing is expanded, so text such as $(...) stays literal. +__append_openroad_args() +{ + local text="$1" + local word="" quote="" char="" have_word=0 index + + for (( index = 0; index < ${#text}; index++ )); do + char="${text:index:1}" + if [ -n "${quote}" ]; then + if [ "${char}" = "${quote}" ]; then + quote="" + else + word+="${char}" + fi + elif [ "${char}" = "'" ] || [ "${char}" = '"' ]; then + quote="${char}" + have_word=1 + elif [[ "${char}" =~ [[:space:]] ]]; then + if [ "${have_word}" -eq 1 ]; then + OPENROAD_APP_USER_ARGS+=("${word}") + word="" + have_word=0 + fi + else + word+="${char}" + have_word=1 + fi + done + + if [ -n "${quote}" ]; then + echo "[ERROR FLW-0006] Unbalanced ${quote} quote in OpenROAD build arguments: ${text}" >&2 + exit 1 + fi + + if [ "${have_word}" -eq 1 ]; then + OPENROAD_APP_USER_ARGS+=("${word}") + fi +} + # Parse arguments __CMD="$0 $@" while (( "$#" )); do @@ -162,15 +207,7 @@ while (( "$#" )); do OPENROAD_APP_OVERWRITE_ARGS=1 ;; --openroad-args) - if ! parsed_args=$(printf '%s\n' "$2" | xargs printf '%s\n'); then - echo "[ERROR] Invalid OpenROAD build arguments: $2" >&2 - exit 1 - fi - while IFS= read -r arg; do - if [ -n "$arg" ]; then - OPENROAD_APP_USER_ARGS+=("$arg") - fi - done <<< "$parsed_args" + __append_openroad_args "$2" shift ;; --install-path)