2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file.
6 # This script will check out llvm and clang into third_party/llvm and build it.
8 # Do NOT CHANGE this if you don't know what you're doing -- see
9 # https://code.google.com/p/chromium/wiki/UpdatingClang
10 # Reverting problematic clang rolls is safe, though.
13 # This is incremented when pushing a new build of Clang at the same revision.
16 PACKAGE_VERSION
="${CLANG_REVISION}-${CLANG_SUB_REVISION}"
18 THIS_DIR
="$(dirname "${0}")"
19 LLVM_DIR
="${THIS_DIR}/../../../third_party/llvm"
20 LLVM_BUILD_DIR
="${LLVM_DIR}/../llvm-build/Release+Asserts"
21 COMPILER_RT_BUILD_DIR
="${LLVM_DIR}/../llvm-build/compiler-rt"
22 LLVM_BOOTSTRAP_DIR
="${LLVM_DIR}/../llvm-bootstrap"
23 LLVM_BOOTSTRAP_INSTALL_DIR
="${LLVM_DIR}/../llvm-bootstrap-install"
24 CLANG_DIR
="${LLVM_DIR}/tools/clang"
25 COMPILER_RT_DIR
="${LLVM_DIR}/compiler-rt"
26 LIBCXX_DIR
="${LLVM_DIR}/projects/libcxx"
27 LIBCXXABI_DIR
="${LLVM_DIR}/projects/libcxxabi"
28 ANDROID_NDK_DIR
="${THIS_DIR}/../../../third_party/android_tools/ndk"
29 STAMP_FILE
="${LLVM_DIR}/../llvm-build/cr_build_revision"
30 CHROMIUM_TOOLS_DIR
="${THIS_DIR}/.."
31 BINUTILS_DIR
="${THIS_DIR}/../../../third_party/binutils"
33 ABS_CHROMIUM_TOOLS_DIR
="${PWD}/${CHROMIUM_TOOLS_DIR}"
34 ABS_LIBCXX_DIR
="${PWD}/${LIBCXX_DIR}"
35 ABS_LIBCXXABI_DIR
="${PWD}/${LIBCXXABI_DIR}"
36 ABS_LLVM_DIR
="${PWD}/${LLVM_DIR}"
37 ABS_LLVM_BUILD_DIR
="${PWD}/${LLVM_BUILD_DIR}"
38 ABS_COMPILER_RT_DIR
="${PWD}/${COMPILER_RT_DIR}"
39 ABS_BINUTILS_DIR
="${PWD}/${BINUTILS_DIR}"
41 # ${A:-a} returns $A if it's set, a else.
42 LLVM_REPO_URL
=${LLVM_URL:-https://llvm.org/svn/llvm-project}
44 CDS_URL
=https
://commondatastorage.googleapis.com
/chromium-browser-clang
46 if [[ -z "$GYP_DEFINES" ]]; then
49 if [[ -z "$GYP_GENERATORS" ]]; then
54 # Die if any command dies, error on undefined variable expansions.
58 if [[ -n ${LLVM_FORCE_HEAD_REVISION:-''} ]]; then
59 # Use a real version number rather than HEAD to make sure that
60 # --print-revision, stamp file logic, etc. all works naturally.
61 CLANG_REVISION
=$
(svn info
"$LLVM_REPO_URL" \
62 |
grep 'Last Changed Rev' |
awk '{ printf $4; }')
63 PACKAGE_VERSION
="${CLANG_REVISION}-0"
68 # Parse command line options.
74 chrome_tools
="plugins;blink_gc_plugin"
78 if [[ "${OS}" = "Darwin" ]]; then
82 while [[ $# > 0 ]]; do
108 if [[ $# == 0 ]]; then
109 echo "--with-chrome-tools requires an argument."
116 if [[ $# == 0 ]]; then
117 echo "--gcc-toolchain requires an argument."
120 if [[ -x "$1/bin/gcc" ]]; then
123 echo "Invalid --gcc-toolchain: '$1'."
124 echo "'$1/bin/gcc' does not appear to be valid."
130 echo "usage: $0 [--force-local-build] [--if-needed] [--run-tests] "
131 echo "--bootstrap: First build clang with CC, then with itself."
132 echo "--force-local-build: Don't try to download prebuilt binaries."
133 echo "--if-needed: Download clang only if the script thinks it is needed."
134 echo "--run-tests: Run tests after building. Only for local builds."
135 echo "--print-revision: Print current clang revision and exit."
136 echo "--without-android: Don't build ASan Android runtime library."
137 echo "--with-chrome-tools: Select which chrome tools to build." \
138 "Defaults to plugins;blink_gc_plugin."
139 echo " Example: --with-chrome-tools plugins;empty-string"
140 echo "--gcc-toolchain: Set the prefix for which GCC version should"
141 echo " be used for building. For example, to use gcc in"
142 echo " /opt/foo/bin/gcc, use '--gcc-toolchain '/opt/foo"
143 echo "--without-patches: Don't apply local patches."
148 echo "Unknown argument: '$1'."
149 echo "Use --help for help."
156 if [[ -n ${LLVM_FORCE_HEAD_REVISION:-''} ]]; then
157 force_local_build
=yes
159 # Skip local patches when using HEAD: they probably don't apply anymore.
162 if ! [[ "$GYP_DEFINES" =~ .
*OS
=android.
* ]]; then
163 # Only build the Android ASan rt when targetting Android.
167 LLVM_BUILD_TOOLS_DIR
="${ABS_LLVM_DIR}/../llvm-build-tools"
169 if [[ "${OS}" == "Linux" ]] && [[ -z "${gcc_toolchain}" ]]; then
170 if [[ $
(gcc
-dumpversion) < "4.7.0" ]]; then
171 # We need a newer GCC version.
172 if [[ ! -e "${LLVM_BUILD_TOOLS_DIR}/gcc482" ]]; then
173 echo "Downloading pre-built GCC 4.8.2..."
174 mkdir
-p "${LLVM_BUILD_TOOLS_DIR}"
175 curl
--fail -L "${CDS_URL}/tools/gcc482.tgz" | \
176 tar zxf
- -C "${LLVM_BUILD_TOOLS_DIR}"
179 gcc_toolchain
="${LLVM_BUILD_TOOLS_DIR}/gcc482"
181 # Always set gcc_toolchain; llvm-symbolizer needs the bundled libstdc++.
182 gcc_toolchain
="$(dirname $(dirname $(which gcc)))"
186 if [[ "${OS}" == "Linux" ||
"${OS}" == "Darwin" ]]; then
187 if [[ $
(cmake
--version |
grep -Eo '[0-9.]+') < "3.0" ]]; then
188 # We need a newer CMake version.
189 if [[ ! -e "${LLVM_BUILD_TOOLS_DIR}/cmake310" ]]; then
190 echo "Downloading pre-built CMake 3.10..."
191 mkdir
-p "${LLVM_BUILD_TOOLS_DIR}"
192 curl
--fail -L "${CDS_URL}/tools/cmake310_${OS}.tgz" | \
193 tar zxf
- -C "${LLVM_BUILD_TOOLS_DIR}"
196 export PATH
="${LLVM_BUILD_TOOLS_DIR}/cmake310/bin:${PATH}"
200 echo "LLVM_FORCE_HEAD_REVISION was set; using r${CLANG_REVISION}"
203 if [[ -n "$if_needed" ]]; then
204 if [[ "${OS}" == "Darwin" ]]; then
205 # clang is used on Mac.
207 elif [[ "$GYP_DEFINES" =~ .
*(clang|tsan|asan|lsan|msan
)=1.
* ]]; then
208 # clang requested via $GYP_DEFINES.
210 elif [[ -d "${LLVM_BUILD_DIR}" ]]; then
211 # clang previously downloaded, remove third_party/llvm-build to prevent
214 elif [[ "${OS}" == "Linux" ]]; then
215 # Temporarily use clang on linux. Leave a stamp file behind, so that
216 # this script can remove clang again on machines where it was autoinstalled.
217 mkdir
-p "${LLVM_BUILD_DIR}"
218 touch "${LLVM_BUILD_DIR}/autoinstall_stamp"
221 # clang wasn't needed, not doing anything.
227 # Check if there's anything to be done, exit early if not.
228 if [[ -f "${STAMP_FILE}" ]]; then
229 PREVIOUSLY_BUILT_REVISON
=$
(cat "${STAMP_FILE}")
230 if [[ -z "$force_local_build" ]] && \
231 [[ "${PREVIOUSLY_BUILT_REVISON}" = \
232 "${PACKAGE_VERSION}" ]]; then
233 echo "Clang already at ${PACKAGE_VERSION}"
237 # To always force a new build if someone interrupts their build half way.
238 rm -f "${STAMP_FILE}"
241 if [[ -z "$force_local_build" ]]; then
242 # Check if there's a prebuilt binary and if so just fetch that. That's faster,
243 # and goma relies on having matching binary hashes on client and server too.
244 CDS_FILE
="clang-${PACKAGE_VERSION}.tgz"
245 CDS_OUT_DIR
=$
(mktemp
-d -t clang_download.XXXXXX
)
246 CDS_OUTPUT
="${CDS_OUT_DIR}/${CDS_FILE}"
247 if [ "${OS}" = "Linux" ]; then
248 CDS_FULL_URL
="${CDS_URL}/Linux_x64/${CDS_FILE}"
249 elif [ "${OS}" = "Darwin" ]; then
250 CDS_FULL_URL
="${CDS_URL}/Mac/${CDS_FILE}"
252 echo Trying to download prebuilt clang
253 if which curl
> /dev
/null
; then
254 curl
-L --fail "${CDS_FULL_URL}" -o "${CDS_OUTPUT}" || \
255 rm -rf "${CDS_OUT_DIR}"
256 elif which wget
> /dev
/null
; then
257 wget
"${CDS_FULL_URL}" -O "${CDS_OUTPUT}" || rm -rf "${CDS_OUT_DIR}"
259 echo "Neither curl nor wget found. Please install one of these."
262 if [ -f "${CDS_OUTPUT}" ]; then
263 rm -rf "${LLVM_BUILD_DIR}"
264 mkdir
-p "${LLVM_BUILD_DIR}"
265 tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}"
266 echo clang
"${PACKAGE_VERSION}" unpacked
267 echo "${PACKAGE_VERSION}" > "${STAMP_FILE}"
268 rm -rf "${CDS_OUT_DIR}"
271 echo Did not
find prebuilt clang
"${PACKAGE_VERSION}", building
275 if [[ -n "${with_android}" ]] && ! [[ -d "${ANDROID_NDK_DIR}" ]]; then
276 echo "Android NDK not found at ${ANDROID_NDK_DIR}"
277 echo "The Android NDK is needed to build a Clang whose -fsanitize=address"
278 echo "works on Android. See "
279 echo "http://code.google.com/p/chromium/wiki/AndroidBuildInstructions for how"
280 echo "to install the NDK, or pass --without-android."
284 # Check that cmake and ninja are available.
285 if ! which cmake
> /dev
/null
; then
286 echo "CMake needed to build clang; please install"
289 if ! which ninja
> /dev
/null
; then
290 echo "ninja needed to build clang, please install"
294 echo Reverting previously patched files
296 "${CLANG_DIR}/test/Index/crash-recovery-modules.m" \
297 "${CLANG_DIR}/unittests/libclang/LibclangTest.cpp" \
298 "${COMPILER_RT_DIR}/lib/asan/asan_rtl.cc" \
299 "${COMPILER_RT_DIR}/test/asan/TestCases/Linux/new_array_cookie_test.cc" \
300 "${LLVM_DIR}/test/DebugInfo/gmlt.ll" \
301 "${LLVM_DIR}/lib/CodeGen/SpillPlacement.cpp" \
302 "${LLVM_DIR}/lib/CodeGen/SpillPlacement.h" \
303 "${LLVM_DIR}/lib/Transforms/Instrumentation/MemorySanitizer.cpp" \
304 "${CLANG_DIR}/test/Driver/env.c" \
305 "${CLANG_DIR}/lib/Frontend/InitPreprocessor.cpp" \
306 "${CLANG_DIR}/test/Frontend/exceptions.c" \
307 "${CLANG_DIR}/test/Preprocessor/predefined-exceptions.m" \
308 "${LLVM_DIR}/test/Bindings/Go/go.test" \
309 "${CLANG_DIR}/lib/Parse/ParseExpr.cpp" \
310 "${CLANG_DIR}/lib/Parse/ParseTemplate.cpp" \
311 "${CLANG_DIR}/lib/Sema/SemaDeclCXX.cpp" \
312 "${CLANG_DIR}/lib/Sema/SemaExprCXX.cpp" \
313 "${CLANG_DIR}/test/SemaCXX/default2.cpp" \
314 "${CLANG_DIR}/test/SemaCXX/typo-correction-delayed.cpp" \
315 "${COMPILER_RT_DIR}/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc" \
316 "${COMPILER_RT_DIR}/test/tsan/signal_segv_handler.cc" \
317 "${COMPILER_RT_DIR}/lib/sanitizer_common/sanitizer_coverage_libcdep.cc" \
319 if [[ -e "${i}" ]]; then
320 rm -f "${i}" # For unversioned files.
325 echo Remove the Clang tools shim dir
326 CHROME_TOOLS_SHIM_DIR
=${ABS_LLVM_DIR}/tools
/chrometools
327 rm -rfv ${CHROME_TOOLS_SHIM_DIR}
329 echo Getting LLVM r
"${CLANG_REVISION}" in "${LLVM_DIR}"
330 if ! svn co
--force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \
332 echo Checkout failed
, retrying
334 svn co
--force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}"
337 echo Getting clang r
"${CLANG_REVISION}" in "${CLANG_DIR}"
338 svn co
--force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}"
340 # We have moved from building compiler-rt in the LLVM tree, to a separate
341 # directory. Nuke any previous checkout to avoid building it.
342 rm -rf "${LLVM_DIR}/projects/compiler-rt"
344 echo Getting compiler-rt r
"${CLANG_REVISION}" in "${COMPILER_RT_DIR}"
345 svn co
--force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \
348 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes
349 # (i.e. this is needed for bootstrap builds).
350 if [ "${OS}" = "Darwin" ]; then
351 echo Getting libc
++ r
"${CLANG_REVISION}" in "${LIBCXX_DIR}"
352 svn co
--force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \
356 # While we're bundling our own libc++ on OS X, we need to compile libc++abi
357 # into it too (since OS X 10.6 doesn't have libc++abi.dylib either).
358 if [ "${OS}" = "Darwin" ]; then
359 echo Getting libc
++abi r
"${CLANG_REVISION}" in "${LIBCXXABI_DIR}"
360 svn co
--force "${LLVM_REPO_URL}/libcxxabi/trunk@${CLANG_REVISION}" \
364 if [[ -n "$with_patches" ]]; then
366 # Apply patch for tests failing with --disable-pthreads (llvm.org/PR11974)
369 --- third_party
/llvm
/tools
/clang
/test
/Index
/crash-recovery-modules.m
(revision
202554)
370 +++ third_party
/llvm
/tools
/clang
/test
/Index
/crash-recovery-modules.m
(working copy
)
373 // REQUIRES
: crash-recovery
385 --- unittests
/libclang
/LibclangTest.cpp
(revision
215949)
386 +++ unittests
/libclang
/LibclangTest.cpp
(working copy
)
388 EXPECT_EQ
(0U, clang_getNumDiagnostics
(ClangTU
));
391 -TEST_F(LibclangReparseTest
, ReparseWithModule
) {
392 +TEST_F
(LibclangReparseTest
, DISABLED_ReparseWithModule
) {
393 const char
*HeaderTop
= "#ifndef H\n#define H\nstruct Foo { int bar;";
394 const char
*HeaderBottom
= "\n};\n#endif\n";
395 const char
*MFile
= "#include \"HeaderFile.h\"\nint main() {"
400 # Cherry-pick r234010 [sancov] Shrink pc array on Android back to 2**24."
401 pushd "${COMPILER_RT_DIR}"
403 diff --git a
/lib
/sanitizer_common
/sanitizer_coverage_libcdep.cc b
/lib
/sanitizer_common
/sanitizer_coverage_libcdep.cc
404 index
4b976fc..cfd9e7e
100644
405 --- a
/lib
/sanitizer_common
/sanitizer_coverage_libcdep.cc
406 +++ b
/lib
/sanitizer_common
/sanitizer_coverage_libcdep.cc
407 @@
-109,7 +109,8 @@ class CoverageData
{
409 // Maximal size pc array may ever grow.
410 // We MmapNoReserve this space to ensure that the array is contiguous.
411 - static const uptr kPcArrayMaxSize
= FIRST_32_SECOND_64
(1 << 26, 1 << 27);
412 + static const uptr kPcArrayMaxSize =
413 + FIRST_32_SECOND_64(1 << (SANITIZER_ANDROID ? 24 : 26), 1 << 27);
414 // The amount file mapping for the pc array is grown by.
415 static const uptr kPcArrayMmapSize = 64 * 1024;
421 # This Go bindings test doesn't work after the bootstrap build on Linux. (PR21552)
424 Index: test/Bindings/Go/go.test
425 ===================================================================
426 --- test/Bindings/Go/go.test (revision 223109)
427 +++ test/Bindings/Go/go.test (working copy)
429 -; RUN: llvm-go test llvm.org/llvm/bindings/go/llvm
443 # Set default values for CC and CXX if they're not set in the environment.
447 if [[ -n "${gcc_toolchain}" ]]; then
448 # Use the specified gcc installation for building.
449 CC="$gcc_toolchain/bin/gcc"
450 CXX="$gcc_toolchain/bin/g++"
451 # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap compiler,
452 # etc.) find the .so.
453 export LD_LIBRARY_PATH="$(dirname $(${CXX} -print-file-name=libstdc++.so.6))"
460 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
461 # needed, on OS X it requires libc++. clang only automatically links to libc++
462 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on
463 # OS X versions as old as 10.7.
464 # TODO(thakis): Some bots are still on 10.6, so for now bundle libc++.dylib.
465 # Remove this once all bots are on 10.7+, then use --enable-libcpp=yes and
466 # change deployment_target to 10.7.
469 if [ "${OS}" = "Darwin" ]; then
470 # When building on 10.9, /usr/include usually doesn't exist, and while
471 # Xcode's clang automatically sets a sysroot, self-built clangs don't.
472 CFLAGS="-isysroot $(xcrun --show-sdk-path)"
474 CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLAGS}"
476 if [[ -n "${bootstrap}" ]]; then
477 deployment_target=10.6
481 # Build bootstrap clang if requested.
482 if [[ -n "${bootstrap}" ]]; then
483 ABS_INSTALL_DIR="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}"
484 echo "Building bootstrap compiler"
485 mkdir -p "${LLVM_BOOTSTRAP_DIR}"
486 pushd "${LLVM_BOOTSTRAP_DIR}"
489 -DCMAKE_BUILD_TYPE=Release \
490 -DLLVM_ENABLE_ASSERTIONS=ON \
491 -DLLVM_TARGETS_TO_BUILD=host \
492 -DLLVM_ENABLE_THREADS=OFF \
493 -DCMAKE_INSTALL_PREFIX="${ABS_INSTALL_DIR}" \
494 -DCMAKE_C_COMPILER="${CC}" \
495 -DCMAKE_CXX_COMPILER="${CXX}" \
496 -DCMAKE_C_FLAGS="${CFLAGS}" \
497 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
501 if [[ -n "${run_tests}" ]]; then
506 if [[ -n "${gcc_toolchain}" ]]; then
507 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap
508 # compiler can start.
509 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \
510 "${ABS_INSTALL_DIR}/lib/"
514 CC="${ABS_INSTALL_DIR}/bin/clang"
515 CXX="${ABS_INSTALL_DIR}/bin/clang++"
517 if [[ -n "${gcc_toolchain}" ]]; then
518 # Tell the bootstrap compiler to use a specific gcc prefix to search
519 # for standard library headers and shared object file.
520 CFLAGS="--gcc-toolchain=${gcc_toolchain}"
521 CXXFLAGS="--gcc-toolchain=${gcc_toolchain}"
524 echo "Building final compiler"
527 # Build clang (in a separate directory).
528 # The clang bots have this path hardcoded in built/scripts/slave/compile.py,
529 # so if you change it you also need to change these links.
530 mkdir -p "${LLVM_BUILD_DIR}"
531 pushd "${LLVM_BUILD_DIR}"
533 # Build libc++.dylib while some bots are still on OS X 10.6.
534 if [ "${OS}" = "Darwin" ]; then
536 LIBCXXFLAGS="-O3 -std=c++11 -fstrict-aliasing"
538 # libcxx and libcxxabi both have a file stdexcept.cpp, so put their .o files
539 # into different subdirectories.
540 mkdir -p libcxxbuild/libcxx
541 pushd libcxxbuild/libcxx
542 ${CXX:-c++} -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXX_DIR}"/src/*.cpp
545 mkdir -p libcxxbuild/libcxxabi
546 pushd libcxxbuild/libcxxabi
547 ${CXX:-c++} -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXXABI_DIR}"/src/*.cpp -I"${ABS_LIBCXXABI_DIR}/include"
551 ${CC:-cc} libcxx/*.o libcxxabi/*.o -o libc++.1.dylib -dynamiclib \
552 -nodefaultlibs -current_version 1 -compatibility_version 1 \
553 -lSystem -install_name @executable_path/libc++.dylib \
554 -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib/libc++unexp.exp \
555 -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib/notweak.exp \
556 -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib/weak.exp
557 ln -sf libc++.1.dylib libc++.dylib
559 LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild"
562 # Find the binutils include dir for the gold plugin.
564 if [ "${OS}" = "Linux" ]; then
565 BINUTILS_INCDIR="${ABS_BINUTILS_DIR}/Linux_x64/Release/include"
569 # If building at head, define a macro that plugins can use for #ifdefing
570 # out code that builds at head, but not at CLANG_REVISION or vice versa.
571 if [[ -n ${LLVM_FORCE_HEAD_REVISION:-''} ]]; then
572 CFLAGS="${CFLAGS} -DLLVM_FORCE_HEAD_REVISION"
573 CXXFLAGS="${CXXFLAGS} -DLLVM_FORCE_HEAD_REVISION"
576 # Hook the Chromium tools into the LLVM build. Several Chromium tools have
577 # dependencies on LLVM/Clang libraries. The LLVM build detects implicit tools
578 # in the tools subdirectory, so install a shim CMakeLists.txt that forwards to
579 # the real directory for the Chromium tools.
580 # Note that the shim directory name intentionally has no _ or _. The implicit
581 # tool detection logic munges them in a weird way.
582 mkdir -v ${CHROME_TOOLS_SHIM_DIR}
583 cat > ${CHROME_TOOLS_SHIM_DIR}/CMakeLists.txt << EOF
584 # Since tools/clang isn't actually a subdirectory, use the two argument version
585 # to specify where build artifacts go. CMake doesn't allow reusing the same
586 # binary dir for multiple source dirs, so the build artifacts have to go into a
588 add_subdirectory(\${CHROMIUM_TOOLS_SRC} \${CMAKE_CURRENT_BINARY_DIR}/a)
590 rm -fv CMakeCache.txt
591 MACOSX_DEPLOYMENT_TARGET=${deployment_target} cmake -GNinja \
592 -DCMAKE_BUILD_TYPE=Release \
593 -DLLVM_ENABLE_ASSERTIONS=ON \
594 -DLLVM_ENABLE_THREADS=OFF \
595 -DLLVM_BINUTILS_INCDIR="${BINUTILS_INCDIR}" \
596 -DCMAKE_C_COMPILER="${CC}" \
597 -DCMAKE_CXX_COMPILER="${CXX}" \
598 -DCMAKE_C_FLAGS="${CFLAGS}" \
599 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
600 -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
601 -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
602 -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" \
603 -DCMAKE_INSTALL_PREFIX="${ABS_LLVM_BUILD_DIR}" \
604 -DCHROMIUM_TOOLS_SRC="${ABS_CHROMIUM_TOOLS_DIR}" \
605 -DCHROMIUM_TOOLS="${chrome_tools}" \
609 if [[ -n "${gcc_toolchain}" ]]; then
610 # Copy in the right stdlibc++.so.6 so clang can start.
612 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" lib/
616 # If any Chromium tools were built, install those now.
617 if [[ -n "${chrome_tools}" ]]; then
622 if [ "${OS}" = "Darwin" ]; then
623 # See http://crbug.com/256342
626 cp libcxxbuild/libc++.1.dylib bin/
628 strip ${STRIP_FLAGS} bin/clang
631 # Build compiler-rt out-of-tree.
632 mkdir -p "${COMPILER_RT_BUILD_DIR}"
633 pushd "${COMPILER_RT_BUILD_DIR}"
635 rm -fv CMakeCache.txt
636 MACOSX_DEPLOYMENT_TARGET=${deployment_target} cmake -GNinja \
637 -DCMAKE_BUILD_TYPE=Release \
638 -DLLVM_ENABLE_ASSERTIONS=ON \
639 -DLLVM_ENABLE_THREADS=OFF \
640 -DCMAKE_C_COMPILER="${CC}" \
641 -DCMAKE_CXX_COMPILER="${CXX}" \
642 -DLLVM_CONFIG_PATH="${ABS_LLVM_BUILD_DIR}/bin/llvm-config" \
643 "${ABS_COMPILER_RT_DIR}"
647 # Copy selected output to the main tree.
648 # Darwin doesn't support cp --parents, so pipe through tar instead.
649 CLANG_VERSION=$("${ABS_LLVM_BUILD_DIR}/bin/clang" --version | \
650 sed -ne 's/clang version \([0-9]\.[0-9]\.[0-9]\).*/\1/p')
651 ABS_LLVM_CLANG_LIB_DIR="${ABS_LLVM_BUILD_DIR}/lib/clang/${CLANG_VERSION}"
652 tar -c *blacklist.txt | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
653 tar -c include/sanitizer | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
654 if [[ "${OS}" = "Darwin" ]]; then
655 tar -c lib/darwin | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
657 tar -c lib/linux | tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
662 if [[ -n "${with_android}" ]]; then
663 # Make a standalone Android toolchain.
664 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \
665 --platform=android-14 \
666 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \
667 --system=linux-x86_64 \
669 --toolchain=arm-linux-androideabi-4.9
671 # Android NDK r9d copies a broken unwind.h into the toolchain, see
672 # http://crbug.com/357890
673 rm -v "${LLVM_BUILD_DIR}"/android-toolchain/include/c++/*/unwind.h
675 # Build ASan runtime for Android in a separate build tree.
676 mkdir -p ${LLVM_BUILD_DIR}/android
677 pushd ${LLVM_BUILD_DIR}/android
678 rm -fv CMakeCache.txt
679 MACOSX_DEPLOYMENT_TARGET=${deployment_target} cmake -GNinja \
680 -DCMAKE_BUILD_TYPE=Release \
681 -DLLVM_ENABLE_ASSERTIONS=ON \
682 -DLLVM_ENABLE_THREADS=OFF \
683 -DCMAKE_C_COMPILER=${PWD}/../bin/clang \
684 -DCMAKE_CXX_COMPILER=${PWD}/../bin/clang++ \
685 -DLLVM_CONFIG_PATH=${PWD}/../bin/llvm-config \
686 -DCMAKE_C_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../android-toolchain/sysroot -B${PWD}/../android-toolchain" \
687 -DCMAKE_CXX_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../android-toolchain/sysroot -B${PWD}/../android-toolchain" \
689 "${ABS_COMPILER_RT_DIR}"
690 ninja libclang_rt.asan-arm-android.so
692 # And copy it into the main build tree.
693 cp "$(find -name libclang_rt.asan-arm-android.so)" "${ABS_LLVM_CLANG_LIB_DIR}/lib/linux/"
697 if [[ -n "$run_tests" ]]; then
698 # Run Chrome tool tests.
699 ninja -C "${LLVM_BUILD_DIR}" cr-check-all
700 # Run the LLVM and Clang tests.
701 ninja -C "${LLVM_BUILD_DIR}" check-all
704 # After everything is done, log success for this revision.
705 echo "${PACKAGE_VERSION}" > "${STAMP_FILE}"