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" \
318 if [[ -e "${i}" ]]; then
319 rm -f "${i}" # For unversioned files.
324 echo Remove the Clang tools shim dir
325 CHROME_TOOLS_SHIM_DIR
=${ABS_LLVM_DIR}/tools
/chrometools
326 rm -rfv ${CHROME_TOOLS_SHIM_DIR}
328 echo Getting LLVM r
"${CLANG_REVISION}" in "${LLVM_DIR}"
329 if ! svn co
--force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \
331 echo Checkout failed
, retrying
333 svn co
--force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}"
336 echo Getting clang r
"${CLANG_REVISION}" in "${CLANG_DIR}"
337 svn co
--force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}"
339 # We have moved from building compiler-rt in the LLVM tree, to a separate
340 # directory. Nuke any previous checkout to avoid building it.
341 rm -rf "${LLVM_DIR}/projects/compiler-rt"
343 echo Getting compiler-rt r
"${CLANG_REVISION}" in "${COMPILER_RT_DIR}"
344 svn co
--force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \
347 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes
348 # (i.e. this is needed for bootstrap builds).
349 if [ "${OS}" = "Darwin" ]; then
350 echo Getting libc
++ r
"${CLANG_REVISION}" in "${LIBCXX_DIR}"
351 svn co
--force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \
355 # While we're bundling our own libc++ on OS X, we need to compile libc++abi
356 # into it too (since OS X 10.6 doesn't have libc++abi.dylib either).
357 if [ "${OS}" = "Darwin" ]; then
358 echo Getting libc
++abi r
"${CLANG_REVISION}" in "${LIBCXXABI_DIR}"
359 svn co
--force "${LLVM_REPO_URL}/libcxxabi/trunk@${CLANG_REVISION}" \
363 if [[ -n "$with_patches" ]]; then
365 # Apply patch for tests failing with --disable-pthreads (llvm.org/PR11974)
368 --- third_party
/llvm
/tools
/clang
/test
/Index
/crash-recovery-modules.m
(revision
202554)
369 +++ third_party
/llvm
/tools
/clang
/test
/Index
/crash-recovery-modules.m
(working copy
)
372 // REQUIRES
: crash-recovery
384 --- unittests
/libclang
/LibclangTest.cpp
(revision
215949)
385 +++ unittests
/libclang
/LibclangTest.cpp
(working copy
)
387 EXPECT_EQ
(0U, clang_getNumDiagnostics
(ClangTU
));
390 -TEST_F(LibclangReparseTest
, ReparseWithModule
) {
391 +TEST_F
(LibclangReparseTest
, DISABLED_ReparseWithModule
) {
392 const char
*HeaderTop
= "#ifndef H\n#define H\nstruct Foo { int bar;";
393 const char
*HeaderBottom
= "\n};\n#endif\n";
394 const char
*MFile
= "#include \"HeaderFile.h\"\nint main() {"
399 # This Go bindings test doesn't work after the bootstrap build on Linux. (PR21552)
402 Index
: test
/Bindings
/Go
/go.
test
403 ===================================================================
404 --- test
/Bindings
/Go
/go.
test (revision
223109)
405 +++ test
/Bindings
/Go
/go.
test (working copy
)
407 -; RUN
: llvm-go
test llvm.org
/llvm
/bindings
/go
/llvm
421 # Set default values for CC and CXX if they're not set in the environment.
425 if [[ -n "${gcc_toolchain}" ]]; then
426 # Use the specified gcc installation for building.
427 CC
="$gcc_toolchain/bin/gcc"
428 CXX
="$gcc_toolchain/bin/g++"
429 # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap compiler,
430 # etc.) find the .so.
431 export LD_LIBRARY_PATH
="$(dirname $(${CXX} -print-file-name=libstdc++.so.6))"
438 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
439 # needed, on OS X it requires libc++. clang only automatically links to libc++
440 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on
441 # OS X versions as old as 10.7.
442 # TODO(thakis): Some bots are still on 10.6, so for now bundle libc++.dylib.
443 # Remove this once all bots are on 10.7+, then use --enable-libcpp=yes and
444 # change deployment_target to 10.7.
447 if [ "${OS}" = "Darwin" ]; then
448 # When building on 10.9, /usr/include usually doesn't exist, and while
449 # Xcode's clang automatically sets a sysroot, self-built clangs don't.
450 CFLAGS
="-isysroot $(xcrun --show-sdk-path)"
452 CXXFLAGS
="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLAGS}"
454 if [[ -n "${bootstrap}" ]]; then
455 deployment_target
=10.6
459 # Build bootstrap clang if requested.
460 if [[ -n "${bootstrap}" ]]; then
461 ABS_INSTALL_DIR
="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}"
462 echo "Building bootstrap compiler"
463 mkdir
-p "${LLVM_BOOTSTRAP_DIR}"
464 pushd "${LLVM_BOOTSTRAP_DIR}"
467 -DCMAKE_BUILD_TYPE=Release \
468 -DLLVM_ENABLE_ASSERTIONS=ON \
469 -DLLVM_TARGETS_TO_BUILD=host \
470 -DLLVM_ENABLE_THREADS=OFF \
471 -DCMAKE_INSTALL_PREFIX="${ABS_INSTALL_DIR}" \
472 -DCMAKE_C_COMPILER="${CC}" \
473 -DCMAKE_CXX_COMPILER="${CXX}" \
474 -DCMAKE_C_FLAGS="${CFLAGS}" \
475 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
479 if [[ -n "${run_tests}" ]]; then
484 if [[ -n "${gcc_toolchain}" ]]; then
485 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap
486 # compiler can start.
487 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \
488 "${ABS_INSTALL_DIR}/lib/"
492 CC
="${ABS_INSTALL_DIR}/bin/clang"
493 CXX
="${ABS_INSTALL_DIR}/bin/clang++"
495 if [[ -n "${gcc_toolchain}" ]]; then
496 # Tell the bootstrap compiler to use a specific gcc prefix to search
497 # for standard library headers and shared object file.
498 CFLAGS
="--gcc-toolchain=${gcc_toolchain}"
499 CXXFLAGS
="--gcc-toolchain=${gcc_toolchain}"
502 echo "Building final compiler"
505 # Build clang (in a separate directory).
506 # The clang bots have this path hardcoded in built/scripts/slave/compile.py,
507 # so if you change it you also need to change these links.
508 mkdir
-p "${LLVM_BUILD_DIR}"
509 pushd "${LLVM_BUILD_DIR}"
511 # Build libc++.dylib while some bots are still on OS X 10.6.
512 if [ "${OS}" = "Darwin" ]; then
514 LIBCXXFLAGS
="-O3 -std=c++11 -fstrict-aliasing"
516 # libcxx and libcxxabi both have a file stdexcept.cpp, so put their .o files
517 # into different subdirectories.
518 mkdir
-p libcxxbuild
/libcxx
519 pushd libcxxbuild
/libcxx
520 ${CXX:-c++} -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXX_DIR}"/src/*.cpp
523 mkdir -p libcxxbuild/libcxxabi
524 pushd libcxxbuild/libcxxabi
525 ${CXX:-c++} -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXXABI_DIR}"/src/*.cpp -I"${ABS_LIBCXXABI_DIR}/include"
529 ${CC:-cc} libcxx
/*.o libcxxabi
/*.o
-o libc
++.1.dylib
-dynamiclib \
530 -nodefaultlibs -current_version 1 -compatibility_version 1 \
531 -lSystem -install_name @executable_path
/libc
++.dylib \
532 -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib
/libc
++unexp.exp \
533 -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib
/notweak.exp \
534 -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib
/weak.exp
535 ln -sf libc
++.1.dylib libc
++.dylib
537 LDFLAGS
+="-stdlib=libc++ -L${PWD}/libcxxbuild"
540 # Find the binutils include dir for the gold plugin.
542 if [ "${OS}" = "Linux" ]; then
543 BINUTILS_INCDIR
="${ABS_BINUTILS_DIR}/Linux_x64/Release/include"
546 # Hook the Chromium tools into the LLVM build. Several Chromium tools have
547 # dependencies on LLVM/Clang libraries. The LLVM build detects implicit tools
548 # in the tools subdirectory, so install a shim CMakeLists.txt that forwards to
549 # the real directory for the Chromium tools.
550 # Note that the shim directory name intentionally has no _ or _. The implicit
551 # tool detection logic munges them in a weird way.
552 mkdir
-v ${CHROME_TOOLS_SHIM_DIR}
553 cat > ${CHROME_TOOLS_SHIM_DIR}/CMakeLists.txt
<< EOF
554 # Since tools/clang isn't actually a subdirectory, use the two argument version
555 # to specify where build artifacts go. CMake doesn't allow reusing the same
556 # binary dir for multiple source dirs, so the build artifacts have to go into a
558 add_subdirectory(\${CHROMIUM_TOOLS_SRC} \${CMAKE_CURRENT_BINARY_DIR}/a)
560 rm -fv CMakeCache.txt
561 MACOSX_DEPLOYMENT_TARGET
=${deployment_target} cmake
-GNinja \
562 -DCMAKE_BUILD_TYPE=Release \
563 -DLLVM_ENABLE_ASSERTIONS=ON \
564 -DLLVM_ENABLE_THREADS=OFF \
565 -DLLVM_BINUTILS_INCDIR="${BINUTILS_INCDIR}" \
566 -DCMAKE_C_COMPILER="${CC}" \
567 -DCMAKE_CXX_COMPILER="${CXX}" \
568 -DCMAKE_C_FLAGS="${CFLAGS}" \
569 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
570 -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
571 -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
572 -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" \
573 -DCMAKE_INSTALL_PREFIX="${ABS_LLVM_BUILD_DIR}" \
574 -DCHROMIUM_TOOLS_SRC="${ABS_CHROMIUM_TOOLS_DIR}" \
575 -DCHROMIUM_TOOLS="${chrome_tools}" \
579 if [[ -n "${gcc_toolchain}" ]]; then
580 # Copy in the right stdlibc++.so.6 so clang can start.
582 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" lib
/
586 # If any Chromium tools were built, install those now.
587 if [[ -n "${chrome_tools}" ]]; then
592 if [ "${OS}" = "Darwin" ]; then
593 # See http://crbug.com/256342
596 cp libcxxbuild
/libc
++.1.dylib bin
/
598 strip
${STRIP_FLAGS} bin
/clang
601 # Build compiler-rt out-of-tree.
602 mkdir
-p "${COMPILER_RT_BUILD_DIR}"
603 pushd "${COMPILER_RT_BUILD_DIR}"
605 rm -fv CMakeCache.txt
606 MACOSX_DEPLOYMENT_TARGET
=${deployment_target} cmake
-GNinja \
607 -DCMAKE_BUILD_TYPE=Release \
608 -DLLVM_ENABLE_ASSERTIONS=ON \
609 -DLLVM_ENABLE_THREADS=OFF \
610 -DCMAKE_C_COMPILER="${CC}" \
611 -DCMAKE_CXX_COMPILER="${CXX}" \
612 -DLLVM_CONFIG_PATH="${ABS_LLVM_BUILD_DIR}/bin/llvm-config" \
613 "${ABS_COMPILER_RT_DIR}"
617 # Copy selected output to the main tree.
618 # Darwin doesn't support cp --parents, so pipe through tar instead.
619 CLANG_VERSION
=$
("${ABS_LLVM_BUILD_DIR}/bin/clang" --version | \
620 sed -ne 's/clang version \([0-9]\.[0-9]\.[0-9]\).*/\1/p')
621 ABS_LLVM_CLANG_LIB_DIR
="${ABS_LLVM_BUILD_DIR}/lib/clang/${CLANG_VERSION}"
622 tar -c *blacklist.txt |
tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
623 tar -c include
/sanitizer |
tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
624 if [[ "${OS}" = "Darwin" ]]; then
625 tar -c lib
/darwin |
tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
627 tar -c lib
/linux |
tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
632 if [[ -n "${with_android}" ]]; then
633 # Make a standalone Android toolchain.
634 ${ANDROID_NDK_DIR}/build
/tools
/make-standalone-toolchain.sh \
635 --platform=android-14 \
636 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \
637 --system=linux-x86_64 \
639 --toolchain=arm-linux-androideabi-4.9
641 # Android NDK r9d copies a broken unwind.h into the toolchain, see
642 # http://crbug.com/357890
643 rm -v "${LLVM_BUILD_DIR}"/android-toolchain
/include
/c
++/*/unwind.h
645 # Build ASan runtime for Android in a separate build tree.
646 mkdir
-p ${LLVM_BUILD_DIR}/android
647 pushd ${LLVM_BUILD_DIR}/android
648 rm -fv CMakeCache.txt
649 MACOSX_DEPLOYMENT_TARGET
=${deployment_target} cmake
-GNinja \
650 -DCMAKE_BUILD_TYPE=Release \
651 -DLLVM_ENABLE_ASSERTIONS=ON \
652 -DLLVM_ENABLE_THREADS=OFF \
653 -DCMAKE_C_COMPILER=${PWD}/..
/bin
/clang \
654 -DCMAKE_CXX_COMPILER=${PWD}/..
/bin
/clang
++ \
655 -DLLVM_CONFIG_PATH=${PWD}/..
/bin
/llvm-config \
656 -DCMAKE_C_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../android-toolchain/sysroot -B${PWD}/../android-toolchain" \
657 -DCMAKE_CXX_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../android-toolchain/sysroot -B${PWD}/../android-toolchain" \
659 "${ABS_COMPILER_RT_DIR}"
660 ninja libclang_rt.asan-arm-android.so
662 # And copy it into the main build tree.
663 cp "$(find -name libclang_rt.asan-arm-android.so)" "${ABS_LLVM_CLANG_LIB_DIR}/lib/linux/"
667 if [[ -n "$run_tests" ]]; then
668 # Run Chrome tool tests.
669 ninja
-C "${LLVM_BUILD_DIR}" cr-check-all
670 # Run the LLVM and Clang tests.
671 ninja
-C "${LLVM_BUILD_DIR}" check-all
674 # After everything is done, log success for this revision.
675 echo "${PACKAGE_VERSION}" > "${STAMP_FILE}"