OLD | NEW |
---|---|
1 #!/usr/bin/env bash | 1 #!/usr/bin/env bash |
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 # This script will check out llvm and clang into third_party/llvm and build it. | 6 # This script will check out llvm and clang into third_party/llvm and build it. |
7 | 7 |
8 # Do NOT CHANGE this if you don't know what you're doing -- see | 8 # Do NOT CHANGE this if you don't know what you're doing -- see |
9 # https://code.google.com/p/chromium/wiki/UpdatingClang | 9 # https://code.google.com/p/chromium/wiki/UpdatingClang |
10 # Reverting problematic clang rolls is safe, though. | 10 # Reverting problematic clang rolls is safe, though. |
11 CLANG_REVISION=202554 | 11 CLANG_REVISION=202554 |
12 | 12 |
13 THIS_DIR="$(dirname "${0}")" | 13 THIS_DIR="$(dirname "${0}")" |
14 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" | 14 LLVM_DIR="${THIS_DIR}/../../../third_party/llvm" |
15 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" | 15 LLVM_BUILD_DIR="${LLVM_DIR}/../llvm-build" |
16 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" | 16 LLVM_BOOTSTRAP_DIR="${LLVM_DIR}/../llvm-bootstrap" |
17 LLVM_BOOTSTRAP_INSTALL_DIR="${LLVM_DIR}/../llvm-bootstrap-install" | 17 LLVM_BOOTSTRAP_INSTALL_DIR="${LLVM_DIR}/../llvm-bootstrap-install" |
18 CLANG_DIR="${LLVM_DIR}/tools/clang" | 18 CLANG_DIR="${LLVM_DIR}/tools/clang" |
19 CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" | 19 CLANG_TOOLS_EXTRA_DIR="${CLANG_DIR}/tools/extra" |
20 COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" | 20 COMPILER_RT_DIR="${LLVM_DIR}/projects/compiler-rt" |
21 LIBCXX_DIR="${LLVM_DIR}/projects/libcxx" | 21 LIBCXX_DIR="${LLVM_DIR}/projects/libcxx" |
22 LIBCXXABI_DIR="${LLVM_DIR}/projects/libcxxabi" | |
22 ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk" | 23 ANDROID_NDK_DIR="${LLVM_DIR}/../android_tools/ndk" |
23 STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" | 24 STAMP_FILE="${LLVM_BUILD_DIR}/cr_build_revision" |
24 | 25 |
26 ABS_LIBCXX_DIR="${PWD}/${LIBCXX_DIR}" | |
27 ABS_LIBCXXABI_DIR="${PWD}/${LIBCXXABI_DIR}" | |
28 | |
29 | |
25 # Use both the clang revision and the plugin revisions to test for updates. | 30 # Use both the clang revision and the plugin revisions to test for updates. |
26 BLINKGCPLUGIN_REVISION=\ | 31 BLINKGCPLUGIN_REVISION=\ |
27 $(grep LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \ | 32 $(grep LIBRARYNAME "$THIS_DIR"/../blink_gc_plugin/Makefile \ |
28 | cut -d '_' -f 2) | 33 | cut -d '_' -f 2) |
29 CLANG_AND_PLUGINS_REVISION="${CLANG_REVISION}-${BLINKGCPLUGIN_REVISION}" | 34 CLANG_AND_PLUGINS_REVISION="${CLANG_REVISION}-${BLINKGCPLUGIN_REVISION}" |
30 | 35 |
31 # ${A:-a} returns $A if it's set, a else. | 36 # ${A:-a} returns $A if it's set, a else. |
32 LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} | 37 LLVM_REPO_URL=${LLVM_URL:-https://llvm.org/svn/llvm-project} |
33 | 38 |
34 if [[ -z "$GYP_DEFINES" ]]; then | 39 if [[ -z "$GYP_DEFINES" ]]; then |
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
269 "${COMPILER_RT_DIR}" | 274 "${COMPILER_RT_DIR}" |
270 | 275 |
271 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes | 276 # clang needs a libc++ checkout, else -stdlib=libc++ won't find includes |
272 # (i.e. this is needed for bootstrap builds). | 277 # (i.e. this is needed for bootstrap builds). |
273 if [ "${OS}" = "Darwin" ]; then | 278 if [ "${OS}" = "Darwin" ]; then |
274 echo Getting libc++ r"${CLANG_REVISION}" in "${LIBCXX_DIR}" | 279 echo Getting libc++ r"${CLANG_REVISION}" in "${LIBCXX_DIR}" |
275 svn co --force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \ | 280 svn co --force "${LLVM_REPO_URL}/libcxx/trunk@${CLANG_REVISION}" \ |
276 "${LIBCXX_DIR}" | 281 "${LIBCXX_DIR}" |
277 fi | 282 fi |
278 | 283 |
284 # While we're bundling our own libc++ on OS X, we need to compile libc++abi | |
285 # into it too (since OS X 10.6 doesn't have libc++abi.dylib either). | |
286 if [ "${OS}" = "Darwin" ]; then | |
287 echo Getting libc++abi r"${CLANG_REVISION}" in "${LIBCXXABI_DIR}" | |
288 svn co --force "${LLVM_REPO_URL}/libcxxabi/trunk@${CLANG_REVISION}" \ | |
289 "${LIBCXXABI_DIR}" | |
290 fi | |
291 | |
279 # Apply patch for test failing with --disable-pthreads (llvm.org/PR11974) | 292 # Apply patch for test failing with --disable-pthreads (llvm.org/PR11974) |
280 cd "${CLANG_DIR}" | 293 cd "${CLANG_DIR}" |
281 svn revert test/Index/crash-recovery-modules.m | 294 svn revert test/Index/crash-recovery-modules.m |
282 cat << 'EOF' | | 295 cat << 'EOF' | |
283 --- third_party/llvm/tools/clang/test/Index/crash-recovery-modules.m (revisio n 202554) | 296 --- third_party/llvm/tools/clang/test/Index/crash-recovery-modules.m (revisio n 202554) |
284 +++ third_party/llvm/tools/clang/test/Index/crash-recovery-modules.m (working copy) | 297 +++ third_party/llvm/tools/clang/test/Index/crash-recovery-modules.m (working copy) |
285 @@ -12,6 +12,8 @@ | 298 @@ -12,6 +12,8 @@ |
286 | 299 |
287 // REQUIRES: crash-recovery | 300 // REQUIRES: crash-recovery |
288 // REQUIRES: shell | 301 // REQUIRES: shell |
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
950 export CC="$gcc_toolchain/bin/gcc" | 963 export CC="$gcc_toolchain/bin/gcc" |
951 export CXX="$gcc_toolchain/bin/g++" | 964 export CXX="$gcc_toolchain/bin/g++" |
952 fi | 965 fi |
953 | 966 |
954 export CFLAGS="" | 967 export CFLAGS="" |
955 export CXXFLAGS="" | 968 export CXXFLAGS="" |
956 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is | 969 # LLVM uses C++11 starting in llvm 3.5. On Linux, this means libstdc++4.7+ is |
957 # needed, on OS X it requires libc++. clang only automatically links to libc++ | 970 # needed, on OS X it requires libc++. clang only automatically links to libc++ |
958 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on | 971 # when targeting OS X 10.9+, so add stdlib=libc++ explicitly so clang can run on |
959 # OS X versions as old as 10.7. | 972 # OS X versions as old as 10.7. |
960 # TODO(thakis): Enable this once all bots are on 10.7, and remove the | 973 # TODO(thakis): Some bots are still on 10.6, so for now bundle libc++.dylib. |
961 # --disable-compiler-version-checks flags below, and change all | 974 # Remove this once all bots are on 10.7+, then use --enable-libcpp=yes and |
962 # MACOSX_DEPLOYMENT_TARGET values to 10.7. | 975 # change all MACOSX_DEPLOYMENT_TARGET values to 10.7. |
963 if [ "${OS}" = "Darwin" ]; then | 976 if [ "${OS}" = "Darwin" ]; then |
964 #CXXFLAGS="-stdlib=libc++" | 977 # When building on 10.9, /usr/include usually doesn't exist, and while |
965 CXXFLAGS="-std=gnu++98" | 978 # Xcode's clang automatically sets a sysroot, self-built clangs don't. |
979 export CFLAGS="-isysroot $(xcrun --show-sdk-path)" | |
980 export CPPFLAGS="${CFLAGS}" | |
981 export CXXFLAGS="-stdlib=libc++ -nostdinc++ -I${ABS_LIBCXX_DIR}/include ${CFLA GS}" | |
966 fi | 982 fi |
967 | 983 |
968 # Build bootstrap clang if requested. | 984 # Build bootstrap clang if requested. |
969 if [[ -n "${bootstrap}" ]]; then | 985 if [[ -n "${bootstrap}" ]]; then |
970 ABS_INSTALL_DIR="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}" | 986 ABS_INSTALL_DIR="${PWD}/${LLVM_BOOTSTRAP_INSTALL_DIR}" |
971 echo "Building bootstrap compiler" | 987 echo "Building bootstrap compiler" |
972 mkdir -p "${LLVM_BOOTSTRAP_DIR}" | 988 mkdir -p "${LLVM_BOOTSTRAP_DIR}" |
973 cd "${LLVM_BOOTSTRAP_DIR}" | 989 cd "${LLVM_BOOTSTRAP_DIR}" |
974 if [[ ! -f ./config.status ]]; then | 990 if [[ ! -f ./config.status ]]; then |
975 # The bootstrap compiler only needs to be able to build the real compiler, | 991 # The bootstrap compiler only needs to be able to build the real compiler, |
976 # so it needs no cross-compiler output support. In general, the host | 992 # so it needs no cross-compiler output support. In general, the host |
977 # compiler should be as similar to the final compiler as possible, so do | 993 # compiler should be as similar to the final compiler as possible, so do |
978 # keep --disable-threads & co. | 994 # keep --disable-threads & co. |
979 ../llvm/configure \ | 995 ../llvm/configure \ |
980 --disable-compiler-version-checks \ | |
981 --enable-optimized \ | 996 --enable-optimized \ |
982 --enable-targets=host-only \ | 997 --enable-targets=host-only \ |
983 --enable-libedit=no \ | 998 --enable-libedit=no \ |
984 --disable-threads \ | 999 --disable-threads \ |
985 --disable-pthreads \ | 1000 --disable-pthreads \ |
986 --without-llvmgcc \ | 1001 --without-llvmgcc \ |
987 --without-llvmgxx \ | 1002 --without-llvmgxx \ |
988 --prefix="${ABS_INSTALL_DIR}" | 1003 --prefix="${ABS_INSTALL_DIR}" |
989 fi | 1004 fi |
990 | 1005 |
991 MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" | 1006 ${MAKE} -j"${NUM_JOBS}" |
992 if [[ -n "${run_tests}" ]]; then | 1007 if [[ -n "${run_tests}" ]]; then |
993 ${MAKE} check-all | 1008 ${MAKE} check-all |
994 fi | 1009 fi |
995 | 1010 |
996 MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} install | 1011 ${MAKE} install |
997 if [[ -n "${gcc_toolchain}" ]]; then | 1012 if [[ -n "${gcc_toolchain}" ]]; then |
998 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap | 1013 # Copy that gcc's stdlibc++.so.6 to the build dir, so the bootstrap |
999 # compiler can start. | 1014 # compiler can start. |
1000 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \ | 1015 cp -v "$(${CXX} -print-file-name=libstdc++.so.6)" \ |
1001 "${ABS_INSTALL_DIR}/lib/" | 1016 "${ABS_INSTALL_DIR}/lib/" |
1002 fi | 1017 fi |
1003 | 1018 |
1004 cd - | 1019 cd - |
1005 export CC="${ABS_INSTALL_DIR}/bin/clang" | 1020 export CC="${ABS_INSTALL_DIR}/bin/clang" |
1006 export CXX="${ABS_INSTALL_DIR}/bin/clang++" | 1021 export CXX="${ABS_INSTALL_DIR}/bin/clang++" |
1007 | 1022 |
1008 if [[ -n "${gcc_toolchain}" ]]; then | 1023 if [[ -n "${gcc_toolchain}" ]]; then |
1009 # Tell the bootstrap compiler to use a specific gcc prefix to search | 1024 # Tell the bootstrap compiler to use a specific gcc prefix to search |
1010 # for standard library headers and shared object file. | 1025 # for standard library headers and shared object file. |
1011 export CFLAGS="--gcc-toolchain=${gcc_toolchain}" | 1026 export CFLAGS="--gcc-toolchain=${gcc_toolchain}" |
1012 export CXXFLAGS="--gcc-toolchain=${gcc_toolchain}" | 1027 export CXXFLAGS="--gcc-toolchain=${gcc_toolchain}" |
1013 fi | 1028 fi |
1014 | 1029 |
1015 echo "Building final compiler" | 1030 echo "Building final compiler" |
1016 fi | 1031 fi |
1017 | 1032 |
1018 # Build clang (in a separate directory). | 1033 # Build clang (in a separate directory). |
1019 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, | 1034 # The clang bots have this path hardcoded in built/scripts/slave/compile.py, |
1020 # so if you change it you also need to change these links. | 1035 # so if you change it you also need to change these links. |
1021 mkdir -p "${LLVM_BUILD_DIR}" | 1036 mkdir -p "${LLVM_BUILD_DIR}" |
1022 cd "${LLVM_BUILD_DIR}" | 1037 pushd "${LLVM_BUILD_DIR}" |
1038 | |
1039 # Build libc++.dylib while some bots are still on OS X 10.6. | |
hans
2014/04/01 15:59:19
i never built libc++, but i assume its build syste
Nico
2014/04/01 18:26:18
libc++'s build system is a shell script called "bu
| |
1040 if [ "${OS}" = "Darwin" ]; then | |
1041 rm -rf libcxxbuild | |
1042 LIBCXXFLAGS="-O3 -std=c++11 -fstrict-aliasing" | |
1043 | |
1044 # libcxx and libcxxabi both have a file stdexcept.cpp, so put their .o files | |
1045 # into different subdirectories. | |
1046 mkdir -p libcxxbuild/libcxx | |
1047 pushd libcxxbuild/libcxx | |
1048 c++ -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXX_DIR}"/src/*.cpp | |
1049 popd | |
1050 | |
1051 mkdir -p libcxxbuild/libcxxabi | |
1052 pushd libcxxbuild/libcxxabi | |
1053 c++ -c ${CXXFLAGS} ${LIBCXXFLAGS} "${ABS_LIBCXXABI_DIR}"/src/*.cpp -I"${ABS_LI BCXXABI_DIR}/include" | |
1054 popd | |
1055 | |
1056 pushd libcxxbuild | |
1057 cc libcxx/*.o libcxxabi/*.o -o libc++.1.dylib -dynamiclib -nodefaultlibs \ | |
1058 -current_version 1 -compatibility_version 1 \ | |
1059 -lSystem -install_name @executable_path/libc++.dylib \ | |
1060 -Wl,-unexported_symbols_list,${ABS_LIBCXX_DIR}/lib/libc++unexp.exp \ | |
1061 -Wl,-force_symbols_not_weak_list,${ABS_LIBCXX_DIR}/lib/notweak.exp \ | |
1062 -Wl,-force_symbols_weak_list,${ABS_LIBCXX_DIR}/lib/weak.exp | |
1063 ln -sf libc++.1.dylib libc++.dylib | |
1064 popd | |
1065 export LDFLAGS+="-stdlib=libc++ -L${PWD}/libcxxbuild" | |
1066 fi | |
1067 | |
1023 if [[ ! -f ./config.status ]]; then | 1068 if [[ ! -f ./config.status ]]; then |
1024 ../llvm/configure \ | 1069 ../llvm/configure \ |
1025 --disable-compiler-version-checks \ | |
1026 --enable-optimized \ | 1070 --enable-optimized \ |
1027 --enable-libedit=no \ | 1071 --enable-libedit=no \ |
1028 --disable-threads \ | 1072 --disable-threads \ |
1029 --disable-pthreads \ | 1073 --disable-pthreads \ |
1030 --without-llvmgcc \ | 1074 --without-llvmgcc \ |
1031 --without-llvmgxx | 1075 --without-llvmgxx |
1032 fi | 1076 fi |
1033 | 1077 |
1034 if [[ -n "${gcc_toolchain}" ]]; then | 1078 if [[ -n "${gcc_toolchain}" ]]; then |
1035 # Copy in the right stdlibc++.so.6 so clang can start. | 1079 # Copy in the right stdlibc++.so.6 so clang can start. |
1036 mkdir -p Release+Asserts/lib | 1080 mkdir -p Release+Asserts/lib |
1037 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" \ | 1081 cp -v "$(${CXX} ${CXXFLAGS} -print-file-name=libstdc++.so.6)" \ |
1038 Release+Asserts/lib/ | 1082 Release+Asserts/lib/ |
1039 fi | 1083 fi |
1040 MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" | 1084 MACOSX_DEPLOYMENT_TARGET=10.5 ${MAKE} -j"${NUM_JOBS}" |
1041 STRIP_FLAGS= | 1085 STRIP_FLAGS= |
1042 if [ "${OS}" = "Darwin" ]; then | 1086 if [ "${OS}" = "Darwin" ]; then |
1043 # See http://crbug.com/256342 | 1087 # See http://crbug.com/256342 |
1044 STRIP_FLAGS=-x | 1088 STRIP_FLAGS=-x |
1089 | |
1090 cp libcxxbuild/libc++.1.dylib Release+Asserts/bin | |
1045 fi | 1091 fi |
1046 strip ${STRIP_FLAGS} Release+Asserts/bin/clang | 1092 strip ${STRIP_FLAGS} Release+Asserts/bin/clang |
1047 cd - | 1093 popd |
1048 | 1094 |
1049 if [[ -n "${with_android}" ]]; then | 1095 if [[ -n "${with_android}" ]]; then |
1050 # Make a standalone Android toolchain. | 1096 # Make a standalone Android toolchain. |
1051 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ | 1097 ${ANDROID_NDK_DIR}/build/tools/make-standalone-toolchain.sh \ |
1052 --platform=android-14 \ | 1098 --platform=android-14 \ |
1053 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \ | 1099 --install-dir="${LLVM_BUILD_DIR}/android-toolchain" \ |
1054 --system=linux-x86_64 \ | 1100 --system=linux-x86_64 \ |
1055 --stl=stlport | 1101 --stl=stlport |
1056 | 1102 |
1057 # Build ASan runtime for Android. | 1103 # Build ASan runtime for Android. |
(...skipping 29 matching lines...) Expand all Loading... | |
1087 "${TOOL_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" | 1133 "${TOOL_SRC_DIR}/tests/test.sh" "${LLVM_BUILD_DIR}/Release+Asserts" |
1088 fi | 1134 fi |
1089 done | 1135 done |
1090 cd "${LLVM_BUILD_DIR}" | 1136 cd "${LLVM_BUILD_DIR}" |
1091 ${MAKE} check-all | 1137 ${MAKE} check-all |
1092 cd - | 1138 cd - |
1093 fi | 1139 fi |
1094 | 1140 |
1095 # After everything is done, log success for this revision. | 1141 # After everything is done, log success for this revision. |
1096 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" | 1142 echo "${CLANG_AND_PLUGINS_REVISION}" > "${STAMP_FILE}" |
OLD | NEW |