Skip to content

Commit

Permalink
[build_symbolizer] Introduce ZLIB_SRC to specify an on-disk location …
Browse files Browse the repository at this point in the history
…for (#70994)

zlib.

Not everyone wants to checkout from `git`. Tested with and without the
env var.
  • Loading branch information
dcci authored Nov 1, 2023
1 parent 801c78d commit 4de9260
Showing 1 changed file with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env bash
#
# Run as: CLANG=bin/clang build_symbolizer.sh out.o
# If you want to use a local copy of zlib, set ZLIB_SRC.
# zlib can be downloaded from http://www.zlib.net.
#
# Script compiles self-contained object file with symbolization code.
Expand All @@ -20,6 +21,12 @@ set -u

SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SRC_DIR=$(readlink -f $SCRIPT_DIR/..)

if [[ $# -ne 1 ]]; then
echo "Missing output file"
exit 1
fi

OUTPUT=$(readlink -f $1)
COMPILER_RT_SRC=$(readlink -f ${SCRIPT_DIR}/../../../..)
LLVM_SRC=${LLVM_SRC:-${COMPILER_RT_SRC}/../llvm}
Expand Down Expand Up @@ -52,6 +59,7 @@ LLVM_BUILD=${BUILD_DIR}/llvm
SYMBOLIZER_BUILD=${BUILD_DIR}/symbolizer

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

# Build zlib.
[[ -d ${ZLIB_BUILD} ]] || git clone https://github.com/madler/zlib ${ZLIB_BUILD}
if [[ -d ${ZLIB_BUILD} ]]; then
if [[ -z "${ZLIB_SRC}" ]]; then
git clone https://github.com/madler/zlib ${ZLIB_BUILD}
else
ZLIB_SRC=$(readlink -f $ZLIB_SRC)
cp -r ${ZLIB_SRC}/* ${ZLIB_BUILD}/
fi
fi

cd ${ZLIB_BUILD}
AR="${AR}" CC="${CC}" CFLAGS="$FLAGS -Wno-deprecated-non-prototype" RANLIB=/bin/true ./configure --static
make -j libz.a
Expand Down

0 comments on commit 4de9260

Please sign in to comment.