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, and then package the results up
11 # Parse command line options.
12 while [[ $# > 0 ]]; do
16 if [[ $# == 0 ]]; then
17 echo "--gcc-toolchain requires an argument."
20 if [[ -x "$1/bin/gcc" ]]; then
23 echo "Invalid --gcc-toolchain: '$1'."
24 echo "'$1/bin/gcc' does not appear to be valid."
30 echo "usage: $0 [--gcc-toolchain <prefix>]"
32 echo "--gcc-toolchain: Set the prefix for which GCC version should"
33 echo " be used for building. For example, to use gcc in"
34 echo " /opt/foo/bin/gcc, use '--gcc-toolchain '/opt/foo"
39 echo "Unknown argument: '$1'."
40 echo "Use --help for help."
48 THIS_DIR
="$(dirname "${0}")"
49 LLVM_DIR
="${THIS_DIR}/../../../third_party/llvm"
50 LLVM_BOOTSTRAP_DIR
="${THIS_DIR}/../../../third_party/llvm-bootstrap"
51 LLVM_BOOTSTRAP_INSTALL_DIR
="${LLVM_DIR}/../llvm-bootstrap-install"
52 LLVM_BUILD_DIR
="${THIS_DIR}/../../../third_party/llvm-build"
53 LLVM_BIN_DIR
="${LLVM_BUILD_DIR}/Release+Asserts/bin"
54 LLVM_LIB_DIR
="${LLVM_BUILD_DIR}/Release+Asserts/lib"
56 echo "Diff in llvm:" |
tee buildlog.txt
57 svn stat
"${LLVM_DIR}" 2>&1 |
tee -a buildlog.txt
58 svn
diff "${LLVM_DIR}" 2>&1 |
tee -a buildlog.txt
59 echo "Diff in llvm/tools/clang:" |
tee -a buildlog.txt
60 svn stat
"${LLVM_DIR}/tools/clang" 2>&1 |
tee -a buildlog.txt
61 svn
diff "${LLVM_DIR}/tools/clang" 2>&1 |
tee -a buildlog.txt
62 echo "Diff in llvm/compiler-rt:" |
tee -a buildlog.txt
63 svn stat
"${LLVM_DIR}/compiler-rt" 2>&1 |
tee -a buildlog.txt
64 svn
diff "${LLVM_DIR}/compiler-rt" 2>&1 |
tee -a buildlog.txt
65 echo "Diff in llvm/projects/libcxx:" |
tee -a buildlog.txt
66 svn stat
"${LLVM_DIR}/projects/libcxx" 2>&1 |
tee -a buildlog.txt
67 svn
diff "${LLVM_DIR}/projects/libcxx" 2>&1 |
tee -a buildlog.txt
68 echo "Diff in llvm/projects/libcxxabi:" |
tee -a buildlog.txt
69 svn stat
"${LLVM_DIR}/projects/libcxxabi" 2>&1 |
tee -a buildlog.txt
70 svn
diff "${LLVM_DIR}/projects/libcxxabi" 2>&1 |
tee -a buildlog.txt
73 echo "Starting build" |
tee -a buildlog.txt
78 rm -rf "${LLVM_BOOTSTRAP_DIR}"
79 rm -rf "${LLVM_BOOTSTRAP_INSTALL_DIR}"
80 rm -rf "${LLVM_BUILD_DIR}"
82 if [[ -n "${gcc_toolchain}" ]]; then
83 extra_flags
="--gcc-toolchain ${gcc_toolchain}"
85 "${THIS_DIR}"/update.sh
--bootstrap --force-local-build --run-tests \
86 ${extra_flags} 2>&1 |
tee -a buildlog.txt
88 R
=$
("${LLVM_BIN_DIR}/clang" --version | \
89 sed -ne 's/clang version .*(\([0-9]*\))/\1/p')
97 if [ "$(uname -s)" = "Darwin" ]; then
103 # Copy buildlog over.
104 cp buildlog.txt
$PDIR/
106 # Copy clang into pdir, symlink clang++ to it.
107 cp "${LLVM_BIN_DIR}/clang" $PDIR/bin
/
108 (cd $PDIR/bin
&& ln -sf clang clang
++)
109 cp "${LLVM_BIN_DIR}/llvm-symbolizer" $PDIR/bin
/
110 if [ "$(uname -s)" = "Darwin" ]; then
111 cp "${LLVM_BIN_DIR}/libc++.1.${SO_EXT}" $PDIR/bin
/
112 (cd $PDIR/bin
&& ln -sf libc
++.1.dylib libc
++.dylib
)
115 # Copy libc++ headers.
116 if [ "$(uname -s)" = "Darwin" ]; then
118 cp -R "${LLVM_BOOTSTRAP_INSTALL_DIR}/include/c++" $PDIR/include
121 # Copy plugins. Some of the dylibs are pretty big, so copy only the ones we
123 cp "${LLVM_LIB_DIR}/libFindBadConstructs.${SO_EXT}" $PDIR/lib
125 BLINKGCPLUGIN_LIBNAME
=\
126 $
(grep 'set(LIBRARYNAME' "$THIS_DIR"/..
/blink_gc_plugin
/CMakeLists.txt \
127 | cut
-d ' ' -f 2 |
tr -d ')')
128 cp "${LLVM_LIB_DIR}/lib${BLINKGCPLUGIN_LIBNAME}.${SO_EXT}" $PDIR/lib
130 if [[ -n "${gcc_toolchain}" ]]; then
131 # Copy the stdlibc++.so.6 we linked Clang against so it can run.
132 cp "${LLVM_LIB_DIR}/libstdc++.so.6" $PDIR/lib
135 # Copy built-in headers (lib/clang/3.x.y/include).
136 # compiler-rt builds all kinds of libraries, but we want only some.
137 if [ "$(uname -s)" = "Darwin" ]; then
138 # Keep only the OSX (ASan and profile) and iossim (ASan) runtime libraries:
139 # Release+Asserts/lib/clang/*/lib/darwin/libclang_rt.{asan,profile}_*
140 find "${LLVM_LIB_DIR}/clang" -type f
-path '*lib/darwin*' \
141 ! -name '*asan_osx*' ! -name '*asan_iossim*' ! -name '*profile_osx*' | \
143 # Fix LC_ID_DYLIB for the ASan dynamic libraries to be relative to
145 # TODO(glider): this is transitional. We'll need to fix the dylib name
146 # either in our build system, or in Clang. See also http://crbug.com/344836.
147 ASAN_DYLIB_NAMES
="libclang_rt.asan_osx_dynamic.dylib
148 libclang_rt.asan_iossim_dynamic.dylib"
149 for ASAN_DYLIB_NAME
in $ASAN_DYLIB_NAMES
151 ASAN_DYLIB
=$
(find "${LLVM_LIB_DIR}/clang" \
152 -type f
-path "*${ASAN_DYLIB_NAME}")
153 install_name_tool
-id @executable_path
/${ASAN_DYLIB_NAME} "${ASAN_DYLIB}"
154 strip
-x "${ASAN_DYLIB}"
158 # Release+Asserts/lib/clang/*/lib/linux/libclang_rt.{[atm]san,san,ubsan,profile}-*.a
160 find "${LLVM_LIB_DIR}/clang" -type f
-path '*lib/linux*' \
161 ! -name '*[atm]san*' ! -name '*ubsan*' ! -name '*libclang_rt.san*' \
162 ! -name '*profile*' |
xargs rm -v
163 # Strip the debug info from the runtime libraries.
164 find "${LLVM_LIB_DIR}/clang" -type f
-path '*lib/linux*' ! -name '*.syms' |
xargs strip
-g
167 cp -vR "${LLVM_LIB_DIR}/clang" $PDIR/lib
169 if [ "$(uname -s)" = "Darwin" ]; then
170 tar zcf
$PDIR.tgz
-C $PDIR bin include lib buildlog.txt
172 tar zcf
$PDIR.tgz
-C $PDIR bin lib buildlog.txt
175 if [ "$(uname -s)" = "Darwin" ]; then
182 echo gsutil
cp -a public-read
$PDIR.tgz \
183 gs
://chromium-browser-clang
/$PLATFORM/$PDIR.tgz