@@ -23,8 +23,8 @@ INSTALL_PATH="$(pwd)/tools/install"
2323YOSYS_USER_ARGS=" "
2424YOSYS_ARGS=" "
2525
26- OPENROAD_APP_USER_ARGS=" "
27- OPENROAD_APP_ARGS=" "
26+ OPENROAD_APP_USER_ARGS=()
27+ OPENROAD_APP_ARGS=()
2828
2929DOCKER_OS_NAME=" ubuntu22.04"
3030PROC=-1
@@ -77,11 +77,12 @@ Options:
7777 to the Verific source folder.
7878
7979 --openroad-args-overwrite
80- Do not use default flags set by this script during
81- OpenROAD app compilation.
80+ Do not use the default OpenROAD Build.sh arguments.
8281
83- --openroad-args STRING Additional compilation flags for OpenROAD app
84- compilation.
82+ --openroad-args STRING Additional arguments for OpenROAD Build.sh.
83+ For example: '-no-gui'. Quotes group one argument
84+ that holds spaces. All other characters, a
85+ backslash included, are literal.
8586
8687 --install-path PATH Path to install tools. Default is ${INSTALL_PATH} .
8788
@@ -104,6 +105,49 @@ Options valid only for Docker builds:
104105EOF
105106}
106107
108+ # Split a shell-like string into words and add them to
109+ # OPENROAD_APP_USER_ARGS. A single or double quote groups a word. Every other
110+ # character, a backslash included, is literal, and there is no escape
111+ # character. A quoted word therefore cannot hold its own quote character.
112+ # Nothing is expanded, so text such as $(...) stays literal.
113+ __append_openroad_args ()
114+ {
115+ local text=" $1 "
116+ local word=" " quote=" " char=" " have_word=0 index
117+
118+ for (( index = 0 ; index < ${# text} ; index++ )) ; do
119+ char=" ${text: index: 1} "
120+ if [ -n " ${quote} " ]; then
121+ if [ " ${char} " = " ${quote} " ]; then
122+ quote=" "
123+ else
124+ word+=" ${char} "
125+ fi
126+ elif [ " ${char} " = " '" ] || [ " ${char} " = ' "' ]; then
127+ quote=" ${char} "
128+ have_word=1
129+ elif [[ " ${char} " =~ [[:space:]] ]]; then
130+ if [ " ${have_word} " -eq 1 ]; then
131+ OPENROAD_APP_USER_ARGS+=(" ${word} " )
132+ word=" "
133+ have_word=0
134+ fi
135+ else
136+ word+=" ${char} "
137+ have_word=1
138+ fi
139+ done
140+
141+ if [ -n " ${quote} " ]; then
142+ echo " [ERROR FLW-0006] Unbalanced ${quote} quote in OpenROAD build arguments: ${text} " >&2
143+ exit 1
144+ fi
145+
146+ if [ " ${have_word} " -eq 1 ]; then
147+ OPENROAD_APP_USER_ARGS+=(" ${word} " )
148+ fi
149+ }
150+
107151# Parse arguments
108152__CMD=" $0 $@ "
109153while (( "$# " )) ; do
@@ -163,7 +207,7 @@ while (( "$#" )); do
163207 OPENROAD_APP_OVERWRITE_ARGS=1
164208 ;;
165209 --openroad-args)
166- OPENROAD_APP_USER_ARGS= " $2 "
210+ __append_openroad_args " $2 "
167211 shift
168212 ;;
169213 --install-path)
@@ -207,11 +251,14 @@ echo "[INFO FLW-0028] Compiling with ${PROC} threads."
207251
208252# Only add install prefix variables after parsing arguments.
209253YOSYS_ARGS+=" -DCMAKE_INSTALL_PREFIX=\" ${INSTALL_PATH} /yosys\" "
210- OPENROAD_APP_ARGS+=" -D CMAKE_INSTALL_PREFIX=${INSTALL_PATH} /OpenROAD"
211- if [ -n " $CMAKE_INSTALL_RPATH " ]; then
212- OPENROAD_APP_ARGS+=" -D CMAKE_INSTALL_RPATH=${CMAKE_INSTALL_RPATH} "
213- OPENROAD_APP_ARGS+=" -D CMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE"
214- fi
254+ # -lto selects Bazel --config=opt (-O3 and LTO). The default Bazel build is
255+ # -O2 without LTO, which produces a slower binary with different QoR than the
256+ # previous CMake RELEASE build.
257+ OPENROAD_APP_ARGS=(
258+ " -prefix=${INSTALL_PATH} /OpenROAD"
259+ " -threads=${PROC} "
260+ " -lto"
261+ )
215262
216263__args_setup () {
217264 if [ ! -z " ${YOSYS_OVERWRITE_ARGS+x} " ]; then
@@ -222,10 +269,10 @@ __args_setup() {
222269 fi
223270
224271 if [ ! -z " ${OPENROAD_APP_OVERWRITE_ARGS+x} " ]; then
225- echo " [INFO FLW-0015] Overwriting OpenROAD app compilation flags ."
226- OPENROAD_APP_ARGS=" ${OPENROAD_APP_USER_ARGS} "
272+ echo " [INFO FLW-0015] Overwriting OpenROAD build arguments ."
273+ OPENROAD_APP_ARGS=( " ${OPENROAD_APP_USER_ARGS[@]} " )
227274 else
228- OPENROAD_APP_ARGS+=" ${OPENROAD_APP_USER_ARGS} "
275+ OPENROAD_APP_ARGS+=( " ${OPENROAD_APP_USER_ARGS[@]} " )
229276 fi
230277}
231278
@@ -325,26 +372,7 @@ __local_build()
325372
326373 if [ -z " ${SKIP_OPENROAD+x} " ]; then
327374 echo " [INFO FLW-0018] Compiling OpenROAD."
328- if [ -f " ${DIR} /openroad_deps_prefixes.txt" ]; then
329- DEPS_PREFIX_ARG=" ${DIR} /openroad_deps_prefixes.txt"
330- elif [ -f " ${DIR} /tools/OpenROAD/etc/openroad_deps_prefixes.txt" ]; then
331- DEPS_PREFIX_ARG=" ${DIR} /tools/OpenROAD/etc/openroad_deps_prefixes.txt"
332- elif [ -f /etc/openroad_deps_prefixes.txt ]; then
333- DEPS_PREFIX_ARG=" /etc/openroad_deps_prefixes.txt"
334- else
335- DEPS_PREFIX_ARG=" "
336- fi
337- if [[ -n " ${DEPS_PREFIX_ARG} " ]]; then
338- echo " [INFO FLW-0029] Found OpenROAD dependencies prefixes file: '${DEPS_PREFIX_ARG} '."
339- DEPS_PREFIX_ARG=" -deps-prefixes-file=${DEPS_PREFIX_ARG} "
340- fi
341- eval ${NICE} ./tools/OpenROAD/etc/Build.sh \
342- -cmake-build \
343- -dir=" $DIR /tools/OpenROAD/build" \
344- -threads=${PROC} \
345- -cmake=\' ${OPENROAD_APP_ARGS} \' \
346- ${DEPS_PREFIX_ARG}
347- ${NICE} cmake --build tools/OpenROAD/build --target install -j " ${PROC} "
375+ ${NICE} ./tools/OpenROAD/etc/Build.sh " ${OPENROAD_APP_ARGS[@]} "
348376 fi
349377
350378 YOSYS_ABC_PATH=tools/yosys/abc
0 commit comments