Skip to content

Commit 4de9260

Browse files
authored
[build_symbolizer] Introduce ZLIB_SRC to specify an on-disk location for (#70994)
zlib. Not everyone wants to checkout from `git`. Tested with and without the env var.
1 parent 801c78d commit 4de9260

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env bash
22
#
33
# Run as: CLANG=bin/clang build_symbolizer.sh out.o
4+
# If you want to use a local copy of zlib, set ZLIB_SRC.
45
# zlib can be downloaded from http://www.zlib.net.
56
#
67
# Script compiles self-contained object file with symbolization code.
@@ -20,6 +21,12 @@ set -u
2021

2122
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
2223
SRC_DIR=$(readlink -f $SCRIPT_DIR/..)
24+
25+
if [[ $# -ne 1 ]]; then
26+
echo "Missing output file"
27+
exit 1
28+
fi
29+
2330
OUTPUT=$(readlink -f $1)
2431
COMPILER_RT_SRC=$(readlink -f ${SCRIPT_DIR}/../../../..)
2532
LLVM_SRC=${LLVM_SRC:-${COMPILER_RT_SRC}/../llvm}
@@ -52,6 +59,7 @@ LLVM_BUILD=${BUILD_DIR}/llvm
5259
SYMBOLIZER_BUILD=${BUILD_DIR}/symbolizer
5360

5461
FLAGS=${FLAGS:-}
62+
ZLIB_SRC=${ZLIB_SRC:-}
5563
TARGET_TRIPLE=$($CC -print-target-triple $FLAGS)
5664
if [[ "$FLAGS" =~ "-m32" ]] ; then
5765
# Avoid new wrappers.
@@ -63,7 +71,15 @@ FLAGS+=" -include ${SRC_DIR}/../sanitizer_redefine_builtins.h -DSANITIZER_COMMON
6371
LINKFLAGS="-fuse-ld=lld -target $TARGET_TRIPLE"
6472

6573
# Build zlib.
66-
[[ -d ${ZLIB_BUILD} ]] || git clone https://github.com/madler/zlib ${ZLIB_BUILD}
74+
if [[ -d ${ZLIB_BUILD} ]]; then
75+
if [[ -z "${ZLIB_SRC}" ]]; then
76+
git clone https://github.com/madler/zlib ${ZLIB_BUILD}
77+
else
78+
ZLIB_SRC=$(readlink -f $ZLIB_SRC)
79+
cp -r ${ZLIB_SRC}/* ${ZLIB_BUILD}/
80+
fi
81+
fi
82+
6783
cd ${ZLIB_BUILD}
6884
AR="${AR}" CC="${CC}" CFLAGS="$FLAGS -Wno-deprecated-non-prototype" RANLIB=/bin/true ./configure --static
6985
make -j libz.a

0 commit comments

Comments
 (0)