File size: 20,087 Bytes
d664931 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 | #!/usr/bin/env bash
set -euo pipefail
# Capture the script's absolute directory before any cd
if [[ "$OSTYPE" == "darwin"* ]]; then
_script_dir="$(dirname $(perl -e 'use Cwd "abs_path";print abs_path(shift)' $0))"
else
_script_dir="$(dirname $(readlink -f $0))"
fi
# Make sure we are on the correct folder before beginning
cd "${_script_dir}/../"
if [[ "$OSTYPE" == "darwin"* ]]; then
numThreads=$(sysctl -n hw.logicalcpu)
else
numThreads=$(nproc)
fi
_versionCompare() {
local a b IFS=. ; set -f
printf -v a %08d $1; printf -v b %08d $3
test $a "$2" $b
}
# Yosys is built with CMake and needs CMake >= 3.28,
# newer than Ubuntu 22.04 ships, so fetch a release from Kitware when the
# one on PATH is too old.
cmakeMinVersion=3.28
cmakeVersion=3.31.9
cmakeChecksumX86_64=64797150473dabe9de95459cb1ce0715
cmakeChecksumAarch64=8d426361ce8c54494c0a041a0e3bcc5c
# True if version $1 >= version $2. Unlike _versionCompare, this handles
# versions with a different number of components (3.22.1 vs 3.28).
_versionAtLeast() {
[[ "$(printf '%s\n%s\n' "$2" "$1" | sort -V | head -n1)" == "$2" ]]
}
# Prints the version of tool $2, looking in prefix $1 first, or 0 if absent.
_toolVersion() {
local bin
bin=$(PATH="$1/bin:${PATH}" command -v "$2" || true)
if [[ -z "${bin}" ]]; then
echo 0
return
fi
"${bin}" --version | head -n1 | grep -oE '[0-9]+\.[0-9]+(\.[0-9]+)?' | head -n1
}
_installCmake() {
local prefix=${PREFIX:-"/usr/local"}
local current
current=$(_toolVersion "${prefix}" cmake)
if _versionAtLeast "${current}" "${cmakeMinVersion}"; then
echo "CMake ${current} found, skipping install"
return
fi
local arch checksum installer workDir
arch=$(uname -m)
if [[ "${arch}" == "aarch64" ]]; then
checksum=${cmakeChecksumAarch64}
else
checksum=${cmakeChecksumX86_64}
fi
installer="cmake-${cmakeVersion}-linux-${arch}.sh"
workDir=$(mktemp -d)
(
cd "${workDir}"
wget -q "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/${installer}"
md5sum -c <(echo "${checksum} ${installer}")
mkdir -p "${prefix}"
sh "${installer}" --skip-license --prefix="${prefix}"
)
rm -rf "${workDir}"
}
# Yosys needs Bison >= 3.6, newer than EL8 ships, so build the release that
# the OpenROAD installer uses when the one on PATH is too old.
bisonMinVersion=3.6
bisonVersion=3.8.2
bisonChecksum=1e541a097cda9eca675d29dd2832921f
_installBison() {
local prefix=${PREFIX:-"/usr/local"}
local current
current=$(_toolVersion "${prefix}" bison)
if _versionAtLeast "${current}" "${bisonMinVersion}"; then
echo "Bison ${current} found, skipping install"
return
fi
local tarball="bison-${bisonVersion}.tar.gz"
local workDir
workDir=$(mktemp -d)
(
cd "${workDir}"
wget -q "https://ftp.gnu.org/gnu/bison/${tarball}"
md5sum -c <(echo "${bisonChecksum} ${tarball}")
tar xzf "${tarball}"
cd "bison-${bisonVersion}"
./configure --prefix="${prefix}"
make -j "${numThreads}"
make install
)
rm -rf "${workDir}"
}
_installORDependencies() {
if [[ ${YOSYS_VER} == "" ]]; then
YOSYS_VER=v$(grep 'yosys_ver =' tools/yosys/docs/source/conf.py | awk -F'"' '{print $2}')
fi
./tools/OpenROAD/etc/DependencyInstaller.sh ${OR_INSTALLER_ARGS} -yosys-ver="${YOSYS_VER}"
}
_installPipCommon() {
local lockfile piplock
lockfile="${_script_dir}/requirements-common_lock.txt"
piplock="${_script_dir}/requirements-pip_lock.txt"
if [[ -n "${VIRTUAL_ENV:-}" ]]; then
# The lock goes into the virtual environment, created if it does
# not exist yet; the Docker images name one with ENV VIRTUAL_ENV.
if [[ ! -x "${VIRTUAL_ENV}/bin/python3" ]]; then
python3 -m venv "${VIRTUAL_ENV}"
fi
"${VIRTUAL_ENV}/bin/python3" -m pip install --no-cache-dir --upgrade --require-hashes -r "$piplock"
"${VIRTUAL_ENV}/bin/python3" -m pip install --no-cache-dir -r "$lockfile"
elif [[ "$OSTYPE" == "darwin"* ]]; then
if [[ "$EUID" -eq 0 ]]; then
echo "Error: Do NOT run with sudo."
exit 1
fi
echo "Error: Activate a virtual environment on macOS."
exit 1
else
# pip before 23.3 fails --require-hashes on requirements-common_lock.txt:
# it does not match an extras-bearing pin such as
# googleapis-common-protos[grpc]==X against a plain request for the same
# package. Raise pip first, from its own hashed lock.
if [[ $(id -u) == 0 ]]; then
python3 -m pip install --no-cache-dir --upgrade --require-hashes -r "$piplock"
python3 -m pip install --no-cache-dir -r "$lockfile"
else
python3 -m pip install --no-cache-dir --user --upgrade --require-hashes -r "$piplock"
python3 -m pip install --no-cache-dir --user -r "$lockfile"
fi
fi
}
_installPipSystem() {
apt-get -y install python3-pandas python3-numpy python3-click python3-yaml python3-yamlfix
}
# Enterprise Linux 8/9 cleanup
_install_EL8_EL9_CleanUp() {
dnf clean -y all
}
# Enterprise Linux 8/9 package installation (EL8/EL9 = RHEL, Rocky Linux, or AlmaLinux)
_install_EL8_EL9_Packages() {
# Re-detect EL version
if [[ -f /etc/os-release ]]; then
elVersion=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g' | cut -d. -f1)
else
echo "ERROR: Could not detect Enterprise Linux version"
exit 1
fi
# EL8 and EL9 use `dnf`, instead of `yum`
dnf -y update
# EPEL has tcl-tclreadline.
dnf -y install "https://dl.fedoraproject.org/pub/epel/epel-release-latest-${elVersion}.noarch.rpm"
# The rest builds Yosys.
dnf -y install \
bison \
boost-devel \
findutils \
flex \
gcc \
gcc-c++ \
git \
libffi-devel \
make \
pkgconf-pkg-config \
python3 \
python3-devel \
python3-pip \
readline \
ruby \
ruby-devel \
tcl-devel \
tcllib \
time \
wget \
zlib-devel
# The pip lock files need Python 3.10 or newer, which
# is newer than the EL8 and EL9 defaults.
dnf -y install python3.12 python3.12-devel python3.12-pip
update-alternatives --install /usr/bin/python3 python3 "$(command -v python3.12)" 50
# EL8 registers its Python 3.6 with a higher priority, so select 3.12.
update-alternatives --set python3 "$(command -v python3.12)"
if [[ "${elVersion}" == "8" ]]; then
dnf -y install \
readline-devel \
tcl-tclreadline \
tcl-tclreadline-devel
# The default GCC 8 is too old for Yosys, which needs C++20.
dnf -y install gcc-toolset-13
fi
if [[ "${elVersion}" == "9" ]]; then
dnf -y install \
https://mirror.stream.centos.org/9-stream/AppStream/x86_64/os/Packages/readline-devel-8.1-4.el9.x86_64.rpm
fi
}
_installUbuntuCleanUp() {
apt-get autoclean -y
apt-get autoremove -y
}
_installUbuntuPackages() {
export DEBIAN_FRONTEND="noninteractive"
apt-get -y update
apt-get -y install --no-install-recommends \
bison \
build-essential \
ca-certificates \
curl \
flex \
git \
help2man \
libboost-iostreams-dev \
libffi-dev \
libfl-dev \
libfl2 \
libgit2-dev \
libgmock-dev \
libgoogle-perftools-dev \
libgtest-dev \
libqt5multimediawidgets5 \
libqt5opengl5 \
libqt5svg5-dev \
libqt5xmlpatterns5-dev \
libreadline-dev \
libz-dev \
perl \
pkg-config \
python3-dev \
python3-pip \
python3-venv \
qtmultimedia5-dev \
qttools5-dev \
ruby \
ruby-dev \
tcl-dev \
tcl-tclreadline \
tcllib \
time \
unzip \
wget \
zlib1g \
zlib1g-dev
packages=()
# Choose libstdc++ version
if _versionCompare $1 -ge 25.04; then
packages+=("libstdc++-15-dev")
elif _versionCompare $1 -ge 24.04; then
packages+=("libstdc++-14-dev")
elif _versionCompare $1 -ge 22.10; then
packages+=("libstdc++-12-dev")
fi
apt-get install -y --no-install-recommends ${packages[@]}
if [[ $1 == "rodete" ]]; then
apt-get -y install --no-install-recommends python3-pandas
fi
if command -v docker &> /dev/null; then
# The user can uninstall docker if they want to reinstall it,
# and also this allows the user to choose drop in replacements
# for docker, such as podman-docker
echo "Docker is already installed, skip docker reinstall."
return 0
fi
# Add Docker's official GPG key:
install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg \
-o /etc/apt/keyrings/docker.asc
chmod a+r /etc/apt/keyrings/docker.asc
# Add the repository to Apt sources:
echo "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
tee /etc/apt/sources.list.d/docker.list > /dev/null
apt-get -y update
if [[ $1 != "rodete" ]]; then
apt-get -y install --no-install-recommends \
docker-ce \
docker-ce-cli \
containerd.io \
docker-buildx-plugin \
docker-compose-plugin
fi
}
_installDarwinPackages() {
brew install libffi tcl-tk ruby
brew install python libomp doxygen bison flex boost spdlog zlib cmake
brew link --force libomp
brew install docker docker-buildx
}
_installCI() {
apt-get -y update
apt-get -y install --no-install-recommends \
apt-transport-https \
ca-certificates \
coreutils \
curl \
gnupg \
jq \
lsb-release \
parallel \
python3 \
software-properties-common \
zip
}
_help() {
cat <<EOF
All arguments and flags are only applicable for OpenROAD dependencies
Usage: $0 [-all|-base|-common] [-<ARGS>]
# Installs all of OpenROAD's dependencies no
# need to run -base or -common. Requires
# privileged access.
#
$0 -base
# Installs OpenROAD's dependencies using
# 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
# command).
$0 -bazel
# Default. Installs the dependencies to
# build OpenROAD with Bazel.
$0 -cmake
# Installs the dependencies to build
# OpenROAD with CMake instead of Bazel,
# e.g. for build_openroad.sh
# --openroad-args -cmake-build.
$0 -prefix=DIR
# Installs common dependencies in an existing
# user-specified directory. Only used
# with -common. This flag cannot be used
# with sudo or with root access.
$0 -local
# Installs common dependencies in
# "$HOME/.local". Only used with
# -common. This flag cannot be used with
# sudo or with root access.
$0 -ci
# Installs CI tools
$0 -yosys-ver=VERSION
# Installs specified version of Yosys.
# By default, the Yosys version is
# obtained from tools/yosys/docs/source/conf.py
$0 -constant-build-dir
# Use constant build directory, instead of
# random one.
EOF
exit "${1:-1}"
}
# default args
OR_INSTALLER_ARGS=""
YOSYS_VER=""
# default prefix
PREFIX=""
# default option
option="none"
# default isLocal
isLocal="false"
constantBuildDir="false"
CI="no"
# OpenROAD build system to install dependencies for: bazel or cmake
buildSystem="bazel"
# default values, can be overwritten by cmdline args
while [ "$#" -gt 0 ]; do
case "${1}" in
-h|-help)
_help 0
;;
-all)
if [[ "${option}" != "none" ]]; then
echo "WARNING: previous argument -${option} will be overwritten with -all." >&2
fi
option="all"
;;
-base)
if [[ "${option}" != "none" ]]; then
echo "WARNING: previous argument -${option} will be overwritten with -base." >&2
fi
option="base"
;;
-common)
if [[ "${option}" != "none" ]]; then
echo "WARNING: previous argument -${option} will be overwritten with -common." >&2
fi
option="common"
;;
-bazel)
buildSystem="bazel"
;;
-cmake)
buildSystem="cmake"
;;
-local)
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -local"
PREFIX="${HOME}/.local"
;;
-ci)
CI="yes"
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -save-deps-prefixes=/etc/openroad_deps_prefixes.txt"
;;
-save-deps-prefixes=*)
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1"
;;
-yosys-ver=*)
YOSYS_VER=${1#*=}
;;
-prefix=*)
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1"
PREFIX=${1#*=}
;;
-constant-build-dir)
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1"
constantBuildDir="true"
;;
-threads=*)
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} $1"
numThreads=${1#*=}
;;
*)
echo "unknown option: ${1}" >&2
_help
;;
esac
shift 1
done
if [[ "${option}" == "none" ]]; then
echo "You must use one of: -all|-base|-common" >&2
_help
fi
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -${option}"
# build_openroad.sh builds OpenROAD with Bazel by default. The Bazel runtime
# libraries need root, and -common may run unprivileged, so they ride along
# with -base only; -common installs bazelisk. -cmake asks for the OpenROAD
# CMake dependencies instead.
if [[ "${buildSystem}" == "cmake" ]]; then
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -cmake"
elif [[ "${option}" == "base" || "${option}" == "all" ]]; then
OR_INSTALLER_ARGS="${OR_INSTALLER_ARGS} -bazel"
fi
platform="$(uname -s)"
case "${platform}" in
"Linux" )
if [[ -f /etc/os-release ]]; then
os=$(awk -F= '/^NAME/{print $2}' /etc/os-release | sed 's/"//g')
else
os="Unidentified OS, could not find /etc/os-release."
fi
;;
"Darwin" )
if [[ $(id -u) == 0 ]]; then>&2
echo "ERROR: cannot install on macOS if you are root or using sudo (not recommended for brew)." >&2
exit 1
fi
os="Darwin"
;;
*)
echo "${platform} is not supported" >&2
_help
;;
esac
case "${os}" in
"Red Hat Enterprise Linux"* | "AlmaLinux" | "Rocky Linux")
# Enterprise Linux support - dispatch based on specific version
if [[ ${CI} == "yes" ]]; then
echo "WARNING: Installing CI dependencies is only supported on Ubuntu 24.04 and 26.04" >&2
fi
# Detect EL version to choose appropriate functions
if [[ -f /etc/os-release ]]; then
elVersion=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g' | cut -d. -f1)
else
echo "ERROR: Could not detect Enterprise Linux version" >&2
exit 1
fi
# Only EL8 and EL9 are supported; other versions stop before any install.
case "${elVersion}" in
"8"|"9")
# EL8/EL9 = RHEL, Rocky Linux, or AlmaLinux
# First install OpenROAD base
_installORDependencies
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
_install_EL8_EL9_Packages
_install_EL8_EL9_CleanUp
fi
;;
*)
echo "ERROR: Unsupported Enterprise Linux version: ${elVersion}" >&2
exit 1
;;
esac
if [[ "${option}" == "common" || "${option}" == "all" ]]; then
_installCmake
_installBison
_installPipCommon
fi
;;
"Ubuntu" | "Debian GNU/Linux rodete" )
version=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | sed 's/"//g')
if [[ -z ${version} ]]; then
version=$(awk -F= '/^VERSION_CODENAME/{print $2}' /etc/os-release | sed 's/"//g')
fi
if [[ ${CI} == "yes" ]]; then
echo "Installing CI Tools"
_installCI
fi
_installORDependencies
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
_installUbuntuPackages "${version}"
_installUbuntuCleanUp
fi
if [[ "${option}" == "common" || "${option}" == "all" ]]; then
_installCmake
fi
if [[ $version != "rodete" ]] && _versionCompare ${version} -lt 23.04 ; then
if [[ "${option}" == "common" || "${option}" == "all" ]]; then
_installPipCommon
fi
else
# The system Python is externally managed (PEP 668): its
# packages come from apt, in -base with the other system
# packages. The lock, which also has packages apt does not
# carry, among them the klayout module the flow writes GDS
# with, goes into the virtual environment VIRTUAL_ENV names;
# setup.sh names the checkout's .venv.
if [[ $version != "rodete" ]] && [[ "${option}" == "base" || "${option}" == "all" ]]; then
_installPipSystem
fi
if [[ "${option}" == "common" || "${option}" == "all" ]]; then
if [[ -z "${VIRTUAL_ENV:-}" ]]; then
echo "ERROR: the system Python is externally managed;" \
"set VIRTUAL_ENV to the virtual environment to" \
"install etc/requirements-common_lock.txt into," \
"or run setup.sh, which installs it into .venv." >&2
exit 1
fi
_installPipCommon
fi
fi
;;
"Darwin" )
if [[ ${CI} == "yes" ]]; then
echo "WARNING: Installing CI dependencies is only supported on Ubuntu 24.04 and 26.04" >&2
fi
_installORDependencies
if [[ "${option}" == "base" || "${option}" == "all" ]]; then
_installDarwinPackages
fi
if [[ "${option}" == "common" || "${option}" == "all" ]]; then
_installPipCommon
fi
;;
*)
echo "unsupported system: ${os}" >&2
_help
;;
esac
|