Commit 92a76881 authored by Dirk Pranke's avatar Dirk Pranke

Revert "Roll Clang 214024:216630 (+216684) and switch to CMake (try 2)"

This reverts commit 3853ffa8.

The change broke the Mac10.6 Tests bot on the chromium.webkit waterfall.

TBR=hwennborg@chromium.org, thakis@chromium.org
BUG=400849

Review URL: https://codereview.chromium.org/572413002

Cr-Commit-Position: refs/heads/master@{#295132}
parent 715038ab
......@@ -109,17 +109,6 @@ config("compiler") {
# and the fix is in chromium.
"-fno-slp-vectorize",
]
if (is_debug) {
# Allow comparing the address of references and 'this' against 0
# in debug builds. Technically, these can never be null in
# well-defined C/C++ and Clang can optimize such checks away in
# release builds, but they may be used in asserts in debug builds.
cflags_cc += [
"-Wno-undefined-bool-conversion",
"-Wno-tautological-undefined-compare",
]
}
}
if (is_clang && !is_win) {
......
......@@ -865,7 +865,7 @@ class BlinkGCPluginConsumer : public ASTConsumer {
visitor.TraverseDecl(context.getTranslationUnitDecl());
if (options_.dump_graph) {
std::error_code err;
string err;
// TODO: Make createDefaultOutputFile or a shorter createOutputFile work.
json_ = JsonWriter::from(instance_.createOutputFile(
"", // OutputPath
......@@ -878,7 +878,7 @@ class BlinkGCPluginConsumer : public ASTConsumer {
false, // CreateMissingDirectories
0, // ResultPathName
0)); // TempPathName
if (!err && json_) {
if (err.empty() && json_) {
json_->OpenList();
} else {
json_ = 0;
......@@ -1844,10 +1844,9 @@ class BlinkGCPluginAction : public PluginASTAction {
protected:
// Overridden from PluginASTAction:
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(
CompilerInstance& instance,
llvm::StringRef ref) {
return llvm::make_unique<BlinkGCPluginConsumer>(instance, options_);
virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance,
llvm::StringRef ref) {
return new BlinkGCPluginConsumer(instance, options_);
}
virtual bool ParseArgs(const CompilerInstance& instance,
......
cmake_minimum_required(VERSION 2.8.8)
project(BlinkGCPlugin)
# This pugin is built using LLVM's build system, not Chromium's.
# It expects LLVM_SRC_DIR and LLVM_BUILD_DIR to be set.
# For example:
#
# cmake -GNinja -DLLVM_BUILD_DIR=$CHROMIUM_SRC_DIR/third_party/llvm-build \
# -DLLVM_SRC_DIR=$CHROMIUM_SRC_DIR/third_party/llvm \
# $CHROMIUM_SRC_DIR/tools/clang/blink_gc_plugin/
# ninja
list(APPEND CMAKE_MODULE_PATH "${LLVM_BUILD_DIR}/share/llvm/cmake")
include(LLVMConfig)
include(AddLLVM)
include(HandleLLVMOptions)
set(LLVM_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
set(LLVM_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib")
include_directories("${LLVM_SRC_DIR}/include"
"${LLVM_SRC_DIR}/tools/clang/include"
"${LLVM_BUILD_DIR}/include"
"${LLVM_BUILD_DIR}/tools/clang/include")
# This line is read by update.sh and other scripts in tools/clang/scripts
# Note: The spaces are significant.
set(LIBRARYNAME BlinkGCPlugin_10)
add_llvm_loadable_module("lib${LIBRARYNAME}"
BlinkGCPlugin.cpp
Edge.cpp
RecordInfo.cpp
)
# This file requires the clang build system, at least for now. So to use this
# Makefile, you should execute the following commands to copy this directory
# into a clang checkout:
#
# cp -R <this directory> third_party/llvm/tools/clang/tools/chrome-plugin
# cd third_party/llvm/tools/clang/tools/chrome-plugin
# make
CLANG_LEVEL := ../..
# This line is read by update.sh and other scripts in tools/clang/scripts
LIBRARYNAME = BlinkGCPlugin_9
LINK_LIBS_IN_SHARED = 0
SHARED_LIBRARY = 1
include $(CLANG_LEVEL)/Makefile
ifeq ($(OS),Darwin)
LDFLAGS+=-Wl,-undefined,dynamic_lookup
endif
......@@ -15,8 +15,7 @@ failed_any_test=
# Prints usage information.
usage() {
echo "Usage: $(basename "${0}")" \
"<path to clang>" \
"<path to plugin>"
"<Path to the llvm build dir, usually Release+Asserts>"
echo ""
echo " Runs all the libBlinkGCPlugin unit tests"
echo ""
......@@ -28,8 +27,8 @@ do_testcase() {
if [ -e "${3}" ]; then
flags="$(cat "${3}")"
fi
local output="$("${CLANG_PATH}" -c -Wno-c++11-extensions \
-Xclang -load -Xclang "${PLUGIN_PATH}" \
local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \
-Xclang -load -Xclang "${CLANG_DIR}"/lib/lib${LIBNAME}.${LIB} \
-Xclang -add-plugin -Xclang blink-gc-plugin ${flags} ${1} 2>&1)"
local json="${input%cpp}graph.json"
if [ -f "$json" ]; then
......@@ -53,26 +52,24 @@ do_testcase() {
if [[ -z "${1}" ]]; then
usage
exit ${E_BADARGS}
elif [[ -z "${2}" ]]; then
usage
exit ${E_BADARGS}
elif [[ ! -x "${1}" ]]; then
echo "${1} is not an executable"
usage
exit ${E_BADARGS}
elif [[ ! -f "${2}" ]]; then
echo "${2} could not be found"
elif [[ ! -d "${1}" ]]; then
echo "${1} is not a directory."
usage
exit ${E_BADARGS}
else
export CLANG_PATH="${1}"
export PLUGIN_PATH="${2}"
echo "Using clang ${CLANG_PATH}..."
echo "Using plugin ${PLUGIN_PATH}..."
export CLANG_DIR="${PWD}/${1}"
echo "Using clang directory ${CLANG_DIR}..."
# The golden files assume that the cwd is this directory. To make the script
# work no matter what the cwd is, explicitly cd to there.
cd "$(dirname "${0}")"
export LIBNAME=$(grep LIBRARYNAME ../Makefile | cut -d ' ' -f 3)
if [ "$(uname -s)" = "Linux" ]; then
export LIB=so
elif [ "$(uname -s)" = "Darwin" ]; then
export LIB=dylib
fi
fi
for input in *.cpp; do
......
cmake_minimum_required(VERSION 2.8.8)
project(FindBadConstructs)
# This pugin is built using LLVM's build system, not Chromium's.
# It expects LLVM_SRC_DIR and LLVM_BUILD_DIR to be set.
# For example:
#
# cmake -GNinja -DLLVM_BUILD_DIR=$CHROMIUM_SRC_DIR/third_party/llvm-build \
# -DLLVM_SRC_DIR=$CHROMIUM_SRC_DIR/third_party/llvm \
# $CHROMIUM_SRC_DIR/tools/clang/blink_gc_plugin/
# ninja
list(APPEND CMAKE_MODULE_PATH "${LLVM_BUILD_DIR}/share/llvm/cmake")
include(LLVMConfig)
include(AddLLVM)
include(HandleLLVMOptions)
set(LLVM_RUNTIME_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin")
set(LLVM_LIBRARY_OUTPUT_INTDIR "${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib")
include_directories("${LLVM_SRC_DIR}/include"
"${LLVM_SRC_DIR}/tools/clang/include"
"${LLVM_BUILD_DIR}/include"
"${LLVM_BUILD_DIR}/tools/clang/include")
add_llvm_loadable_module(libFindBadConstructs
ChromeClassTester.cpp
FindBadConstructsAction.cpp
FindBadConstructsConsumer.cpp
)
......@@ -15,10 +15,10 @@ namespace chrome_checker {
FindBadConstructsAction::FindBadConstructsAction() {
}
std::unique_ptr<ASTConsumer> FindBadConstructsAction::CreateASTConsumer(
ASTConsumer* FindBadConstructsAction::CreateASTConsumer(
CompilerInstance& instance,
llvm::StringRef ref) {
return llvm::make_unique<FindBadConstructsConsumer>(instance, options_);
return new FindBadConstructsConsumer(instance, options_);
}
bool FindBadConstructsAction::ParseArgs(const CompilerInstance& instance,
......
......@@ -17,7 +17,7 @@ class FindBadConstructsAction : public clang::PluginASTAction {
protected:
// Overridden from PluginASTAction:
virtual std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
virtual clang::ASTConsumer* CreateASTConsumer(
clang::CompilerInstance& instance,
llvm::StringRef ref);
virtual bool ParseArgs(const clang::CompilerInstance& instance,
......
# This file requires the clang build system, at least for now. So to use this
# Makefile, you should execute the following commands to copy this directory
# into a clang checkout:
#
# cp -R <this directory> third_party/llvm/tools/clang/tools/chrome-plugin
# cd third_party/llvm/tools/clang/tools/chrome-plugin
# make
CLANG_LEVEL := ../..
LIBRARYNAME = FindBadConstructs
LINK_LIBS_IN_SHARED = 0
SHARED_LIBRARY = 1
include $(CLANG_LEVEL)/Makefile
ifeq ($(OS),Darwin)
LDFLAGS+=-Wl,-undefined,dynamic_lookup
endif
......@@ -15,8 +15,7 @@ failed_any_test=
# Prints usage information.
usage() {
echo "Usage: $(basename "${0}")" \
"<path to clang>" \
"<path to plugin>"
"<Path to the llvm build dir, usually Release+Asserts>"
echo ""
echo " Runs all the libFindBadConstructs unit tests"
echo ""
......@@ -33,8 +32,8 @@ do_testcase() {
flags="${flags} -isysroot $(xcrun --show-sdk-path) -stdlib=libstdc++"
fi
local output="$("${CLANG_PATH}" -c -Wno-c++11-extensions \
-Xclang -load -Xclang "${PLUGIN_PATH}" \
local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \
-Xclang -load -Xclang "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \
-Xclang -add-plugin -Xclang find-bad-constructs ${flags} ${1} 2>&1)"
local diffout="$(echo "${output}" | diff - "${2}")"
if [ "${diffout}" = "" ]; then
......@@ -54,26 +53,23 @@ do_testcase() {
if [[ -z "${1}" ]]; then
usage
exit ${E_BADARGS}
elif [[ -z "${2}" ]]; then
usage
exit ${E_BADARGS}
elif [[ ! -x "${1}" ]]; then
echo "${1} is not an executable"
usage
exit ${E_BADARGS}
elif [[ ! -f "${2}" ]]; then
echo "${2} could not be found"
elif [[ ! -d "${1}" ]]; then
echo "${1} is not a directory."
usage
exit ${E_BADARGS}
else
export CLANG_PATH="${1}"
export PLUGIN_PATH="${2}"
echo "Using clang ${CLANG_PATH}..."
echo "Using plugin ${PLUGIN_PATH}..."
export CLANG_DIR="${PWD}/${1}"
echo "Using clang directory ${CLANG_DIR}..."
# The golden files assume that the cwd is this directory. To make the script
# work no matter what the cwd is, explicitly cd to there.
cd "$(dirname "${0}")"
if [ "$(uname -s)" = "Linux" ]; then
export LIB=so
elif [ "$(uname -s)" = "Darwin" ]; then
export LIB=dylib
fi
fi
for input in *.cpp; do
......
......@@ -13,9 +13,10 @@ if uname -s | grep -q Darwin; then
else
LIBSUFFIX=so
fi
LIBNAME=\
$(grep 'set(LIBRARYNAME' "$THIS_ABS_DIR"/../blink_gc_plugin/CMakeLists.txt \
| cut -d ' ' -f 2 | tr -d ')')
$(grep LIBRARYNAME "$THIS_ABS_DIR"/../blink_gc_plugin/Makefile \
| cut -d ' ' -f 3)
FLAGS=""
PREFIX="-Xclang -plugin-arg-blink-gc-plugin -Xclang"
......
......@@ -59,16 +59,9 @@ svn diff "${LLVM_DIR}" 2>&1 | tee -a buildlog.txt
echo "Diff in llvm/tools/clang:" | tee -a buildlog.txt
svn stat "${LLVM_DIR}/tools/clang" 2>&1 | tee -a buildlog.txt
svn diff "${LLVM_DIR}/tools/clang" 2>&1 | tee -a buildlog.txt
echo "Diff in llvm/compiler-rt:" | tee -a buildlog.txt
svn stat "${LLVM_DIR}/compiler-rt" 2>&1 | tee -a buildlog.txt
svn diff "${LLVM_DIR}/compiler-rt" 2>&1 | tee -a buildlog.txt
echo "Diff in llvm/projects/libcxx:" | tee -a buildlog.txt
svn stat "${LLVM_DIR}/projects/libcxx" 2>&1 | tee -a buildlog.txt
svn diff "${LLVM_DIR}/projects/libcxx" 2>&1 | tee -a buildlog.txt
echo "Diff in llvm/projects/libcxxabi:" | tee -a buildlog.txt
svn stat "${LLVM_DIR}/projects/libcxxabi" 2>&1 | tee -a buildlog.txt
svn diff "${LLVM_DIR}/projects/libcxxabi" 2>&1 | tee -a buildlog.txt
echo "Diff in llvm/projects/compiler-rt:" | tee -a buildlog.txt
svn stat "${LLVM_DIR}/projects/compiler-rt" 2>&1 | tee -a buildlog.txt
svn diff "${LLVM_DIR}/projects/compiler-rt" 2>&1 | tee -a buildlog.txt
echo "Starting build" | tee -a buildlog.txt
......@@ -86,7 +79,7 @@ fi
${extra_flags} 2>&1 | tee -a buildlog.txt
R=$("${LLVM_BIN_DIR}/clang" --version | \
sed -ne 's/clang version .*(\([0-9]*\))/\1/p')
sed -ne 's/clang version .*(trunk \([0-9]*\))/\1/p')
PDIR=clang-$R
rm -rf $PDIR
......@@ -123,8 +116,8 @@ fi
cp "${LLVM_LIB_DIR}/libFindBadConstructs.${SO_EXT}" $PDIR/lib
BLINKGCPLUGIN_LIBNAME=\
$(grep 'set(LIBRARYNAME' "$THIS_DIR"/../blink_gc_plugin/CMakeLists.txt \
| cut -d ' ' -f 2 | tr -d ')')
$(grep LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \
| cut -d ' ' -f 3)
cp "${LLVM_LIB_DIR}/lib${BLINKGCPLUGIN_LIBNAME}.${SO_EXT}" $PDIR/lib
if [[ -n "${gcc_toolchain}" ]]; then
......@@ -133,7 +126,7 @@ if [[ -n "${gcc_toolchain}" ]]; then
fi
# Copy built-in headers (lib/clang/3.x.y/include).
# compiler-rt builds all kinds of libraries, but we want only some.
# libcompiler-rt puts all kinds of libraries there too, but we want only some.
if [ "$(uname -s)" = "Darwin" ]; then
# Keep only the OSX (ASan and profile) and iossim (ASan) runtime libraries:
# Release+Asserts/lib/clang/*/lib/darwin/libclang_rt.{asan,profile}_*
......@@ -151,7 +144,6 @@ if [ "$(uname -s)" = "Darwin" ]; then
ASAN_DYLIB=$(find "${LLVM_LIB_DIR}/clang" \
-type f -path "*${ASAN_DYLIB_NAME}")
install_name_tool -id @executable_path/${ASAN_DYLIB_NAME} "${ASAN_DYLIB}"
strip -x "${ASAN_DYLIB}"
done
else
# Keep only
......@@ -159,12 +151,12 @@ else
# , but not dfsan.
find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/linux*' \
! -name '*[atm]san*' ! -name '*ubsan*' ! -name '*libclang_rt.san*' \
! -name '*profile*' | xargs rm -v
! -name '*profile*' | xargs rm
# Strip the debug info from the runtime libraries.
find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/linux*' ! -name '*.syms' | xargs strip -g
find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/linux*' | xargs strip -g
fi
cp -vR "${LLVM_LIB_DIR}/clang" $PDIR/lib
cp -R "${LLVM_LIB_DIR}/clang" $PDIR/lib
if [ "$(uname -s)" = "Darwin" ]; then
tar zcf $PDIR.tgz -C $PDIR bin include lib buildlog.txt
......
......@@ -30,7 +30,7 @@ fi
"$THIS_DIR"/package.sh $@
R=$("${LLVM_BIN_DIR}/clang" --version | \
sed -ne 's/clang version .*(\([0-9]*\))/\1/p')
sed -ne 's/clang version .*(trunk \([0-9]*\))/\1/p')
PDIR=clang-$R
if [ ! -f "$PDIR.tgz" ]; then
......@@ -43,9 +43,9 @@ fi
rm -rf $LLVM_BUILD_DIR
"$THIS_DIR"/update.sh
LIBNAME=\
$(grep 'set(LIBRARYNAME' "$THIS_DIR"/../blink_gc_plugin/CMakeLists.txt \
| cut -d ' ' -f 2 | tr -d ')')
LIBNAME=$(grep LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \
| cut -d ' ' -f 3)
LIBFILE=lib$LIBNAME.$SO_EXT
# Check that we are actually creating the plugin at a new revision.
......
......@@ -8,33 +8,29 @@
# Do NOT CHANGE this if you don't know what you're doing -- see
# https://code.google.com/p/chromium/wiki/UpdatingClang
# Reverting problematic clang rolls is safe, though.
CLANG_REVISION=216630
CLANG_REVISION=214024
THIS_DIR="$(dirname "${0}")"
LLVM_DIR="${THIS_DIR}/../../../third_party/llvm"
LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build/Release+Asserts"
COMPILER_RT_BUILD_DIR="${LLVM_DIR}/../llvm-build/compiler-rt"
LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build"
LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap"
LLVM_BOOTSTRAP_INSTALL_DIR="${LLVM_DIR}/../llvm-bootstrap-install"
CLANG_DIR="${LLVM_DIR}/tools/clang"
CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra"
COMPILER_RT_DIR="${LLVM_DIR}/compiler-rt"
COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt"
LIBCXX_DIR="${LLVM_DIR}/projects/libcxx"
LIBCXXABI_DIR="${LLVM_DIR}/projects/libcxxabi"
ANDROID_NDK_DIR="${THIS_DIR}/../../../third_party/android_tools/ndk"
STAMP_FILE="${LLVM_DIR}/../llvm-build/cr_build_revision"
ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk"
STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision"
ABS_LIBCXX_DIR="${PWD}/${LIBCXX_DIR}"
ABS_LIBCXXABI_DIR="${PWD}/${LIBCXXABI_DIR}"
ABS_LLVM_DIR="${PWD}/${LLVM_DIR}"
ABS_LLVM_BUILD_DIR="${PWD}/${LLVM_BUILD_DIR}"
ABS_COMPILER_RT_DIR="${PWD}/${COMPILER_RT_DIR}"
# Use both the clang revision and the plugin revisions to test for updates.
BLINKGCPLUGIN_REVISION=\
$(grep 'set(LIBRARYNAME' "$THIS_DIR"/../blink_gc_plugin/CMakeLists.txt \
| cut -d ' ' -f 2 | tr -cd '[0-9]')
$(grep LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \
| cut -d '_' -f 2)
CLANG_AND_PLUGINS_REVISION="${CLANG_REVISION}-${BLINKGCPLUGIN_REVISION}"
# ${A:-a} returns $A if it's set, a else.
......@@ -65,6 +61,11 @@ gcc_toolchain=
if [[ "${OS}" = "Darwin" ]]; then
with_android=
fi
if [ "${OS}" = "FreeBSD" ]; then
MAKE=gmake
else
MAKE=make
fi
while [[ $# > 0 ]]; do
case $1 in
......@@ -197,9 +198,9 @@ if [[ -z "$force_local_build" ]]; then
exit 1
fi
if [ -f "${CDS_OUTPUT}" ]; then
rm -rf "${LLVM_BUILD_DIR}"
mkdir -p "${LLVM_BUILD_DIR}"
tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}"
rm -rf "${LLVM_BUILD_DIR}/Release+Asserts"
mkdir -p "${LLVM_BUILD_DIR}/Release+Asserts"
tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}/Release+Asserts"
echo clang "${CLANG_REVISION}" unpacked
echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}"
rm -rf "${CDS_OUT_DIR}"
......@@ -218,16 +219,6 @@ if [[ -n "${with_android}" ]] && ! [[ -d "${ANDROID_NDK_DIR}" ]]; then
exit 1
fi
# Check that cmake and ninja are available.
if ! which cmake > /dev/null; then
echo "CMake needed to build clang; please install"
exit 1
fi
if ! which ninja > /dev/null; then
echo "ninja needed to build clang, please install"
exit 1
fi
echo Getting LLVM r"${CLANG_REVISION}" in "${LLVM_DIR}"
if ! svn co --force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \
"${LLVM_DIR}"; then
......@@ -239,10 +230,6 @@ fi
echo Getting clang r"${CLANG_REVISION}" in "${CLANG_DIR}"
svn co --force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}"
# We have moved from building compiler-rt in the LLVM tree, to a separate
# directory. Nuke any previous checkout to avoid building it.
rm -rf "${LLVM_DIR}/projects/compiler-rt"
echo Getting compiler-rt r"${CLANG_REVISION}" in "${COMPILER_RT_DIR}"
svn co --force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \
"${COMPILER_RT_DIR}"
......@@ -263,7 +250,7 @@ if [ "${OS}" = "Darwin" ]; then
"${LIBCXXABI_DIR}"
fi
# Apply patch for tests failing with --disable-pthreads (llvm.org/PR11974)
# Apply patch for test failing with --disable-pthreads (llvm.org/PR11974)
pushd "${CLANG_DIR}"
svn revert test/Index/crash-recovery-modules.m
cat << 'EOF' |
......@@ -281,76 +268,27 @@ EOF
patch -p4
popd
pushd "${CLANG_DIR}"
svn revert unittests/libclang/LibclangTest.cpp
cat << 'EOF' |
--- unittests/libclang/LibclangTest.cpp (revision 215949)
+++ unittests/libclang/LibclangTest.cpp (working copy)
@@ -431,7 +431,7 @@
EXPECT_EQ(0U, clang_getNumDiagnostics(ClangTU));
}
-TEST_F(LibclangReparseTest, ReparseWithModule) {
+TEST_F(LibclangReparseTest, DISABLED_ReparseWithModule) {
const char *HeaderTop = "#ifndef H\n#define H\nstruct Foo { int bar;";
const char *HeaderBottom = "\n};\n#endif\n";
const char *MFile = "#include \"HeaderFile.h\"\nint main() {"
EOF
patch -p0
popd
# Apply r216684 to fix ASan array cookie instrumentation problem.
# (See https://code.google.com/p/chromium/issues/detail?id=400849#c17)
pushd "${COMPILER_RT_DIR}"
svn revert lib/asan/asan_rtl.cc
cat << 'EOF' |
--- a/lib/asan/asan_rtl.cc
+++ b/lib/asan/asan_rtl.cc
@@ -269,7 +269,7 @@ void InitializeFlags(Flags *f, const char *env) {
f->allow_reexec = true;
f->print_full_thread_history = true;
f->poison_heap = true;
- f->poison_array_cookie = true;
+ f->poison_array_cookie = false;
f->poison_partial = true;
// Turn off alloc/dealloc mismatch checker on Mac and Windows for now.
// https://code.google.com/p/address-sanitizer/issues/detail?id=131
diff --git a/test/asan/TestCases/Linux/new_array_cookie_test.cc b/test/asan/TestCases/Linux/new_array_cookie_test.cc
index 339120b..49545f0 100644
--- a/test/asan/TestCases/Linux/new_array_cookie_test.cc
+++ b/test/asan/TestCases/Linux/new_array_cookie_test.cc
@@ -1,6 +1,6 @@
// REQUIRES: asan-64-bits
-// RUN: %clangxx_asan -O0 %s -o %t && not %run %t 2>&1 | FileCheck %s
-// RUN: %clangxx_asan -O3 %s -o %t && not %run %t 2>&1 | FileCheck %s
+// RUN: %clangxx_asan -O3 %s -o %t
+// RUN %run %t
// RUN: ASAN_OPTIONS=poison_array_cookie=1 not %run %t 2>&1 | FileCheck %s
// RUN: ASAN_OPTIONS=poison_array_cookie=0 %run %t
#include <stdio.h>
EOF
patch -p1
popd
# Echo all commands.
set -x
# Set default values for CC and CXX if they're not set in the environment.
CC=${CC:-cc}
CXX=${CXX:-c++}
NUM_JOBS=3
if [[ "${OS}" = "Linux" ]]; then
NUM_JOBS="$(grep -c "^processor" /proc/cpuinfo)"
elif [ "${OS}" = "Darwin" -o "${OS}" = "FreeBSD" ]; then
NUM_JOBS="$(sysctl -n hw.ncpu)"
fi
if [[ -n "${gcc_toolchain}" ]]; then
# Use the specified gcc installation for building.
CC="$gcc_toolchain/bin/gcc"
CXX="$gcc_toolchain/bin/g++"
export CC="$gcc_toolchain/bin/gcc"
export CXX="$gcc_toolchain/bin/g++"
# Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap compiler,
# etc.) find the .so.
export LD_LIBRARY_PATH="$(dirname $(${CXX} -print-file-name=libstdc++.so.6))"
fi
CFLAGS=""
CXXFLAGS=""
LDFLAGS=""
export CFLAGS=""
export CXXFLAGS=""
# LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
# needed, on OS X it requires libc++. clang only automatically links to libc++
# when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on
......@@ -361,9 +299,9 @@ LDFLAGS=""
if [ "${OS}" = "Darwin" ]; then
# When building on 10.9, /usr/include usually doesn't exist, and while
# Xcode's clang automatically sets a sysroot, self-built clangs don't.
CFLAGS="-isysroot $(xcrun --show-sdk-path)"
CPPFLAGS="${CFLAGS}"
CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLAGS}"
export CFLAGS="-isysroot $(xcrun --show-sdk-path)"
export CPPFLAGS="${CFLAGS}"
export CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLAGS}"
fi
# Build bootstrap clang if requested.
......@@ -372,25 +310,28 @@ if [[ -n "${bootstrap}" ]]; then
echo "Building bootstrap compiler"
mkdir -p "${LLVM_BOOTSTRAP_DIR}"
pushd "${LLVM_BOOTSTRAP_DIR}"
if [[ ! -f ./config.status ]]; then
# The bootstrap compiler only needs to be able to build the real compiler,
# so it needs no cross-compiler output support. In general, the host
# compiler should be as similar to the final compiler as possible, so do
# keep --disable-threads & co.
../llvm/configure \
--enable-optimized \
--enable-targets=host-only \
--enable-libedit=no \
--disable-threads \
--disable-pthreads \
--without-llvmgcc \
--without-llvmgxx \
--prefix="${ABS_INSTALL_DIR}"
fi
cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_TARGETS_TO_BUILD=host \
-DLLVM_ENABLE_THREADS=OFF \
-DCMAKE_INSTALL_PREFIX="${ABS_INSTALL_DIR}" \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
../llvm
ninja
${MAKE} -j"${NUM_JOBS}"
if [[ -n "${run_tests}" ]]; then
ninja check-all
${MAKE} check-all
fi
ninja install
${MAKE} install
if [[ -n "${gcc_toolchain}" ]]; then
# Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap
# compiler can start.
......@@ -399,14 +340,14 @@ if [[ -n "${bootstrap}" ]]; then
fi
popd
CC="${ABS_INSTALL_DIR}/bin/clang"
CXX="${ABS_INSTALL_DIR}/bin/clang++"
export CC="${ABS_INSTALL_DIR}/bin/clang"
export CXX="${ABS_INSTALL_DIR}/bin/clang++"
if [[ -n "${gcc_toolchain}" ]]; then
# Tell the bootstrap compiler to use a specific gcc prefix to search
# for standard library headers and shared object file.
CFLAGS="--gcc-toolchain=${gcc_toolchain}"
CXXFLAGS="--gcc-toolchain=${gcc_toolchain}"
export CFLAGS="--gcc-toolchain=${gcc_toolchain}"
export CXXFLAGS="--gcc-toolchain=${gcc_toolchain}"
fi
echo "Building final compiler"
......@@ -444,70 +385,34 @@ if [ "${OS}" = "Darwin" ]; then
-Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib/weak.exp
ln -sf libc++.1.dylib libc++.dylib
popd
LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild"
export LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild"
fi
if [[ ! -f ./CMakeCache.txt ]]; then
MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_THREADS=OFF \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
"${ABS_LLVM_DIR}"
env
if [[ ! -f ./config.status ]]; then
../llvm/configure \
--enable-optimized \
--enable-libedit=no \
--disable-threads \
--disable-pthreads \
--without-llvmgcc \
--without-llvmgxx
fi
if [[ -n "${gcc_toolchain}" ]]; then
# Copy in the right stdlibc++.so.6 so clang can start.
mkdir -p lib
cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" lib/
mkdir -p Release+Asserts/lib
cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" \
Release+Asserts/lib/
fi
ninja
MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}"
STRIP_FLAGS=
if [ "${OS}" = "Darwin" ]; then
# See http://crbug.com/256342
STRIP_FLAGS=-x
cp libcxxbuild/libc++.1.dylib bin/
cp libcxxbuild/libc++.1.dylib Release+Asserts/bin
fi
strip ${STRIP_FLAGS} bin/clang
popd
# Build compiler-rt out-of-tree.
mkdir -p "${COMPILER_RT_BUILD_DIR}"
pushd "${COMPILER_RT_BUILD_DIR}"
MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_THREADS=OFF \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DLLVM_CONFIG_PATH="${ABS_LLVM_BUILD_DIR}/bin/llvm-config" \
"${ABS_COMPILER_RT_DIR}"
ninja
# Copy selected output to the main tree.
# Darwin doesn't support cp --parents, so pipe through tar instead.
CLANG_VERSION=$("${ABS_LLVM_BUILD_DIR}/bin/clang" --version | \
sed -ne 's/clang version \([0-9]\.[0-9]\.[0-9]\).*/\1/p')
ABS_LLVM_CLANG_LIB_DIR="${ABS_LLVM_BUILD_DIR}/lib/clang/${CLANG_VERSION}"
tar -c *blacklist.txt | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
tar -c include/sanitizer | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
if [[ "${OS}" = "Darwin" ]]; then
tar -c lib/darwin | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
else
tar -c lib/linux | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
fi
strip ${STRIP_FLAGS} Release+Asserts/bin/clang
popd
if [[ -n "${with_android}" ]]; then
......@@ -522,24 +427,12 @@ if [[ -n "${with_android}" ]]; then
# http://crbug.com/357890
rm -v "${LLVM_BUILD_DIR}"/android-toolchain/include/c++/*/unwind.h
# Build ASan runtime for Android in a separate build tree.
mkdir -p ${LLVM_BUILD_DIR}/android
pushd ${LLVM_BUILD_DIR}/android
MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_THREADS=OFF \
-DCMAKE_C_COMPILER=${PWD}/../bin/clang \
-DCMAKE_CXX_COMPILER=${PWD}/../bin/clang++ \
-DLLVM_CONFIG_PATH=${PWD}/../bin/llvm-config \
-DCMAKE_C_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../android-toolchain/sysroot -B${PWD}/../android-toolchain" \
-DCMAKE_CXX_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../android-toolchain/sysroot -B${PWD}/../android-toolchain" \
-DANDROID=1 \
"${ABS_COMPILER_RT_DIR}"
ninja clang_rt.asan-arm-android
# And copy it into the main build tree.
cp "$(find -name libclang_rt.asan-arm-android.so)" "${ABS_LLVM_CLANG_LIB_DIR}/lib/linux/"
# Build ASan runtime for Android.
# Note: LLVM_ANDROID_TOOLCHAIN_DIR is not relative to PWD, but to where we
# build the runtime, i.e. third_party/llvm/projects/compiler-rt.
pushd "${LLVM_BUILD_DIR}"
${MAKE} -C tools/clang/runtime/ \
LLVM_ANDROID_TOOLCHAIN_DIR="../../../llvm-build/android-toolchain"
popd
fi
......@@ -548,38 +441,28 @@ fi
# For each tool directory, copy it into the clang tree and use clang's build
# system to compile it.
for CHROME_TOOL_DIR in ${chrome_tools}; do
TOOL_SRC_DIR="${PWD}/${THIS_DIR}/../${CHROME_TOOL_DIR}"
TOOL_BUILD_DIR="${ABS_LLVM_BUILD_DIR}/tools/clang/tools/chrome-${CHROME_TOOL_DIR}"
TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}"
TOOL_DST_DIR="${LLVM_DIR}/tools/clang/tools/chrome-${CHROME_TOOL_DIR}"
TOOL_BUILD_DIR="${LLVM_BUILD_DIR}/tools/clang/tools/chrome-${CHROME_TOOL_DIR}"
rm -rf "${TOOL_DST_DIR}"
cp -R "${TOOL_SRC_DIR}" "${TOOL_DST_DIR}"
rm -rf "${TOOL_BUILD_DIR}"
mkdir -p "${TOOL_BUILD_DIR}"
pushd "${TOOL_BUILD_DIR}"
MACOSX_DEPLOYMENT_TARGET=10.6 cmake -GNinja \
-DLLVM_BUILD_DIR="${ABS_LLVM_BUILD_DIR}" \
-DLLVM_SRC_DIR="${ABS_LLVM_DIR}" \
-DCMAKE_C_COMPILER="${CC}" \
-DCMAKE_CXX_COMPILER="${CXX}" \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
"${TOOL_SRC_DIR}"
ninja
cp -v "${TOOL_BUILD_DIR}/lib"/* "${ABS_LLVM_BUILD_DIR}/lib/"
popd
cp "${TOOL_SRC_DIR}/Makefile" "${TOOL_BUILD_DIR}"
MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" -C "${TOOL_BUILD_DIR}"
done
if [[ -n "$run_tests" ]]; then
# Run the tests for each chrome tool.
# Run a few tests.
for CHROME_TOOL_DIR in ${chrome_tools}; do
TOOL_SRC_DIR="${THIS_DIR}/../${CHROME_TOOL_DIR}"
TOOL_BUILD_DIR="${ABS_LLVM_BUILD_DIR}/tools/clang/tools/chrome-${CHROME_TOOL_DIR}"
if [[ -f "${TOOL_SRC_DIR}/tests/test.sh" ]]; then
"${TOOL_SRC_DIR}/tests/test.sh" "${ABS_LLVM_BUILD_DIR}/bin/clang" "${TOOL_BUILD_DIR}/lib"/*
"${TOOL_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts"
fi
done
# Run the LLVM and Clang tests.
ninja -C "${LLVM_BUILD_DIR}" check-all
pushd "${LLVM_BUILD_DIR}"
${MAKE} check-all
popd
fi
# After everything is done, log success for this revision.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment