18e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien#!/bin/sh 28e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# 38e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# Copyright (C) 2012 The Android Open Source Project 48e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# 58e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# Licensed under the Apache License, Version 2.0 (the "License"); 68e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# you may not use this file except in compliance with the License. 78e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# You may obtain a copy of the License at 88e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# 98e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# http://www.apache.org/licenses/LICENSE-2.0 108e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# 118e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# Unless required by applicable law or agreed to in writing, software 128e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# distributed under the License is distributed on an "AS IS" BASIS, 138e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 148e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# See the License for the specific language governing permissions and 158e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# limitations under the License. 168e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# 178e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# This shell script is used to rebuild the llvm and clang binaries 188e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# for the Android NDK. 198e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# 208e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 218e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# include common function and variable definitions 228e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien. `dirname $0`/prebuilt-common.sh 238e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 248e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienPROGRAM_PARAMETERS="<src-dir> <ndk-dir> <toolchain>" 258e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 268e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienPROGRAM_DESCRIPTION=\ 278e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien"Rebuild the LLVM prebuilt binaries for the Android NDK. 288e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 298e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienWhere <src-dir> is the location of toolchain sources, <ndk-dir> is 308e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienthe top-level NDK installation path and <toolchain> is the name of 317eb94c06c3eecb2fd8df73ef3708d3a2882d8f7bAndrew Hsiehthe toolchain to use (e.g. llvm-3.3)." 328e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 338e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienRELEASE=`date +%Y%m%d` 348e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienBUILD_OUT=/tmp/ndk-$USER/build/toolchain 358e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienOPTION_BUILD_OUT= 368e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienregister_var_option "--build-out=<path>" OPTION_BUILD_OUT "Set temporary build directory" 378e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 388e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# Note: platform API level 9 or higher is needed for proper C++ support 398e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienPLATFORM=$DEFAULT_PLATFORM 408e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienregister_var_option "--platform=<name>" PLATFORM "Specify platform name" 418e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 42ddeed0481172250935ed47f906905629450d981bAndrew HsiehGMP_VERSION=$DEFAULT_GMP_VERSION 43ddeed0481172250935ed47f906905629450d981bAndrew Hsiehregister_var_option "--gmp-version=<version>" GMP_VERSION "Specify gmp version" 44ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 458e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienPACKAGE_DIR= 468e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienregister_var_option "--package-dir=<path>" PACKAGE_DIR "Create archive tarball in specific directory" 478e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 489a8e348465381a80a516da2783289b40cfa12e56Andrew HsiehWINE=wine 499a8e348465381a80a516da2783289b40cfa12e56Andrew Hsiehregister_var_option "--wine=<path>" WINE "WINE needed to run llvm-config.exe for building mclinker with --mingw" 509a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh 51ddeed0481172250935ed47f906905629450d981bAndrew HsiehPOLLY=no 52ddeed0481172250935ed47f906905629450d981bAndrew Hsiehdo_polly_option () { POLLY=yes; } 53ddeed0481172250935ed47f906905629450d981bAndrew Hsiehregister_option "--with-polly" do_polly_option "Enable Polyhedral optimizations for LLVM" 54ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 55bedf803c145294a8a1970accd860d8a49379f9e7Andrew HsiehCHECK=no 56bedf803c145294a8a1970accd860d8a49379f9e7Andrew Hsiehdo_check_option () { CHECK=yes; } 57bedf803c145294a8a1970accd860d8a49379f9e7Andrew Hsiehregister_option "--check" do_check_option "Check LLVM" 58bedf803c145294a8a1970accd860d8a49379f9e7Andrew Hsieh 598e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienregister_jobs_option 603b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehregister_canadian_option 618e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienregister_try64_option 628e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 638e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienextract_parameters "$@" 648e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 653b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehprepare_canadian_toolchain /tmp/ndk-$USER/build 668e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 678e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienfix_option BUILD_OUT "$OPTION_BUILD_OUT" "build directory" 688e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chiensetup_default_log_file $BUILD_OUT/config.log 698e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 708e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienset_parameters () 718e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien{ 723f388011e9709ad81bdde9589ab2d86f0ef9606dAndrew Hsieh SRC_DIR="$1" 733f388011e9709ad81bdde9589ab2d86f0ef9606dAndrew Hsieh NDK_DIR="$2" 748e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien TOOLCHAIN="$3" 758e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 768e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien # Check source directory 778e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien # 788e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien if [ -z "$SRC_DIR" ] ; then 798e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien echo "ERROR: Missing source directory parameter. See --help for details." 808e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien exit 1 818e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien fi 828e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 8395b6825d5b1037a152c9efc83367dd3c75be04a3Andrew Hsieh if [ ! -d "$SRC_DIR/$TOOLCHAIN/llvm" ] ; then 8495b6825d5b1037a152c9efc83367dd3c75be04a3Andrew Hsieh echo "ERROR: Source directory does not contain llvm sources: $SRC_DIR/$TOOLCHAIN/llvm" 858e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien exit 1 868e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien fi 878e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 88ddeed0481172250935ed47f906905629450d981bAndrew Hsieh if [ -e "$SRC_DIR/$TOOLCHAIN/llvm/tools/polly" -a ! -h "$SRC_DIR/$TOOLCHAIN/llvm/tools/polly" ] ; then 89ddeed0481172250935ed47f906905629450d981bAndrew Hsieh echo "ERROR: polly, if exist, needs to be a symbolic link: $SRC_DIR/$TOOLCHAIN/llvm/tools/polly" 90ddeed0481172250935ed47f906905629450d981bAndrew Hsieh exit 1 91ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fi 92ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 93ddeed0481172250935ed47f906905629450d981bAndrew Hsieh GMP_SOURCE=$SRC_DIR/gmp/gmp-$GMP_VERSION.tar.bz2 94ddeed0481172250935ed47f906905629450d981bAndrew Hsieh if [ ! -f "$GMP_SOURCE" ] ; then 95ddeed0481172250935ed47f906905629450d981bAndrew Hsieh echo "ERROR: Source directory does not contain gmp: $GMP_SOURCE" 96ddeed0481172250935ed47f906905629450d981bAndrew Hsieh exit 1 97ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fi 983f388011e9709ad81bdde9589ab2d86f0ef9606dAndrew Hsieh SRC_DIR=`cd $SRC_DIR; pwd` 998e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien log "Using source directory: $SRC_DIR" 1008e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1018e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien # Check NDK installation directory 1028e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien # 1038e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien if [ -z "$NDK_DIR" ] ; then 1048e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien echo "ERROR: Missing NDK directory parameter. See --help for details." 1058e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien exit 1 1068e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien fi 1078e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1088e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien if [ ! -d "$NDK_DIR" ] ; then 1098e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien mkdir -p $NDK_DIR 1108e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien if [ $? != 0 ] ; then 1118e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien echo "ERROR: Could not create target NDK installation path: $NDK_DIR" 1128e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien exit 1 1138e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien fi 1148e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien fi 1153f388011e9709ad81bdde9589ab2d86f0ef9606dAndrew Hsieh NDK_DIR=`cd $NDK_DIR; pwd` 1168e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien log "Using NDK directory: $NDK_DIR" 1178e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1188e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien # Check toolchain name 1198e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien # 1208e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien if [ -z "$TOOLCHAIN" ] ; then 1218e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien echo "ERROR: Missing toolchain name parameter. See --help for details." 1228e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien exit 1 1238e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien fi 1248e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien} 1258e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1268e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienset_parameters $PARAMETERS 1278e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1288e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienprepare_target_build 1298e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1308e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienif [ "$PACKAGE_DIR" ]; then 1318e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien mkdir -p "$PACKAGE_DIR" 1328e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien fail_panic "Could not create package directory: $PACKAGE_DIR" 1338e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienfi 1348e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1358e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienset_toolchain_ndk $NDK_DIR $TOOLCHAIN 1368e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1373b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehif [ "$MINGW" != "yes" -a "$DARWIN" != "yes" ] ; then 1383b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh dump "Using C compiler: $CC" 1393b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh dump "Using C++ compiler: $CXX" 1403b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehfi 1418e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1428e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienrm -rf $BUILD_OUT 1438e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienmkdir -p $BUILD_OUT 1448e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 1453b28972d8a5a108579496233266fccd69c9d2fe5Andrew HsiehMAKE_FLAGS= 1463b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehif [ "$VERBOSE" = "yes" ]; then 1473b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh MAKE_FLAGS="VERBOSE=1" 1483b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehfi 1493b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh 1508e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan ChienTOOLCHAIN_BUILD_PREFIX=$BUILD_OUT/prefix 1518e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 152818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew HsiehARCH=$HOST_ARCH 153818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew Hsieh 1543b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh# Note that the following 2 flags only apply for BUILD_CC in canadian cross build 1553b28972d8a5a108579496233266fccd69c9d2fe5Andrew HsiehCFLAGS_FOR_BUILD="-O2 -I$TOOLCHAIN_BUILD_PREFIX/include" 1563b28972d8a5a108579496233266fccd69c9d2fe5Andrew HsiehLDFLAGS_FOR_BUILD="-L$TOOLCHAIN_BUILD_PREFIX/lib" 1573b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh 1583508d6a8bdb2510e70461dfcab8cfc184d92a30bPavel Chupin# Eliminate dependency on libgcc_s_sjlj-1.dll and libstdc++-6.dll on cross builds 1593508d6a8bdb2510e70461dfcab8cfc184d92a30bPavel Chupinif [ "$DARWIN" = "yes" -o "$MINGW" = "yes" ]; then 1603508d6a8bdb2510e70461dfcab8cfc184d92a30bPavel Chupin LDFLAGS_FOR_BUILD=$LDFLAGS_FOR_BUILD" -static-libgcc -static-libstdc++" 1613508d6a8bdb2510e70461dfcab8cfc184d92a30bPavel Chupinfi 1623508d6a8bdb2510e70461dfcab8cfc184d92a30bPavel Chupin 1633b28972d8a5a108579496233266fccd69c9d2fe5Andrew HsiehCFLAGS="$CFLAGS $CFLAGS_FOR_BUILD $HOST_CFLAGS" 1643b28972d8a5a108579496233266fccd69c9d2fe5Andrew HsiehCXXFLAGS="$CXXFLAGS $CFLAGS_FOR_BUILD $HOST_CFLAGS" # polly doesn't look at CFLAGS ! 1653b28972d8a5a108579496233266fccd69c9d2fe5Andrew HsiehLDFLAGS="$LDFLAGS $LDFLAGS_FOR_BUILD $HOST_LDFLAGS" 166818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew Hsiehexport CC CXX CFLAGS CXXFLAGS LDFLAGS CFLAGS_FOR_BUILD LDFLAGS_FOR_BUILD REQUIRES_RTTI=1 ARCH 1673b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh 1683b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehif [ "$DARWIN" = "yes" ]; then 1693b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh # To stop /usr/bin/install -s calls strip on darwin binary 1703b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh export KEEP_SYMBOLS=1 1713b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh # Disable polly for now 1723b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh POLLY=no 1733b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehfi 174ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 17503a98fc152662546429f3e86e454e8222779b42aAndrew Hsiehif [ "$POLLY" = "yes" -a ! -d "$SRC_DIR/$TOOLCHAIN/polly" ] ; then 17603a98fc152662546429f3e86e454e8222779b42aAndrew Hsieh dump "Disable polly because $SRC_DIR/$TOOLCHAIN/polly doesn't exist" 17703a98fc152662546429f3e86e454e8222779b42aAndrew Hsieh POLLY=no 17803a98fc152662546429f3e86e454e8222779b42aAndrew Hsiehfi 17903a98fc152662546429f3e86e454e8222779b42aAndrew Hsieh 180ddeed0481172250935ed47f906905629450d981bAndrew HsiehEXTRA_CONFIG_FLAGS= 181c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsiehrm -rf $SRC_DIR/$TOOLCHAIN/llvm/tools/polly 182c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsiehif [ "$POLLY" = "yes" ]; then 183ddeed0481172250935ed47f906905629450d981bAndrew Hsieh # crate symbolic link 184ddeed0481172250935ed47f906905629450d981bAndrew Hsieh ln -s ../../polly $SRC_DIR/$TOOLCHAIN/llvm/tools 185ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 186ddeed0481172250935ed47f906905629450d981bAndrew Hsieh # build polly dependencies 187ddeed0481172250935ed47f906905629450d981bAndrew Hsieh unpack_archive "$GMP_SOURCE" "$BUILD_OUT" 188ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't unpack $SRC_DIR/gmp/gmp-$GMP_VERSION to $BUILD_OUT" 189ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 190ddeed0481172250935ed47f906905629450d981bAndrew Hsieh GMP_BUILD_OUT=$BUILD_OUT/gmp-$GMP_VERSION 191ddeed0481172250935ed47f906905629450d981bAndrew Hsieh cd $GMP_BUILD_OUT 192ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't cd into gmp build path: $GMP_BUILD_OUT" 193ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 194ddeed0481172250935ed47f906905629450d981bAndrew Hsieh OLD_ABI="${ABI}" 195ddeed0481172250935ed47f906905629450d981bAndrew Hsieh export ABI=$HOST_GMP_ABI # needed to build 32-bit on 64-bit host 196ddeed0481172250935ed47f906905629450d981bAndrew Hsieh run ./configure \ 197ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --prefix=$TOOLCHAIN_BUILD_PREFIX \ 198ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --host=$ABI_CONFIGURE_HOST \ 199ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --build=$ABI_CONFIGURE_BUILD \ 200ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --disable-shared \ 201ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --disable-nls \ 202ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --enable-cxx 203ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't configure gmp" 204ddeed0481172250935ed47f906905629450d981bAndrew Hsieh run make -j$NUM_JOBS 205ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't compile gmp" 206ddeed0481172250935ed47f906905629450d981bAndrew Hsieh run make install 207ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't install gmp to $TOOLCHAIN_BUILD_PREFIX" 208ddeed0481172250935ed47f906905629450d981bAndrew Hsieh ABI="$OLD_ABI" 209ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 210ddeed0481172250935ed47f906905629450d981bAndrew Hsieh CLOOG_BUILD_OUT=$BUILD_OUT/cloog 211ddeed0481172250935ed47f906905629450d981bAndrew Hsieh mkdir -p $CLOOG_BUILD_OUT && cd $CLOOG_BUILD_OUT 212ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't create cloog build path: $CLOOG_BUILD_OUT" 213ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 214ddeed0481172250935ed47f906905629450d981bAndrew Hsieh run $SRC_DIR/$TOOLCHAIN/llvm/tools/polly/utils/cloog_src/configure \ 215ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --prefix=$TOOLCHAIN_BUILD_PREFIX \ 216ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --host=$ABI_CONFIGURE_HOST \ 217ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --build=$ABI_CONFIGURE_BUILD \ 218ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --with-gmp-prefix=$TOOLCHAIN_BUILD_PREFIX \ 219ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --disable-shared \ 220ddeed0481172250935ed47f906905629450d981bAndrew Hsieh --disable-nls 221ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't configure cloog" 222ddeed0481172250935ed47f906905629450d981bAndrew Hsieh run make -j$NUM_JOBS 223ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't compile cloog" 224ddeed0481172250935ed47f906905629450d981bAndrew Hsieh run make install 225ddeed0481172250935ed47f906905629450d981bAndrew Hsieh fail_panic "Couldn't install cloog to $TOOLCHAIN_BUILD_PREFIX" 226ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 227ddeed0481172250935ed47f906905629450d981bAndrew Hsieh EXTRA_CONFIG_FLAGS="--with-cloog=$TOOLCHAIN_BUILD_PREFIX --with-isl=$TOOLCHAIN_BUILD_PREFIX" 228818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew Hsieh 229818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew Hsieh # Allow text relocs when linking LLVMPolly.dylib against statically linked libgmp.a 230818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew Hsieh if [ "$HOST_TAG32" = "darwin-x86" -o "$DARWIN" = "yes" ]; then # -a "$HOST_ARCH" = "x86" 231818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew Hsieh LDFLAGS="$LDFLAGS -read_only_relocs suppress" 232818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew Hsieh export LDFLAGS 233818939010eda2710a68acb24c8c6aa8e47dff6b7Andrew Hsieh fi 234ddeed0481172250935ed47f906905629450d981bAndrew Hsiehfi # POLLY = yes 235ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 2368e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# configure the toolchain 2378e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chiendump "Configure: $TOOLCHAIN toolchain build" 238ddeed0481172250935ed47f906905629450d981bAndrew HsiehLLVM_BUILD_OUT=$BUILD_OUT/llvm 239ddeed0481172250935ed47f906905629450d981bAndrew Hsiehmkdir -p $LLVM_BUILD_OUT && cd $LLVM_BUILD_OUT 240ddeed0481172250935ed47f906905629450d981bAndrew Hsiehfail_panic "Couldn't cd into llvm build path: $LLVM_BUILD_OUT" 241ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 24295b6825d5b1037a152c9efc83367dd3c75be04a3Andrew Hsiehrun $SRC_DIR/$TOOLCHAIN/llvm/configure \ 2438e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien --prefix=$TOOLCHAIN_BUILD_PREFIX \ 2448e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien --host=$ABI_CONFIGURE_HOST \ 2458e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien --build=$ABI_CONFIGURE_BUILD \ 246d1ffb2662073329d0c2b13c082fc355035d2891cLogan Chien --with-bug-report-url=$DEFAULT_ISSUE_TRACKER_URL \ 2478e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien --enable-targets=arm,mips,x86 \ 2489ea8af51d236ef05a7297d0fdffd8365f4145aacLogan Chien --enable-optimized \ 24977d9062c6391002bb2340f1da0187f4807d776c2Andrew Hsieh --with-binutils-include=$SRC_DIR/binutils/binutils-$DEFAULT_BINUTILS_VERSION/include \ 250ddeed0481172250935ed47f906905629450d981bAndrew Hsieh $EXTRA_CONFIG_FLAGS 2518e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienfail_panic "Couldn't configure llvm toolchain" 2528e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 25382a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh# build llvm/clang 2548e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chiendump "Building : llvm toolchain [this can take a long time]." 255ddeed0481172250935ed47f906905629450d981bAndrew Hsiehcd $LLVM_BUILD_OUT 2563b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehrun make -j$NUM_JOBS $MAKE_FLAGS 2578e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienfail_panic "Couldn't compile llvm toolchain" 2588e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 2593b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehif [ "$CHECK" = "yes" -a "$MINGW" != "yes" -a "$DARWIN" != "yes" ] ; then 260c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh # run the regression test 261c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh dump "Running : llvm toolchain regression test" 262c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh cd $LLVM_BUILD_OUT 263c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh run make check-all 26416377bcfb3266c63f6039ddb53f3776b57c0effaAndrew Hsieh fail_warning "Couldn't pass all llvm regression test" # change to fail_panic later 265c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh if [ "$POLLY" = "yes" ]; then 266c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh dump "Running : polly toolchain regression test" 267c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh cd $LLVM_BUILD_OUT 268c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh run make polly-test -C tools/polly/test 26916377bcfb3266c63f6039ddb53f3776b57c0effaAndrew Hsieh fail_warning "Couldn't pass all polly regression test" # change to fail_panic later 270c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsieh fi 271c8078f93e69b23919ae82b070a95962470c68c34Andrew Hsiehfi 272ddeed0481172250935ed47f906905629450d981bAndrew Hsieh 2738e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# install the toolchain to its final location 27482a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsiehdump "Install : llvm toolchain binaries" 2753b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsiehcd $LLVM_BUILD_OUT && run make install $MAKE_FLAGS 2768e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienfail_panic "Couldn't install llvm toolchain to $TOOLCHAIN_BUILD_PREFIX" 2778e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 2789a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh# create llvm-config wrapper if needed. 2799a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh# llvm-config is invoked by other llvm projects (eg. mclinker/configure) 2809a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh# to figure out flags and libs dependencies. Unfortunately in canadian-build 2819a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh# llvm-config[.exe] may not run directly. Create a wrapper. 2829a8e348465381a80a516da2783289b40cfa12e56Andrew HsiehLLVM_CONFIG=llvm-config 2839a8e348465381a80a516da2783289b40cfa12e56Andrew Hsiehif [ "$MINGW" = "yes" ] ; then 2849a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh LLVM_CONFIG=llvm-config.sh 2859a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh cat > $TOOLCHAIN_BUILD_PREFIX/bin/$LLVM_CONFIG <<EOF 2869a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh$WINE \`dirname \$0\`/llvm-config.exe "\$@" 2879a8e348465381a80a516da2783289b40cfa12e56Andrew HsiehEOF 2889a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh chmod 0755 $TOOLCHAIN_BUILD_PREFIX/bin/$LLVM_CONFIG 2899a8e348465381a80a516da2783289b40cfa12e56Andrew Hsiehfi 2909a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh 2919a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh# build mclinker only against default the LLVM version, once 2929a8e348465381a80a516da2783289b40cfa12e56Andrew Hsiehif [ "$TOOLCHAIN" = "llvm-$DEFAULT_LLVM_VERSION" -a "$DARWIN" != "yes" ] ; then 29382a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh dump "Copy : mclinker source" 29482a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh MCLINKER_SRC_DIR=$BUILD_OUT/mclinker 29582a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh mkdir -p $MCLINKER_SRC_DIR 29682a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fail_panic "Couldn't create mclinker source directory: $MCLINKER_SRC_DIR" 29782a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh 29882a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh run copy_directory "$SRC_DIR/mclinker" "$MCLINKER_SRC_DIR" 29982a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fail_panic "Couldn't copy mclinker source: $MCLINKER_SRC_DIR" 30082a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh 3016021e2612ae907ec14d683edb329e675a37bcdf6Ray Donnelly CXXFLAGS="$CXXFLAGS -fexceptions" # optimized/ScriptParser.cc needs it 3026021e2612ae907ec14d683edb329e675a37bcdf6Ray Donnelly export CXXFLAGS 303a75d92649b9ecdd7f3470fcac689eae35a28536cAndrew Hsieh 30482a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh cd $MCLINKER_SRC_DIR && run ./autogen.sh 30582a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fail_panic "Couldn't run autogen.sh in $MCLINKER_SRC_DIR" 30682a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh 30782a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh dump "Configure: mclinker against $TOOLCHAIN" 30882a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh MCLINKER_BUILD_OUT=$MCLINKER_SRC_DIR/build 30982a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh mkdir -p $MCLINKER_BUILD_OUT && cd $MCLINKER_BUILD_OUT 31082a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fail_panic "Couldn't cd into mclinker build path: $MCLINKER_BUILD_OUT" 31182a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh 31282a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh run $MCLINKER_SRC_DIR/configure \ 31382a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh --prefix=$TOOLCHAIN_BUILD_PREFIX \ 3149a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh --with-llvm-config=$TOOLCHAIN_BUILD_PREFIX/bin/$LLVM_CONFIG \ 31582a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh --host=$ABI_CONFIGURE_HOST \ 3169a8e348465381a80a516da2783289b40cfa12e56Andrew Hsieh --build=$ABI_CONFIGURE_BUILD 31782a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fail_panic "Couldn't configure mclinker" 31882a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh 31982a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh dump "Building : mclinker" 32082a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh cd $MCLINKER_BUILD_OUT 3216021e2612ae907ec14d683edb329e675a37bcdf6Ray Donnelly run make -j$NUM_JOBS $MAKE_FLAGS CXXFLAGS="$CXXFLAGS" 32282a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fail_panic "Couldn't compile mclinker" 32382a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh 32482a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh dump "Install : mclinker" 32582a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh cd $MCLINKER_BUILD_OUT && run make install $MAKE_FLAGS 32682a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fail_panic "Couldn't install mclinker to $TOOLCHAIN_BUILD_PREFIX" 32782a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh 32882a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh if [ "$CHECK" = "yes" -a "$MINGW" != "yes" -a "$DARWIN" != "yes" ] ; then 32982a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh # run the regression test 33082a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh dump "Running : mclinker regression test" 33182a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh cd $MCLINKER_BUILD_OUT 33282a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh run make check 33382a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fail_warning "Couldn't pass all mclinker regression test" # change to fail_panic later 33482a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh fi 33582a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsiehfi 33682a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh 33782a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsieh# remove redundant bits 3388e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienrm -rf $TOOLCHAIN_BUILD_PREFIX/docs 3398e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienrm -rf $TOOLCHAIN_BUILD_PREFIX/include 3408e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/*.a 341ddeed0481172250935ed47f906905629450d981bAndrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/*.la 342ddeed0481172250935ed47f906905629450d981bAndrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/pkgconfig 34377d9062c6391002bb2340f1da0187f4807d776c2Andrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/lib[cp]*.so 34477d9062c6391002bb2340f1da0187f4807d776c2Andrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/lib[cp]*.dylib 345ddeed0481172250935ed47f906905629450d981bAndrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/B*.so 346ddeed0481172250935ed47f906905629450d981bAndrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/B*.dylib 347ddeed0481172250935ed47f906905629450d981bAndrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/LLVMH*.so 348ddeed0481172250935ed47f906905629450d981bAndrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/lib/LLVMH*.dylib 34982a52f8b1d9a944ae2fa9b3c9524181d00b41a6bAndrew Hsiehrm -rf $TOOLCHAIN_BUILD_PREFIX/bin/ld.bcc* 3508e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienrm -rf $TOOLCHAIN_BUILD_PREFIX/share 3518e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 352a2fd84c1f82f7c438adf3aaaa8c14f29d6df0596Logan ChienUNUSED_LLVM_EXECUTABLES=" 3537eb94c06c3eecb2fd8df73ef3708d3a2882d8f7bAndrew Hsiehbugpoint c-index-test clang-check clang-format clang-tblgen lli llvm-as llvm-bcanalyzer 35403a98fc152662546429f3e86e454e8222779b42aAndrew Hsiehllvm-config llvm-config-host llvm-cov llvm-diff llvm-dwarfdump llvm-extract llvm-ld 35503a98fc152662546429f3e86e454e8222779b42aAndrew Hsiehllvm-mc llvm-nm llvm-mcmarkup llvm-objdump llvm-prof llvm-ranlib llvm-readobj llvm-rtdyld 3567eb94c06c3eecb2fd8df73ef3708d3a2882d8f7bAndrew Hsiehllvm-size llvm-stress llvm-stub llvm-symbolizer llvm-tblgen macho-dump cloog" 357a2fd84c1f82f7c438adf3aaaa8c14f29d6df0596Logan Chien 358a2fd84c1f82f7c438adf3aaaa8c14f29d6df0596Logan Chienfor i in $UNUSED_LLVM_EXECUTABLES; do 359a2fd84c1f82f7c438adf3aaaa8c14f29d6df0596Logan Chien rm -f $TOOLCHAIN_BUILD_PREFIX/bin/$i 360a2fd84c1f82f7c438adf3aaaa8c14f29d6df0596Logan Chien rm -f $TOOLCHAIN_BUILD_PREFIX/bin/$i.exe 361a2fd84c1f82f7c438adf3aaaa8c14f29d6df0596Logan Chiendone 362a2fd84c1f82f7c438adf3aaaa8c14f29d6df0596Logan Chien 363475062536afdce382df7b9b891577740a4eb7a2dAndrew Hsiehtest -z "$STRIP" && STRIP=strip 364454a4461e791257580af5975656f16785dcac1abAndrew Hsiehfind $TOOLCHAIN_BUILD_PREFIX/bin -maxdepth 1 -type f -exec $STRIP {} \; 365454a4461e791257580af5975656f16785dcac1abAndrew Hsieh# Note that MacOSX strip generate the follow error on .dylib: 366454a4461e791257580af5975656f16785dcac1abAndrew Hsieh# "symbols referenced by indirect symbol table entries that can't be stripped " 367454a4461e791257580af5975656f16785dcac1abAndrew Hsiehfind $TOOLCHAIN_BUILD_PREFIX/lib -maxdepth 1 -type f \( -name "*.dll" -o -name "*.so" \) -exec $STRIP {} \; 3683b28972d8a5a108579496233266fccd69c9d2fe5Andrew Hsieh 3698f6ebb44673774081944dd526501f32bcf669736Lai Wei-Chih# install script 3708f6ebb44673774081944dd526501f32bcf669736Lai Wei-Chihcp -p "$SRC_DIR/$TOOLCHAIN/llvm/tools/ndk-bc2native/ndk-bc2native.py" "$TOOLCHAIN_BUILD_PREFIX/bin/" 3718f6ebb44673774081944dd526501f32bcf669736Lai Wei-Chih 3728e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien# copy to toolchain path 3738e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienrun copy_directory "$TOOLCHAIN_BUILD_PREFIX" "$TOOLCHAIN_PATH" 3748e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 3758fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh# create analyzer/++ scripts 3768fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehfor ABI in $PREBUILT_ABIS; do 3778fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh ANALYZER_PATH="$TOOLCHAIN_PATH/bin/$ABI" 3788fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh ANALYZER="$ANALYZER_PATH/analyzer" 3798fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh mkdir -p "$ANALYZER_PATH" 3808fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh case "$ABI" in 3818fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh armeabi) 3828fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh LLVM_TARGET=armv5te-none-linux-androideabi 3838fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh ;; 3848fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh armeabi-v7a) 3858fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh LLVM_TARGET=armv7-none-linux-androideabi 3868fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh ;; 3878fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh x86) 3888fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh LLVM_TARGET=i686-none-linux-android 3898fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh ;; 3908fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh mips) 3918fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh LLVM_TARGET=mipsel-none-linux-android 3928fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh ;; 3938fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh *) 3948fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh dump "ERROR: Unsupported NDK ABI: $ABI" 3958fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh exit 1 3968fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh esac 3978fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh 3988fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh cat > "${ANALYZER}" <<EOF 3998fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehif [ "\$1" != "-cc1" ]; then 4008fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh \`dirname \$0\`/../clang -target $LLVM_TARGET "\$@" 4018fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehelse 4028fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh # target/triple already spelled out. 4038fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh \`dirname \$0\`/../clang "\$@" 4048fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehfi 4058fbff41d699dad1386dcdf58e02b7263939abe41Andrew HsiehEOF 4068fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh cat > "${ANALYZER}++" <<EOF 4078fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehif [ "\$1" != "-cc1" ]; then 4088fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh \`dirname \$0\`/../clang++ -target $LLVM_TARGET "\$@" 4098fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehelse 4108fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh # target/triple already spelled out. 4118fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh \`dirname \$0\`/../clang++ "\$@" 4128fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehfi 4138fbff41d699dad1386dcdf58e02b7263939abe41Andrew HsiehEOF 4148fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh chmod 0755 "${ANALYZER}" "${ANALYZER}++" 4158fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh 4168fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh if [ -n "$HOST_EXE" ] ; then 4178fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh cat > "${ANALYZER}.cmd" <<EOF 4188fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh@echo off 4198fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehif "%1" == "-cc1" goto :L 4208fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh%~dp0\\..\\clang${HOST_EXE} -target $LLVM_TARGET %* 4218fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehif ERRORLEVEL 1 exit /b 1 4228fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehgoto :done 4238fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh:L 4248fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehrem target/triple already spelled out. 4258fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh%~dp0\\..\\clang${HOST_EXE} %* 4268fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehif ERRORLEVEL 1 exit /b 1 4278fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh:done 4288fbff41d699dad1386dcdf58e02b7263939abe41Andrew HsiehEOF 4298fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh cat > "${ANALYZER}++.cmd" <<EOF 4308fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh@echo off 4318fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehif "%1" == "-cc1" goto :L 4328fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh%~dp0\\..\\clang++${HOST_EXE} -target $LLVM_TARGET %* 4338fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehif ERRORLEVEL 1 exit /b 1 4348fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehgoto :done 4358fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh:L 4368fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehrem target/triple already spelled out. 4378fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh%~dp0\\..\\clang++${HOST_EXE} %* 4388fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehif ERRORLEVEL 1 exit /b 1 4398fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh:done 4408fbff41d699dad1386dcdf58e02b7263939abe41Andrew HsiehEOF 4418fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh fi 4428fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsiehdone 4438fbff41d699dad1386dcdf58e02b7263939abe41Andrew Hsieh 4448e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienif [ "$PACKAGE_DIR" ]; then 4458e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien ARCHIVE="$TOOLCHAIN-$HOST_TAG.tar.bz2" 4468e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien SUBDIR=$(get_toolchain_install_subdir $TOOLCHAIN $HOST_TAG) 4478e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien dump "Packaging $ARCHIVE" 4488e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SUBDIR" 4498e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienfi 4508e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien 4518e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chiendump "Done." 4528e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienif [ -z "$OPTION_BUILD_OUT" ] ; then 4538e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chien rm -rf $BUILD_OUT 4548e58e6b10c9c82e2085420b0e2f4c82d1db9b5c3Logan Chienfi 455