[compiler-rt] r295272 - Extract *.a to *.bc conversion into separate script.
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Wed Feb 15 18:12:18 PST 2017
Author: vitalybuka
Date: Wed Feb 15 20:12:18 2017
New Revision: 295272
URL: http://llvm.org/viewvc/llvm-project?rev=295272&view=rev
Log:
Extract *.a to *.bc conversion into separate script.
Reviewers: eugenis
Subscribers: llvm-commits, kubamracek
Differential Revision: https://reviews.llvm.org/D30013
Added:
compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh (with props)
Modified:
compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
Added: compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh?rev=295272&view=auto
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh (added)
+++ compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh Wed Feb 15 20:12:18 2017
@@ -0,0 +1,39 @@
+#!/bin/bash
+
+function usage() {
+ echo "Usage: $0 INPUT... OUTPUT"
+ exit 1
+}
+
+if [ "$#" -le 1 ]; then
+ usage
+fi
+
+AR=$(readlink -f $AR)
+LINK=$(readlink -f $LINK)
+
+INPUTS=
+OUTPUT=
+for ARG in $@; do
+ INPUTS="$INPUTS $OUTPUT"
+ OUTPUT=$(readlink -f $ARG)
+done
+
+echo Inputs: $INPUTS
+echo Output: $OUTPUT
+
+SCRATCH_DIR=$(mktemp -d)
+ln -s $INPUTS $SCRATCH_DIR/
+
+pushd $SCRATCH_DIR
+
+for INPUT in *; do
+ for OBJ in $($AR t $INPUT); do
+ $AR x $INPUT $OBJ
+ mv -f $OBJ $(basename $INPUT).$OBJ
+ done
+done
+
+$LINK *.o -o $OUTPUT
+
+rm -rf $SCRATCH_DIR
Propchange: compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh
------------------------------------------------------------------------------
svn:executable = *
Modified: compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh?rev=295272&r1=295271&r2=295272&view=diff
==============================================================================
--- compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh (original)
+++ compiler-rt/trunk/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh Wed Feb 15 20:12:18 2017
@@ -58,9 +58,9 @@ cd $BUILD_DIR
CC=$CLANG_DIR/clang
CXX=$CLANG_DIR/clang++
TBLGEN=$CLANG_DIR/llvm-tblgen
-LINK=$CLANG_DIR/llvm-link
OPT=$CLANG_DIR/opt
-AR=$CLANG_DIR/llvm-ar
+export AR=$CLANG_DIR/llvm-ar
+export LINK=$CLANG_DIR/llvm-link
for F in $CC $CXX $TBLGEN $LINK $OPT $AR; do
if [[ ! -x "$F" ]]; then
@@ -136,7 +136,15 @@ rm -rf ${SYMBOLIZER_BUILD}
mkdir ${SYMBOLIZER_BUILD}
cd ${SYMBOLIZER_BUILD}
-for A in $LIBCXX_BUILD/lib/libc++.a \
+echo "Compiling..."
+SYMBOLIZER_FLAGS="$FLAGS -std=c++11 -I${LLVM_SRC}/include -I${LLVM_BUILD}/include -I${LIBCXX_BUILD}/include/c++/v1"
+$CXX $SYMBOLIZER_FLAGS ${SRC_DIR}/sanitizer_symbolize.cc ${SRC_DIR}/sanitizer_wrappers.cc -c
+$AR rc symbolizer.a sanitizer_symbolize.o sanitizer_wrappers.o
+
+SYMBOLIZER_API_LIST=__sanitizer_symbolize_code,__sanitizer_symbolize_data,__sanitizer_symbolize_flush,__sanitizer_symbolize_demangle
+
+# Merge all the object files together and copy the resulting library back.
+$SCRIPT_DIR/ar_to_bc.sh $LIBCXX_BUILD/lib/libc++.a \
$LIBCXX_BUILD/lib/libc++abi.a \
$LLVM_BUILD/lib/libLLVMSymbolize.a \
$LLVM_BUILD/lib/libLLVMObject.a \
@@ -144,21 +152,10 @@ for A in $LIBCXX_BUILD/lib/libc++.a \
$LLVM_BUILD/lib/libLLVMSupport.a \
$LLVM_BUILD/lib/libLLVMDebugInfoPDB.a \
$LLVM_BUILD/lib/libLLVMMC.a \
- $ZLIB_BUILD/libz.a ; do
- for O in $($AR t $A); do
- $AR x $A $O
- mv -f $O "$(basename $A).$O" # Rename to avoid collisions between libs.
- done
-done
+ $ZLIB_BUILD/libz.a \
+ symbolizer.a \
+ all.bc
-echo "Compiling..."
-SYMBOLIZER_FLAGS="$FLAGS -std=c++11 -I${LLVM_SRC}/include -I${LLVM_BUILD}/include -I${LIBCXX_BUILD}/include/c++/v1"
-$CXX $SYMBOLIZER_FLAGS ${SRC_DIR}/sanitizer_symbolize.cc ${SRC_DIR}/sanitizer_wrappers.cc -c
-
-SYMBOLIZER_API_LIST=__sanitizer_symbolize_code,__sanitizer_symbolize_data,__sanitizer_symbolize_flush,__sanitizer_symbolize_demangle
-
-# Merge all the object files together and copy the resulting library back.
-$LINK *.o -o all.bc
echo "Optimizing..."
$OPT -internalize -internalize-public-api-list=${SYMBOLIZER_API_LIST} all.bc -o opt.bc
$CC $FLAGS -fno-lto -c opt.bc -o symbolizer.o
More information about the llvm-commits
mailing list