Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
Expand Down
98 changes: 63 additions & 35 deletions build_openroad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -77,11 +77,12 @@ 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'. 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}.

Expand All @@ -104,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
Expand Down Expand Up @@ -163,7 +207,7 @@ while (( "$#" )); do
OPENROAD_APP_OVERWRITE_ARGS=1
;;
--openroad-args)
OPENROAD_APP_USER_ARGS="$2"
__append_openroad_args "$2"
shift
;;
--install-path)
Expand Down Expand Up @@ -207,11 +251,14 @@ 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
# -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() {
if [ ! -z "${YOSYS_OVERWRITE_ARGS+x}" ]; then
Expand All @@ -222,10 +269,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
}

Expand Down Expand Up @@ -325,26 +372,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
Expand Down
2 changes: 0 additions & 2 deletions docker/Dockerfile.builder
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ ENV PATH="/usr/local/bin/wrapped-cc:$PATH"

COPY --link tools tools
ARG numThreads=$(nproc)
ARG openroadVersion=NotSet
ARG verificPath=""

RUN <<EOF
Expand All @@ -38,7 +37,6 @@ fi
./build_openroad.sh --no_init \
--local \
--threads ${numThreads} \
--openroad-args -DOPENROAD_VERSION=${openroadVersion} \
${verificArgs}
if [ -n "${verificPath}" ]; then
rm -rf "${verificPath}"
Expand Down
11 changes: 9 additions & 2 deletions etc/DependencyInstaller.sh
Original file line number Diff line number Diff line change
Expand Up @@ -339,8 +339,9 @@ Usage: $0 [-all|-base|-common] [-<ARGS>]
#
$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
Expand Down Expand Up @@ -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
Expand Down
6 changes: 2 additions & 4 deletions etc/DockerHelper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -66,9 +67,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}"
Expand Down
4 changes: 3 additions & 1 deletion etc/DockerTag.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down