Commit ff31c1ba authored by Hans Wennborg's avatar Hans Wennborg

Roll Clang 214024:216630 (+216684) and switch to CMake

This updates Chromium's clang version to r216630 with
r216684 cherry-picked to fix an ASan issue.

It also changes the build script for Clang to use CMake
instead of Autoconf. The ASan team say this configuration
is better tested, and it also makes us consistent with
the Windows Clang build which already uses CMake.

BUG=400849
R=thakis@chromium.org

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

Cr-Commit-Position: refs/heads/master@{#294953}
parent e77127ef
......@@ -865,7 +865,7 @@ class BlinkGCPluginConsumer : public ASTConsumer {
visitor.TraverseDecl(context.getTranslationUnitDecl());
if (options_.dump_graph) {
string err;
std::error_code 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.empty() && json_) {
if (!err && json_) {
json_->OpenList();
} else {
json_ = 0;
......@@ -1844,9 +1844,10 @@ class BlinkGCPluginAction : public PluginASTAction {
protected:
// Overridden from PluginASTAction:
virtual ASTConsumer* CreateASTConsumer(CompilerInstance& instance,
llvm::StringRef ref) {
return new BlinkGCPluginConsumer(instance, options_);
virtual std::unique_ptr<ASTConsumer> CreateASTConsumer(
CompilerInstance& instance,
llvm::StringRef ref) {
return llvm::make_unique<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,7 +15,8 @@ failed_any_test=
# Prints usage information.
usage() {
echo "Usage: $(basename "${0}")" \
"<Path to the llvm build dir, usually Release+Asserts>"
"<path to clang>" \
"<path to plugin>"
echo ""
echo " Runs all the libBlinkGCPlugin unit tests"
echo ""
......@@ -27,8 +28,8 @@ do_testcase() {
if [ -e "${3}" ]; then
flags="$(cat "${3}")"
fi
local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \
-Xclang -load -Xclang "${CLANG_DIR}"/lib/lib${LIBNAME}.${LIB} \
local output="$("${CLANG_PATH}" -c -Wno-c++11-extensions \
-Xclang -load -Xclang "${PLUGIN_PATH}" \
-Xclang -add-plugin -Xclang blink-gc-plugin ${flags} ${1} 2>&1)"
local json="${input%cpp}graph.json"
if [ -f "$json" ]; then
......@@ -52,24 +53,26 @@ do_testcase() {
if [[ -z "${1}" ]]; then
usage
exit ${E_BADARGS}
elif [[ ! -d "${1}" ]]; then
echo "${1} is not a directory."
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"
usage
exit ${E_BADARGS}
else
export CLANG_DIR="${PWD}/${1}"
echo "Using clang directory ${CLANG_DIR}..."
export CLANG_PATH="${1}"
export PLUGIN_PATH="${2}"
echo "Using clang ${CLANG_PATH}..."
echo "Using plugin ${PLUGIN_PATH}..."
# 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() {
}
ASTConsumer* FindBadConstructsAction::CreateASTConsumer(
std::unique_ptr<ASTConsumer> FindBadConstructsAction::CreateASTConsumer(
CompilerInstance& instance,
llvm::StringRef ref) {
return new FindBadConstructsConsumer(instance, options_);
return llvm::make_unique<FindBadConstructsConsumer>(instance, options_);
}
bool FindBadConstructsAction::ParseArgs(const CompilerInstance& instance,
......
......@@ -17,7 +17,7 @@ class FindBadConstructsAction : public clang::PluginASTAction {
protected:
// Overridden from PluginASTAction:
virtual clang::ASTConsumer* CreateASTConsumer(
virtual std::unique_ptr<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,7 +15,8 @@ failed_any_test=
# Prints usage information.
usage() {
echo "Usage: $(basename "${0}")" \
"<Path to the llvm build dir, usually Release+Asserts>"
"<path to clang>" \
"<path to plugin>"
echo ""
echo " Runs all the libFindBadConstructs unit tests"
echo ""
......@@ -32,8 +33,8 @@ do_testcase() {
flags="${flags} -isysroot $(xcrun --show-sdk-path) -stdlib=libstdc++"
fi
local output="$("${CLANG_DIR}"/bin/clang -c -Wno-c++11-extensions \
-Xclang -load -Xclang "${CLANG_DIR}"/lib/libFindBadConstructs.${LIB} \
local output="$("${CLANG_PATH}" -c -Wno-c++11-extensions \
-Xclang -load -Xclang "${PLUGIN_PATH}" \
-Xclang -add-plugin -Xclang find-bad-constructs ${flags} ${1} 2>&1)"
local diffout="$(echo "${output}" | diff - "${2}")"
if [ "${diffout}" = "" ]; then
......@@ -53,23 +54,26 @@ do_testcase() {
if [[ -z "${1}" ]]; then
usage
exit ${E_BADARGS}
elif [[ ! -d "${1}" ]]; then
echo "${1} is not a directory."
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"
usage
exit ${E_BADARGS}
else
export CLANG_DIR="${PWD}/${1}"
echo "Using clang directory ${CLANG_DIR}..."
export CLANG_PATH="${1}"
export PLUGIN_PATH="${2}"
echo "Using clang ${CLANG_PATH}..."
echo "Using plugin ${PLUGIN_PATH}..."
# 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,10 +13,9 @@ if uname -s | grep -q Darwin; then
else
LIBSUFFIX=so
fi
LIBNAME=\
$(grep LIBRARYNAME "$THIS_ABS_DIR"/../blink_gc_plugin/Makefile \
| cut -d ' ' -f 3)
$(grep 'set(LIBRARYNAME' "$THIS_ABS_DIR"/../blink_gc_plugin/CMakeLists.txt \
| cut -d ' ' -f 2 | tr -d ')')
FLAGS=""
PREFIX="-Xclang -plugin-arg-blink-gc-plugin -Xclang"
......
......@@ -59,9 +59,16 @@ 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/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 "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 "Starting build" | tee -a buildlog.txt
......@@ -79,7 +86,7 @@ fi
${extra_flags} 2>&1 | tee -a buildlog.txt
R=$("${LLVM_BIN_DIR}/clang" --version | \
sed -ne 's/clang version .*(trunk \([0-9]*\))/\1/p')
sed -ne 's/clang version .*(\([0-9]*\))/\1/p')
PDIR=clang-$R
rm -rf $PDIR
......@@ -116,8 +123,8 @@ fi
cp "${LLVM_LIB_DIR}/libFindBadConstructs.${SO_EXT}" $PDIR/lib
BLINKGCPLUGIN_LIBNAME=\
$(grep LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \
| cut -d ' ' -f 3)
$(grep 'set(LIBRARYNAME' "$THIS_DIR"/../blink_gc_plugin/CMakeLists.txt \
| cut -d ' ' -f 2 | tr -d ')')
cp "${LLVM_LIB_DIR}/lib${BLINKGCPLUGIN_LIBNAME}.${SO_EXT}" $PDIR/lib
if [[ -n "${gcc_toolchain}" ]]; then
......@@ -126,7 +133,7 @@ if [[ -n "${gcc_toolchain}" ]]; then
fi
# Copy built-in headers (lib/clang/3.x.y/include).
# libcompiler-rt puts all kinds of libraries there too, but we want only some.
# compiler-rt builds all kinds of libraries, 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}_*
......@@ -144,6 +151,7 @@ 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
......@@ -151,12 +159,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
! -name '*profile*' | xargs rm -v
# Strip the debug info from the runtime libraries.
find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/linux*' | xargs strip -g
find "${LLVM_LIB_DIR}/clang" -type f -path '*lib/linux*' ! -name '*.syms' | xargs strip -g
fi
cp -R "${LLVM_LIB_DIR}/clang" $PDIR/lib
cp -vR "${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 .*(trunk \([0-9]*\))/\1/p')
sed -ne 's/clang version .*(\([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 LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \
| cut -d ' ' -f 3)
LIBNAME=\
$(grep 'set(LIBRARYNAME' "$THIS_DIR"/../blink_gc_plugin/CMakeLists.txt \
| cut -d ' ' -f 2 | tr -d ')')
LIBFILE=lib$LIBNAME.$SO_EXT
# Check that we are actually creating the plugin at a new revision.
......
This diff is collapsed.
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