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"
66 # Use both the clang revision and the plugin revisions to test for updates.
67 BLINKGCPLUGIN_REVISION
=\
68 $
(grep 'set(LIBRARYNAME' "$THIS_DIR"/..
/blink_gc_plugin
/CMakeLists.txt \
69 | cut
-d ' ' -f 2 |
tr -cd '[0-9]')
70 CLANG_AND_PLUGINS_REVISION
="${CLANG_REVISION}-${BLINKGCPLUGIN_REVISION}"
75 # Parse command line options.
81 chrome_tools
="plugins;blink_gc_plugin"
85 if [[ "${OS}" = "Darwin" ]]; then
89 while [[ $# > 0 ]]; do
101 echo $PACKAGE_VERSION
115 if [[ $# == 0 ]]; then
116 echo "--with-chrome-tools requires an argument."
123 if [[ $# == 0 ]]; then
124 echo "--gcc-toolchain requires an argument."
127 if [[ -x "$1/bin/gcc" ]]; then
130 echo "Invalid --gcc-toolchain: '$1'."
131 echo "'$1/bin/gcc' does not appear to be valid."
137 echo "usage: $0 [--force-local-build] [--if-needed] [--run-tests] "
138 echo "--bootstrap: First build clang with CC, then with itself."
139 echo "--force-local-build: Don't try to download prebuilt binaries."
140 echo "--if-needed: Download clang only if the script thinks it is needed."
141 echo "--run-tests: Run tests after building. Only for local builds."
142 echo "--print-revision: Print current clang revision and exit."
143 echo "--without-android: Don't build ASan Android runtime library."
144 echo "--with-chrome-tools: Select which chrome tools to build." \
145 "Defaults to plugins;blink_gc_plugin."
146 echo " Example: --with-chrome-tools plugins;empty-string"
147 echo "--gcc-toolchain: Set the prefix for which GCC version should"
148 echo " be used for building. For example, to use gcc in"
149 echo " /opt/foo/bin/gcc, use '--gcc-toolchain '/opt/foo"
150 echo "--without-patches: Don't apply local patches."
155 echo "Unknown argument: '$1'."
156 echo "Use --help for help."
163 if [[ -n ${LLVM_FORCE_HEAD_REVISION:-''} ]]; then
164 force_local_build
=yes
166 # Skip local patches when using HEAD: they probably don't apply anymore.
169 if ! [[ "$GYP_DEFINES" =~ .
*OS
=android.
* ]]; then
170 # Only build the Android ASan rt when targetting Android.
174 LLVM_BUILD_TOOLS_DIR
="${ABS_LLVM_DIR}/../llvm-build-tools"
176 if [[ "${OS}" == "Linux" ]] && [[ -z "${gcc_toolchain}" ]]; then
177 if [[ $
(gcc
-dumpversion) < "4.7.0" ]]; then
178 # We need a newer GCC version.
179 if [[ ! -e "${LLVM_BUILD_TOOLS_DIR}/gcc482" ]]; then
180 echo "Downloading pre-built GCC 4.8.2..."
181 mkdir
-p "${LLVM_BUILD_TOOLS_DIR}"
182 curl
--fail -L "${CDS_URL}/tools/gcc482.tgz" | \
183 tar zxf
- -C "${LLVM_BUILD_TOOLS_DIR}"
186 gcc_toolchain
="${LLVM_BUILD_TOOLS_DIR}/gcc482"
188 # Always set gcc_toolchain; llvm-symbolizer needs the bundled libstdc++.
189 gcc_toolchain
="$(dirname $(dirname $(which gcc)))"
193 if [[ "${OS}" == "Linux" ]]; then
194 # TODO(hans): Might need to make this work on Mac eventually.
195 if [[ $
(cmake
--version |
grep -Eo '[0-9.]+') < "3.0" ]]; then
196 # We need a newer CMake version.
197 if [[ ! -e "${LLVM_BUILD_TOOLS_DIR}/cmake310" ]]; then
198 echo "Downloading pre-built CMake 3.10..."
199 mkdir
-p "${LLVM_BUILD_TOOLS_DIR}"
200 curl
--fail -L "${CDS_URL}/tools/cmake310.tgz" | \
201 tar zxf
- -C "${LLVM_BUILD_TOOLS_DIR}"
204 export PATH
="${LLVM_BUILD_TOOLS_DIR}/cmake310/bin:${PATH}"
208 echo "LLVM_FORCE_HEAD_REVISION was set; using r${CLANG_REVISION}"
211 if [[ -n "$if_needed" ]]; then
212 if [[ "${OS}" == "Darwin" ]]; then
213 # clang is used on Mac.
215 elif [[ "$GYP_DEFINES" =~ .
*(clang|tsan|asan|lsan|msan
)=1.
* ]]; then
216 # clang requested via $GYP_DEFINES.
218 elif [[ -d "${LLVM_BUILD_DIR}" ]]; then
219 # clang previously downloaded, remove third_party/llvm-build to prevent
222 elif [[ "${OS}" == "Linux" ]]; then
223 # Temporarily use clang on linux. Leave a stamp file behind, so that
224 # this script can remove clang again on machines where it was autoinstalled.
225 mkdir
-p "${LLVM_BUILD_DIR}"
226 touch "${LLVM_BUILD_DIR}/autoinstall_stamp"
229 # clang wasn't needed, not doing anything.
235 # Check if there's anything to be done, exit early if not.
236 if [[ -f "${STAMP_FILE}" ]]; then
237 PREVIOUSLY_BUILT_REVISON
=$
(cat "${STAMP_FILE}")
238 if [[ -z "$force_local_build" ]] && \
239 [[ "${PREVIOUSLY_BUILT_REVISON}" = \
240 "${PACKAGE_VERSION}" ]]; then
241 echo "Clang already at ${PACKAGE_VERSION}"
245 # To always force a new build if someone interrupts their build half way.
246 rm -f "${STAMP_FILE}"
249 if [[ -z "$force_local_build" ]]; then
250 # Check if there's a prebuilt binary and if so just fetch that. That's faster,
251 # and goma relies on having matching binary hashes on client and server too.
252 CDS_FILE
="clang-${PACKAGE_VERSION}.tgz"
253 CDS_OUT_DIR
=$
(mktemp
-d -t clang_download.XXXXXX
)
254 CDS_OUTPUT
="${CDS_OUT_DIR}/${CDS_FILE}"
255 if [ "${OS}" = "Linux" ]; then
256 CDS_FULL_URL
="${CDS_URL}/Linux_x64/${CDS_FILE}"
257 elif [ "${OS}" = "Darwin" ]; then
258 CDS_FULL_URL
="${CDS_URL}/Mac/${CDS_FILE}"
260 echo Trying to download prebuilt clang
261 if which curl
> /dev
/null
; then
262 curl
-L --fail "${CDS_FULL_URL}" -o "${CDS_OUTPUT}" || \
263 rm -rf "${CDS_OUT_DIR}"
264 elif which wget
> /dev
/null
; then
265 wget
"${CDS_FULL_URL}" -O "${CDS_OUTPUT}" || rm -rf "${CDS_OUT_DIR}"
267 echo "Neither curl nor wget found. Please install one of these."
270 if [ -f "${CDS_OUTPUT}" ]; then
271 rm -rf "${LLVM_BUILD_DIR}"
272 mkdir
-p "${LLVM_BUILD_DIR}"
273 tar -xzf "${CDS_OUTPUT}" -C "${LLVM_BUILD_DIR}"
274 echo clang
"${PACKAGE_VERSION}" unpacked
275 echo "${PACKAGE_VERSION}" > "${STAMP_FILE}"
276 rm -rf "${CDS_OUT_DIR}"
279 echo Did not
find prebuilt clang
"${PACKAGE_VERSION}", building
283 if [[ -n "${with_android}" ]] && ! [[ -d "${ANDROID_NDK_DIR}" ]]; then
284 echo "Android NDK not found at ${ANDROID_NDK_DIR}"
285 echo "The Android NDK is needed to build a Clang whose -fsanitize=address"
286 echo "works on Android. See "
287 echo "http://code.google.com/p/chromium/wiki/AndroidBuildInstructions for how"
288 echo "to install the NDK, or pass --without-android."
292 # Check that cmake and ninja are available.
293 if ! which cmake
> /dev
/null
; then
294 echo "CMake needed to build clang; please install"
297 if ! which ninja
> /dev
/null
; then
298 echo "ninja needed to build clang, please install"
302 echo Reverting previously patched files
304 "${CLANG_DIR}/test/Index/crash-recovery-modules.m" \
305 "${CLANG_DIR}/unittests/libclang/LibclangTest.cpp" \
306 "${COMPILER_RT_DIR}/lib/asan/asan_rtl.cc" \
307 "${COMPILER_RT_DIR}/test/asan/TestCases/Linux/new_array_cookie_test.cc" \
308 "${LLVM_DIR}/test/DebugInfo/gmlt.ll" \
309 "${LLVM_DIR}/lib/CodeGen/SpillPlacement.cpp" \
310 "${LLVM_DIR}/lib/CodeGen/SpillPlacement.h" \
311 "${LLVM_DIR}/lib/Transforms/Instrumentation/MemorySanitizer.cpp" \
312 "${CLANG_DIR}/test/Driver/env.c" \
313 "${CLANG_DIR}/lib/Frontend/InitPreprocessor.cpp" \
314 "${CLANG_DIR}/test/Frontend/exceptions.c" \
315 "${CLANG_DIR}/test/Preprocessor/predefined-exceptions.m" \
316 "${LLVM_DIR}/test/Bindings/Go/go.test" \
317 "${CLANG_DIR}/lib/Parse/ParseExpr.cpp" \
318 "${CLANG_DIR}/lib/Parse/ParseTemplate.cpp" \
319 "${CLANG_DIR}/lib/Sema/SemaDeclCXX.cpp" \
320 "${CLANG_DIR}/lib/Sema/SemaExprCXX.cpp" \
321 "${CLANG_DIR}/test/SemaCXX/default2.cpp" \
322 "${CLANG_DIR}/test/SemaCXX/typo-correction-delayed.cpp" \
323 "${COMPILER_RT_DIR}/lib/sanitizer_common/sanitizer_stoptheworld_linux_libcdep.cc" \
324 "${COMPILER_RT_DIR}/test/tsan/signal_segv_handler.cc" \
326 if [[ -e "${i}" ]]; then
327 rm -f "${i}" # For unversioned files.
332 echo Remove the Clang tools shim dir
333 CHROME_TOOLS_SHIM_DIR
=${ABS_LLVM_DIR}/tools
/chrometools
334 rm -rfv ${CHROME_TOOLS_SHIM_DIR}
336 echo Getting LLVM r
"${CLANG_REVISION}" in "${LLVM_DIR}"
337 if ! svn co
--force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" \
339 echo Checkout failed
, retrying
341 svn co
--force "${LLVM_REPO_URL}/llvm/trunk@${CLANG_REVISION}" "${LLVM_DIR}"
344 echo Getting clang r
"${CLANG_REVISION}" in "${CLANG_DIR}"
345 svn co
--force "${LLVM_REPO_URL}/cfe/trunk@${CLANG_REVISION}" "${CLANG_DIR}"
347 # We have moved from building compiler-rt in the LLVM tree, to a separate
348 # directory. Nuke any previous checkout to avoid building it.
349 rm -rf "${LLVM_DIR}/projects/compiler-rt"
351 echo Getting compiler-rt r
"${CLANG_REVISION}" in "${COMPILER_RT_DIR}"
352 svn co
--force "${LLVM_REPO_URL}/compiler-rt/trunk@${CLANG_REVISION}" \
355 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes
356 # (i.e. this is needed for bootstrap builds).
357 if [ "${OS}" = "Darwin" ]; then
358 echo Getting libc
++ r
"${CLANG_REVISION}" in "${LIBCXX_DIR}"
359 svn co
--force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \
363 # While we're bundling our own libc++ on OS X, we need to compile libc++abi
364 # into it too (since OS X 10.6 doesn't have libc++abi.dylib either).
365 if [ "${OS}" = "Darwin" ]; then
366 echo Getting libc
++abi r
"${CLANG_REVISION}" in "${LIBCXXABI_DIR}"
367 svn co
--force "${LLVM_REPO_URL}/libcxxabi/trunk@${CLANG_REVISION}" \
371 if [[ -n "$with_patches" ]]; then
373 # Apply patch for tests failing with --disable-pthreads (llvm.org/PR11974)
376 --- third_party
/llvm
/tools
/clang
/test
/Index
/crash-recovery-modules.m
(revision
202554)
377 +++ third_party
/llvm
/tools
/clang
/test
/Index
/crash-recovery-modules.m
(working copy
)
380 // REQUIRES
: crash-recovery
392 --- unittests
/libclang
/LibclangTest.cpp
(revision
215949)
393 +++ unittests
/libclang
/LibclangTest.cpp
(working copy
)
395 EXPECT_EQ
(0U, clang_getNumDiagnostics
(ClangTU
));
398 -TEST_F(LibclangReparseTest
, ReparseWithModule
) {
399 +TEST_F
(LibclangReparseTest
, DISABLED_ReparseWithModule
) {
400 const char
*HeaderTop
= "#ifndef H\n#define H\nstruct Foo { int bar;";
401 const char
*HeaderBottom
= "\n};\n#endif\n";
402 const char
*MFile
= "#include \"HeaderFile.h\"\nint main() {"
407 # This Go bindings test doesn't work after the bootstrap build on Linux. (PR21552)
410 Index
: test
/Bindings
/Go
/go.
test
411 ===================================================================
412 --- test
/Bindings
/Go
/go.
test (revision
223109)
413 +++ test
/Bindings
/Go
/go.
test (working copy
)
415 -; RUN
: llvm-go
test llvm.org
/llvm
/bindings
/go
/llvm
429 # Set default values for CC and CXX if they're not set in the environment.
433 if [[ -n "${gcc_toolchain}" ]]; then
434 # Use the specified gcc installation for building.
435 CC
="$gcc_toolchain/bin/gcc"
436 CXX
="$gcc_toolchain/bin/g++"
437 # Set LD_LIBRARY_PATH to make auxiliary targets (tablegen, bootstrap compiler,
438 # etc.) find the .so.
439 export LD_LIBRARY_PATH
="$(dirname $(${CXX} -print-file-name=libstdc++.so.6))"
446 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is
447 # needed, on OS X it requires libc++. clang only automatically links to libc++
448 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on
449 # OS X versions as old as 10.7.
450 # TODO(thakis): Some bots are still on 10.6, so for now bundle libc++.dylib.
451 # Remove this once all bots are on 10.7+, then use --enable-libcpp=yes and
452 # change deployment_target to 10.7.
455 if [ "${OS}" = "Darwin" ]; then
456 # When building on 10.9, /usr/include usually doesn't exist, and while
457 # Xcode's clang automatically sets a sysroot, self-built clangs don't.
458 CFLAGS
="-isysroot $(xcrun --show-sdk-path)"
460 CXXFLAGS
="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLAGS}"
462 if [[ -n "${bootstrap}" ]]; then
463 deployment_target
=10.6
467 # Build bootstrap clang if requested.
468 if [[ -n "${bootstrap}" ]]; then
469 ABS_INSTALL_DIR
="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}"
470 echo "Building bootstrap compiler"
471 mkdir
-p "${LLVM_BOOTSTRAP_DIR}"
472 pushd "${LLVM_BOOTSTRAP_DIR}"
475 -DCMAKE_BUILD_TYPE=Release \
476 -DLLVM_ENABLE_ASSERTIONS=ON \
477 -DLLVM_TARGETS_TO_BUILD=host \
478 -DLLVM_ENABLE_THREADS=OFF \
479 -DCMAKE_INSTALL_PREFIX="${ABS_INSTALL_DIR}" \
480 -DCMAKE_C_COMPILER="${CC}" \
481 -DCMAKE_CXX_COMPILER="${CXX}" \
482 -DCMAKE_C_FLAGS="${CFLAGS}" \
483 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
487 if [[ -n "${run_tests}" ]]; then
492 if [[ -n "${gcc_toolchain}" ]]; then
493 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap
494 # compiler can start.
495 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \
496 "${ABS_INSTALL_DIR}/lib/"
500 CC
="${ABS_INSTALL_DIR}/bin/clang"
501 CXX
="${ABS_INSTALL_DIR}/bin/clang++"
503 if [[ -n "${gcc_toolchain}" ]]; then
504 # Tell the bootstrap compiler to use a specific gcc prefix to search
505 # for standard library headers and shared object file.
506 CFLAGS
="--gcc-toolchain=${gcc_toolchain}"
507 CXXFLAGS
="--gcc-toolchain=${gcc_toolchain}"
510 echo "Building final compiler"
513 # Build clang (in a separate directory).
514 # The clang bots have this path hardcoded in built/scripts/slave/compile.py,
515 # so if you change it you also need to change these links.
516 mkdir
-p "${LLVM_BUILD_DIR}"
517 pushd "${LLVM_BUILD_DIR}"
519 # Build libc++.dylib while some bots are still on OS X 10.6.
520 if [ "${OS}" = "Darwin" ]; then
522 LIBCXXFLAGS
="-O3 -std=c++11 -fstrict-aliasing"
524 # libcxx and libcxxabi both have a file stdexcept.cpp, so put their .o files
525 # into different subdirectories.
526 mkdir
-p libcxxbuild
/libcxx
527 pushd libcxxbuild
/libcxx
528 ${CXX:-c++} -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXX_DIR}"/src/*.cpp
531 mkdir -p libcxxbuild/libcxxabi
532 pushd libcxxbuild/libcxxabi
533 ${CXX:-c++} -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXXABI_DIR}"/src/*.cpp -I"${ABS_LIBCXXABI_DIR}/include"
537 ${CC:-cc} libcxx
/*.o libcxxabi
/*.o
-o libc
++.1.dylib
-dynamiclib \
538 -nodefaultlibs -current_version 1 -compatibility_version 1 \
539 -lSystem -install_name @executable_path
/libc
++.dylib \
540 -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib
/libc
++unexp.exp \
541 -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib
/notweak.exp \
542 -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib
/weak.exp
543 ln -sf libc
++.1.dylib libc
++.dylib
545 LDFLAGS
+="-stdlib=libc++ -L${PWD}/libcxxbuild"
548 # Find the binutils include dir for the gold plugin.
550 if [ "${OS}" = "Linux" ]; then
551 BINUTILS_INCDIR
="${ABS_BINUTILS_DIR}/Linux_x64/Release/include"
554 # Hook the Chromium tools into the LLVM build. Several Chromium tools have
555 # dependencies on LLVM/Clang libraries. The LLVM build detects implicit tools
556 # in the tools subdirectory, so install a shim CMakeLists.txt that forwards to
557 # the real directory for the Chromium tools.
558 # Note that the shim directory name intentionally has no _ or _. The implicit
559 # tool detection logic munges them in a weird way.
560 mkdir
-v ${CHROME_TOOLS_SHIM_DIR}
561 cat > ${CHROME_TOOLS_SHIM_DIR}/CMakeLists.txt
<< EOF
562 # Since tools/clang isn't actually a subdirectory, use the two argument version
563 # to specify where build artifacts go. CMake doesn't allow reusing the same
564 # binary dir for multiple source dirs, so the build artifacts have to go into a
566 add_subdirectory(\${CHROMIUM_TOOLS_SRC} \${CMAKE_CURRENT_BINARY_DIR}/a)
568 rm -fv CMakeCache.txt
569 MACOSX_DEPLOYMENT_TARGET
=${deployment_target} cmake
-GNinja \
570 -DCMAKE_BUILD_TYPE=Release \
571 -DLLVM_ENABLE_ASSERTIONS=ON \
572 -DLLVM_ENABLE_THREADS=OFF \
573 -DLLVM_BINUTILS_INCDIR="${BINUTILS_INCDIR}" \
574 -DCMAKE_C_COMPILER="${CC}" \
575 -DCMAKE_CXX_COMPILER="${CXX}" \
576 -DCMAKE_C_FLAGS="${CFLAGS}" \
577 -DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
578 -DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
579 -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
580 -DCMAKE_MODULE_LINKER_FLAGS="${LDFLAGS}" \
581 -DCMAKE_INSTALL_PREFIX="${ABS_LLVM_BUILD_DIR}" \
582 -DCHROMIUM_TOOLS_SRC="${ABS_CHROMIUM_TOOLS_DIR}" \
583 -DCHROMIUM_TOOLS="${chrome_tools}" \
587 if [[ -n "${gcc_toolchain}" ]]; then
588 # Copy in the right stdlibc++.so.6 so clang can start.
590 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" lib
/
594 # If any Chromium tools were built, install those now.
595 if [[ -n "${chrome_tools}" ]]; then
600 if [ "${OS}" = "Darwin" ]; then
601 # See http://crbug.com/256342
604 cp libcxxbuild
/libc
++.1.dylib bin
/
606 strip
${STRIP_FLAGS} bin
/clang
609 # Build compiler-rt out-of-tree.
610 mkdir
-p "${COMPILER_RT_BUILD_DIR}"
611 pushd "${COMPILER_RT_BUILD_DIR}"
613 rm -fv CMakeCache.txt
614 MACOSX_DEPLOYMENT_TARGET
=${deployment_target} cmake
-GNinja \
615 -DCMAKE_BUILD_TYPE=Release \
616 -DLLVM_ENABLE_ASSERTIONS=ON \
617 -DLLVM_ENABLE_THREADS=OFF \
618 -DCMAKE_C_COMPILER="${CC}" \
619 -DCMAKE_CXX_COMPILER="${CXX}" \
620 -DLLVM_CONFIG_PATH="${ABS_LLVM_BUILD_DIR}/bin/llvm-config" \
621 "${ABS_COMPILER_RT_DIR}"
625 # Copy selected output to the main tree.
626 # Darwin doesn't support cp --parents, so pipe through tar instead.
627 CLANG_VERSION
=$
("${ABS_LLVM_BUILD_DIR}/bin/clang" --version | \
628 sed -ne 's/clang version \([0-9]\.[0-9]\.[0-9]\).*/\1/p')
629 ABS_LLVM_CLANG_LIB_DIR
="${ABS_LLVM_BUILD_DIR}/lib/clang/${CLANG_VERSION}"
630 tar -c *blacklist.txt |
tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
631 tar -c include
/sanitizer |
tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
632 if [[ "${OS}" = "Darwin" ]]; then
633 tar -c lib
/darwin |
tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
635 tar -c lib
/linux |
tar -C ${ABS_LLVM_CLANG_LIB_DIR} -xv
640 if [[ -n "${with_android}" ]]; then
641 # Make a standalone Android toolchain.
642 ${ANDROID_NDK_DIR}/build
/tools
/make-standalone-toolchain.sh \
643 --platform=android-14 \
644 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \
645 --system=linux-x86_64 \
647 --toolchain=arm-linux-androideabi-4.9
649 # Android NDK r9d copies a broken unwind.h into the toolchain, see
650 # http://crbug.com/357890
651 rm -v "${LLVM_BUILD_DIR}"/android-toolchain
/include
/c
++/*/unwind.h
653 # Build ASan runtime for Android in a separate build tree.
654 mkdir
-p ${LLVM_BUILD_DIR}/android
655 pushd ${LLVM_BUILD_DIR}/android
656 rm -fv CMakeCache.txt
657 MACOSX_DEPLOYMENT_TARGET
=${deployment_target} cmake
-GNinja \
658 -DCMAKE_BUILD_TYPE=Release \
659 -DLLVM_ENABLE_ASSERTIONS=ON \
660 -DLLVM_ENABLE_THREADS=OFF \
661 -DCMAKE_C_COMPILER=${PWD}/..
/bin
/clang \
662 -DCMAKE_CXX_COMPILER=${PWD}/..
/bin
/clang
++ \
663 -DLLVM_CONFIG_PATH=${PWD}/..
/bin
/llvm-config \
664 -DCMAKE_C_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../android-toolchain/sysroot -B${PWD}/../android-toolchain" \
665 -DCMAKE_CXX_FLAGS="--target=arm-linux-androideabi --sysroot=${PWD}/../android-toolchain/sysroot -B${PWD}/../android-toolchain" \
667 "${ABS_COMPILER_RT_DIR}"
668 ninja libclang_rt.asan-arm-android.so
670 # And copy it into the main build tree.
671 cp "$(find -name libclang_rt.asan-arm-android.so)" "${ABS_LLVM_CLANG_LIB_DIR}/lib/linux/"
675 if [[ -n "$run_tests" ]]; then
676 # Run Chrome tool tests.
677 ninja
-C "${LLVM_BUILD_DIR}" cr-check-all
678 # Run the LLVM and Clang tests.
679 ninja
-C "${LLVM_BUILD_DIR}" check-all
682 # After everything is done, log success for this revision.
683 echo "${PACKAGE_VERSION}" > "${STAMP_FILE}"