Skip to content

[build_symbolizer] Introduce ZLIB_SRC to specify an on-disk location for #70994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 1, 2023
Merged
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
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be if [[ ! -d ${ZLIB_BUILD} ]] ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for catching this, @htyu. Fixed in a follow-up.

commit d06596516fcb4d32a26eef5930a50fa56457814b (HEAD -> github/main, github/main)
Author: Davide Italiano <[email protected]>
Date:   Wed Nov 1 18:38:27 2023 -0700

    [build_symbolizer] Fix typo in 2c81d70747ac81b37b6c7639fe7afa328e8f5e79

diff --git a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
index 13acced825e0..520e0a631cb4 100755
--- a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
+++ b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
@@ -71,7 +71,7 @@ FLAGS+=" -include ${SRC_DIR}/../sanitizer_redefine_builtins.h -DSANITIZER_COMMON
 LINKFLAGS="-fuse-ld=lld -target $TARGET_TRIPLE"
 
 # Build zlib.
-if [[ -d ${ZLIB_BUILD} ]]; then
+if [[ ! -d ${ZLIB_BUILD} ]]; then
   if [[ -z "${ZLIB_SRC}" ]]; then
     git clone https://github.com/madler/zlib ${ZLIB_BUILD}
   else

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