diff --git a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh deleted file mode 100755 --- a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/ar_to_bc.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/usr/bin/env bash - -function usage() { - echo "Usage: $0 INPUT... OUTPUT" - exit 1 -} - -if [ "$#" -le 1 ]; then - usage -fi - -[[ $AR == /* ]] || AR=$PWD/$AR -[[ $LINK == /* ]] || LINK=$PWD/$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 - if [[ $(file $OBJ) =~ 'LLVM IR bitcode' ]]; then - mv -f $OBJ $(basename $INPUT).$OBJ - else - # Skip $OBJ which may come from an assembly file (e.g. Support/BLAKE3/*.S). - rm -f $OBJ - fi - done -done - -$LINK *.o -o $OUTPUT - -rm -rf $SCRATCH_DIR diff --git a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh --- a/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh +++ b/compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh @@ -69,8 +69,8 @@ CXX=$CLANG_DIR/clang++ TBLGEN=$CLANG_DIR/llvm-tblgen OPT=$CLANG_DIR/opt -export AR=$CLANG_DIR/llvm-ar -export LINK=$CLANG_DIR/llvm-link +AR=$CLANG_DIR/llvm-ar +LINK=$CLANG_DIR/llvm-link TARGET_TRIPLE=$($CC -print-target-triple) for F in $CC $CXX $TBLGEN $LINK $OPT $AR; do @@ -165,23 +165,23 @@ LIBCXX_ARCHIVE_DIR=$(dirname $(find $LIBCXX_BUILD -name libc++.a | head -n1)) # Merge all the object files together and copy the resulting library back. -$SCRIPT_DIR/ar_to_bc.sh $LIBCXX_ARCHIVE_DIR/libc++.a \ - $LIBCXX_ARCHIVE_DIR/libc++abi.a \ - $LLVM_BUILD/lib/libLLVMSymbolize.a \ - $LLVM_BUILD/lib/libLLVMObject.a \ - $LLVM_BUILD/lib/libLLVMBinaryFormat.a \ - $LLVM_BUILD/lib/libLLVMDebugInfoDWARF.a \ - $LLVM_BUILD/lib/libLLVMSupport.a \ - $LLVM_BUILD/lib/libLLVMDebugInfoPDB.a \ - $LLVM_BUILD/lib/libLLVMDebugInfoMSF.a \ - $LLVM_BUILD/lib/libLLVMDebugInfoCodeView.a \ - $LLVM_BUILD/lib/libLLVMDebuginfod.a \ - $LLVM_BUILD/lib/libLLVMDemangle.a \ - $LLVM_BUILD/lib/libLLVMMC.a \ - $LLVM_BUILD/lib/libLLVMTextAPI.a \ - $ZLIB_BUILD/libz.a \ - symbolizer.a \ - all.bc +$LINK $LIBCXX_ARCHIVE_DIR/libc++.a \ + $LIBCXX_ARCHIVE_DIR/libc++abi.a \ + $LLVM_BUILD/lib/libLLVMSymbolize.a \ + $LLVM_BUILD/lib/libLLVMObject.a \ + $LLVM_BUILD/lib/libLLVMBinaryFormat.a \ + $LLVM_BUILD/lib/libLLVMDebugInfoDWARF.a \ + $LLVM_BUILD/lib/libLLVMSupport.a \ + $LLVM_BUILD/lib/libLLVMDebugInfoPDB.a \ + $LLVM_BUILD/lib/libLLVMDebugInfoMSF.a \ + $LLVM_BUILD/lib/libLLVMDebugInfoCodeView.a \ + $LLVM_BUILD/lib/libLLVMDebuginfod.a \ + $LLVM_BUILD/lib/libLLVMDemangle.a \ + $LLVM_BUILD/lib/libLLVMMC.a \ + $LLVM_BUILD/lib/libLLVMTextAPI.a \ + $ZLIB_BUILD/libz.a \ + symbolizer.a \ + -ignore-non-bitcode -o all.bc echo "Optimizing..." $OPT -internalize -internalize-public-api-list=${SYMBOLIZER_API_LIST} all.bc -o opt.bc diff --git a/llvm/tools/llvm-link/llvm-link.cpp b/llvm/tools/llvm-link/llvm-link.cpp --- a/llvm/tools/llvm-link/llvm-link.cpp +++ b/llvm/tools/llvm-link/llvm-link.cpp @@ -124,6 +124,12 @@ cl::desc("Do not run the verifier"), cl::Hidden, cl::cat(LinkCategory)); +static cl::opt IgnoreNonBitcode( + "ignore-non-bitcode", + cl::desc( + "Ignore non-bitcode file in archives instead of reporting an error"), + cl::Hidden); + static ExitOnError ExitOnErr; // Read the specified bitcode file in and return it. This routine searches the @@ -199,6 +205,8 @@ MemBuf.get().getBufferStart()), reinterpret_cast( MemBuf.get().getBufferEnd()))) { + if (IgnoreNonBitcode) + continue; errs() << Argv0 << ": "; WithColor::error() << " member of archive is not a bitcode file: '" << ChildName << "'\n";