diff options
author | Andrew Hsieh <andrewhsieh@google.com> | 2014-11-13 01:33:23 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2014-11-13 01:33:23 +0000 |
commit | 1814549e6ffe19a5b507ccf476c862b9376283cb (patch) | |
tree | 13140492e1ee4fc5c7b86ddc723d91bfe4cf3d52 /build | |
parent | c74cc9f75066402609f854c6c1ad98aa24f3dea7 (diff) | |
parent | c4bc12f9d2c1aa303bb54ff411a9c554013d29f7 (diff) | |
download | ndk-1814549e6ffe19a5b507ccf476c862b9376283cb.tar.gz |
Merge "Support build-target-prebuilts for selected toolchain version"
Diffstat (limited to 'build')
-rwxr-xr-x | build/tools/build-cxx-stl.sh | 18 | ||||
-rwxr-xr-x | build/tools/build-gdbserver.sh | 2 | ||||
-rwxr-xr-x | build/tools/build-gnu-libstdc++.sh | 1 | ||||
-rwxr-xr-x | build/tools/build-host-prebuilts.sh | 22 | ||||
-rwxr-xr-x | build/tools/build-libportable.sh | 2 | ||||
-rwxr-xr-x | build/tools/build-target-prebuilts.sh | 90 | ||||
-rw-r--r-- | build/tools/dev-defaults.sh | 11 | ||||
-rwxr-xr-x | build/tools/gen-platforms.sh | 10 | ||||
-rwxr-xr-x | build/tools/rebuild-all-prebuilt.sh | 28 |
9 files changed, 126 insertions, 58 deletions
diff --git a/build/tools/build-cxx-stl.sh b/build/tools/build-cxx-stl.sh index 723cd6b34..8a512006e 100755 --- a/build/tools/build-cxx-stl.sh +++ b/build/tools/build-cxx-stl.sh @@ -80,24 +80,16 @@ register_var_option "--visible-static" VISIBLE_STATIC "Do not use hidden visibil WITH_DEBUG_INFO= register_var_option "--with-debug-info" WITH_DEBUG_INFO "Build with -g. STL is still built with optimization but with debug info" -EXPLICIT_COMPILER_VERSION= - GCC_VERSION= -register_option "--gcc-version=<ver>" do_gcc_version "Specify GCC version" -do_gcc_version() { - GCC_VERSION=$1 - EXPLICIT_COMPILER_VERSION=true -} +register_var_option "--gcc-version=<ver>" GCC_VERSION "Specify GCC version" LLVM_VERSION= -register_option "--llvm-version=<ver>" do_llvm_version "Specify LLVM version" -do_llvm_version() { - LLVM_VERSION=$1 - EXPLICIT_COMPILER_VERSION=true -} +register_var_option "--llvm-version=<ver>" LLVM_VERSION "Specify LLVM version" register_jobs_option +register_try64_option + extract_parameters "$@" if [ -n "${LLVM_VERSION}" -a -n "${GCC_VERSION}" ]; then @@ -198,7 +190,7 @@ fi if [ "$CXX_STL" = "libc++" ]; then # Use clang to build libc++ by default. - if [ "$EXPLICIT_COMPILER_VERSION" != "true" ]; then + if [ -z "$LLVM_VERSION" -a -z "$GCC_VERSION" ]; then LLVM_VERSION=$DEFAULT_LLVM_VERSION fi fi diff --git a/build/tools/build-gdbserver.sh b/build/tools/build-gdbserver.sh index 2e8289d68..a44d81379 100755 --- a/build/tools/build-gdbserver.sh +++ b/build/tools/build-gdbserver.sh @@ -59,6 +59,8 @@ register_var_option "--package-dir=<path>" PACKAGE_DIR "Archive binary into spec register_jobs_option +register_try64_option + extract_parameters "$@" setup_default_log_file diff --git a/build/tools/build-gnu-libstdc++.sh b/build/tools/build-gnu-libstdc++.sh index bd15f828b..2923b0199 100755 --- a/build/tools/build-gnu-libstdc++.sh +++ b/build/tools/build-gnu-libstdc++.sh @@ -72,6 +72,7 @@ WITH_DEBUG_INFO= register_var_option "--with-debug-info" WITH_DEBUG_INFO "Build with -g. STL is still built with optimization but with debug info" register_jobs_option +register_try64_option extract_parameters "$@" diff --git a/build/tools/build-host-prebuilts.sh b/build/tools/build-host-prebuilts.sh index 98378d074..19a628c8c 100755 --- a/build/tools/build-host-prebuilts.sh +++ b/build/tools/build-host-prebuilts.sh @@ -324,17 +324,11 @@ for SYSTEM in $SYSTEMS; do # Then the toolchains for ARCH in $ARCHS; do - TOOLCHAIN_NAMES=$(get_toolchain_name_list_for_arch $ARCH) if [ "$GCC_VERSION_LIST" != "default" ]; then - TOOLCHAINS= - for VERSION in $(commas_to_spaces $GCC_VERSION_LIST); do - for TOOLCHAIN in $TOOLCHAIN_NAMES; do - if [ $TOOLCHAIN != ${TOOLCHAIN%%$VERSION} ]; then - TOOLCHAINS="$TOOLCHAIN $TOOLCHAINS" - fi - done - done - TOOLCHAIN_NAMES=$TOOLCHAINS + VERSIONS=$(spaces_to_commas $GCC_VERSION_LIST) + TOOLCHAIN_NAMES=$(get_toolchain_name_list_for_arch $ARCH $VERSIONS) + else + TOOLCHAIN_NAMES=$(get_toolchain_name_list_for_arch $ARCH) fi if [ -z "$TOOLCHAIN_NAMES" ]; then echo "ERROR: Toolchains: "$(spaces_to_commas $GCC_VERSION_LIST)" are not available for arch: $ARCH" @@ -359,9 +353,11 @@ for SYSTEM in $SYSTEMS; do fail_panic "Could not build llvm for $SYSNAME" done - # Deploy ld.mcld - run $PROGDIR/deploy-host-mcld.sh --package-dir=$PACKAGE_DIR --systems=$SYSNAME - fail_panic "Could not deploy ld.mcld for $SYSNAME" + if [ ! -z "$LLVM_VERSION_LIST" ]; then + # Deploy ld.mcld + run $PROGDIR/deploy-host-mcld.sh --package-dir=$PACKAGE_DIR --systems=$SYSNAME + fail_panic "Could not deploy ld.mcld for $SYSNAME" + fi # We're done for this system done diff --git a/build/tools/build-libportable.sh b/build/tools/build-libportable.sh index 016406bbc..80c9b22f7 100755 --- a/build/tools/build-libportable.sh +++ b/build/tools/build-libportable.sh @@ -73,6 +73,8 @@ register_var_option "--platform=<name>" PLATFORM "Specify platform name" register_jobs_option +register_try64_option + extract_parameters "$@" ABIS=$(commas_to_spaces $ABIS) diff --git a/build/tools/build-target-prebuilts.sh b/build/tools/build-target-prebuilts.sh index 8826749b9..31e71b6ed 100755 --- a/build/tools/build-target-prebuilts.sh +++ b/build/tools/build-target-prebuilts.sh @@ -30,6 +30,12 @@ register_var_option "--arch=<list>" ARCHS "List of target archs to build for" NO_GEN_PLATFORMS= register_var_option "--no-gen-platforms" NO_GEN_PLATFORMS "Don't generate platforms/ directory, use existing one" +GCC_VERSION_LIST="default" # it's arch defined by default so use default keyword +register_var_option "--gcc-version-list=<vers>" GCC_VERSION_LIST "GCC version list (libgnustl should be built per each GCC version)" + +LLVM_VERSION= +register_var_option "--llvm-version=<vers>" LLVM_VERSION "LLVM version" + PACKAGE_DIR= register_var_option "--package-dir=<path>" PACKAGE_DIR "Package toolchain into this directory" @@ -38,6 +44,8 @@ register_var_option "--visible-libgnustl-static" VISIBLE_LIBGNUSTL_STATIC "Do no register_jobs_option +register_try64_option + PROGRAM_PARAMETERS="<toolchain-src-dir>" PROGRAM_DESCRIPTION=\ "This script can be used to rebuild all the target NDK prebuilts at once. @@ -46,6 +54,25 @@ downloaded by the 'download-toolchain-sources.sh' dev-script." extract_parameters "$@" +# Pickup one GCC_VERSION for the cases where we want only one build +# That's actually all cases except libgnustl where we are building for each GCC version +GCC_VERSION= +if [ "$GCC_VERSION_LIST" != "default" ]; then + GCC_VERSIONS=$(commas_to_spaces $GCC_VERSION_LIST) + GCC_VERSION=${GCC_VERSIONS%% *} +fi + +# Use DEFAULT_LLVM_VERSION to build targets unless we want to build with some particular version +if [ -z "$GCC_VERSION_LIST" -a -z "$LLVM_VERSION" ]; then + LLVM_VERSION=$DEFAULT_LLVM_VERSION +fi + +if [ ! -z "$LLVM_VERSION" ]; then + BUILD_TOOLCHAIN="--llvm-version=$LLVM_VERSION" +else + BUILD_TOOLCHAIN="--gcc-version=$GCC_VERSION" +fi + # Check toolchain source path SRC_DIR="$PARAMETERS" check_toolchain_src_dir "$SRC_DIR" @@ -62,7 +89,11 @@ fi if [ -z "$NO_GEN_PLATFORMS" ]; then echo "Preparing the build..." - run $BUILDTOOLS/gen-platforms.sh --samples --fast-copy --dst-dir=$NDK_DIR --ndk-dir=$NDK_DIR --arch=$(spaces_to_commas $ARCHS) $PACKAGE_FLAGS + PLATFORMS_BUILD_TOOLCHAIN= + if [ "$GCC_VERSION" != "default" ]; then + PLATFORMS_BUILD_TOOLCHAIN="--gcc-version=$GCC_VERSION" + fi + run $BUILDTOOLS/gen-platforms.sh --samples --fast-copy --dst-dir=$NDK_DIR --ndk-dir=$NDK_DIR --arch=$(spaces_to_commas $ARCHS) $PACKAGE_FLAGS $PLATFORMS_BUILD_TOOLCHAIN fail_panic "Could not generate platforms and samples directores!" else if [ ! -d "$NDK_DIR/platforms" ]; then @@ -96,36 +127,43 @@ if [ "$PACKAGE_DIR" ]; then fi FLAGS=$FLAGS" -j$NUM_JOBS" +if [ "$TRY64" = "yes" ]; then + FLAGS=$FLAGS" --try-64" +fi + # First, gdbserver for ARCH in $ARCHS; do - GDB_TOOLCHAINS=$(get_default_toolchain_name_for_arch $ARCH) - for GDB_TOOLCHAIN in $GDB_TOOLCHAINS; do - GDB_VERSION="--gdb-version="$(get_default_gdb_version_for_gcc $GDB_TOOLCHAIN) - dump "Building $GDB_TOOLCHAIN gdbserver binaries..." - run $BUILDTOOLS/build-gdbserver.sh "$SRC_DIR" "$NDK_DIR" "$GDB_TOOLCHAIN" "$GDB_VERSION" $FLAGS - fail_panic "Could not build $GDB_TOOLCHAIN gdb-server!" - done + if [ "$GCC_VERSION" == "default" ]; then + GDB_TOOLCHAIN=$(get_default_toolchain_name_for_arch $ARCH) + elif [ ! -z "$GCC_VERSION" ]; then + GDB_TOOLCHAIN=$(get_toolchain_name_for_arch $ARCH $GCC_VERSION) + fi + GDB_VERSION="--gdb-version="$(get_default_gdb_version_for_gcc $GDB_TOOLCHAIN) + dump "Building $GDB_TOOLCHAIN gdbserver binaries..." + run $BUILDTOOLS/build-gdbserver.sh "$SRC_DIR" "$NDK_DIR" "$GDB_TOOLCHAIN" "$GDB_VERSION" $FLAGS + fail_panic "Could not build $GDB_TOOLCHAIN gdb-server!" done FLAGS=$FLAGS" --ndk-dir=\"$NDK_DIR\"" ABIS=$(convert_archs_to_abis $ARCHS) UNKNOWN_ABIS=$(convert_archs_to_abis $UNKNOWN_ARCH) -dump "Building $ABIS compiler-rt binaries..." -run $BUILDTOOLS/build-compiler-rt.sh --abis="$ABIS" $FLAGS --src-dir="$SRC_DIR/llvm-$DEFAULT_LLVM_VERSION/compiler-rt" \ - --llvm-version=$DEFAULT_LLVM_VERSION -fail_panic "Could not build compiler-rt!" +if [ ! -z "$LLVM_VERSION" ]; then + dump "Building $ABIS compiler-rt binaries..." + run $BUILDTOOLS/build-compiler-rt.sh --abis="$ABIS" $FLAGS --src-dir="$SRC_DIR/llvm-$LLVM_VERSION/compiler-rt" $BUILD_TOOLCHAIN + fail_panic "Could not build compiler-rt!" +fi dump "Building $ABIS gabi++ binaries..." -run $BUILDTOOLS/build-cxx-stl.sh --stl=gabi++ --abis="$ABIS" $FLAGS --with-debug-info +run $BUILDTOOLS/build-cxx-stl.sh --stl=gabi++ --abis="$ABIS" $FLAGS --with-debug-info $BUILD_TOOLCHAIN fail_panic "Could not build gabi++ with debug info!" dump "Building $ABIS $UNKNOWN_ABIS stlport binaries..." -run $BUILDTOOLS/build-cxx-stl.sh --stl=stlport --abis="$ABIS,$UNKNOWN_ABIS" $FLAGS --with-debug-info +run $BUILDTOOLS/build-cxx-stl.sh --stl=stlport --abis="$ABIS,$UNKNOWN_ABIS" $FLAGS --with-debug-info $BUILD_TOOLCHAIN fail_panic "Could not build stlport with debug info!" dump "Building $ABIS $UNKNOWN_ABIS libc++ binaries... with libc++abi" -run $BUILDTOOLS/build-cxx-stl.sh --stl=libc++-libc++abi --abis="$ABIS,$UNKNOWN_ABIS" $FLAGS --with-debug-info --llvm-version=$DEFAULT_LLVM_VERSION +run $BUILDTOOLS/build-cxx-stl.sh --stl=libc++-libc++abi --abis="$ABIS,$UNKNOWN_ABIS" $FLAGS --with-debug-info $BUILD_TOOLCHAIN fail_panic "Could not build libc++ with libc++abi and debug info!" # workaround issues in libc++/libc++abi for x86 and mips @@ -133,9 +171,7 @@ for abi in $ABIS; do case $abi in x86|x86_64|mips|mips64) dump "Rebuilding $abi libc++ binaries... with gabi++" - run $BUILDTOOLS/build-cxx-stl.sh --stl=libc++-gabi++ --abis=$abi $FLAGS --with-debug-info --llvm-version=$DEFAULT_LLVM_VERSION - fail_panic "Could not build libc++ with gabi++ and debug info!" - ;; + run $BUILDTOOLS/build-cxx-stl.sh --stl=libc++-gabi++ --abis=$abi $FLAGS --with-debug-info $BUILD_TOOLCHAIN esac done @@ -143,14 +179,20 @@ if [ ! -z $VISIBLE_LIBGNUSTL_STATIC ]; then GNUSTL_STATIC_VIS_FLAG=--visible-libgnustl-static fi -dump "Building $ABIS gnustl binaries..." -run $BUILDTOOLS/build-gnu-libstdc++.sh --abis="$ABIS" $FLAGS $GNUSTL_STATIC_VIS_FLAG "$SRC_DIR" -fail_panic "Could not build gnustl!" -run $BUILDTOOLS/build-gnu-libstdc++.sh --abis="$ABIS" $FLAGS $GNUSTL_STATIC_VIS_FLAG "$SRC_DIR" --with-debug-info -fail_panic "Could not build gnustl with debug info!" +if [ ! -z "$GCC_VERSION_LIST" ]; then + STDCXX_GCC_VERSIONS= + if [ "$GCC_VERSION_LIST" != "default" ]; then + STDCXX_GCC_VERSIONS="--gcc-version-list=$GCC_VERSION_LIST" + fi + dump "Building $ABIS gnustl binaries..." + run $BUILDTOOLS/build-gnu-libstdc++.sh --abis="$ABIS" $FLAGS $GNUSTL_STATIC_VIS_FLAG "$SRC_DIR" $STDCXX_GCC_VERSIONS + fail_panic "Could not build gnustl!" + run $BUILDTOOLS/build-gnu-libstdc++.sh --abis="$ABIS" $FLAGS $GNUSTL_STATIC_VIS_FLAG "$SRC_DIR" --with-debug-info $STDCXX_GCC_VERSIONS + fail_panic "Could not build gnustl with debug info!" +fi dump "Building $ABIS libportable binaries..." -run $BUILDTOOLS/build-libportable.sh --abis="$ABIS" $FLAGS +run $BUILDTOOLS/build-libportable.sh --abis="$ABIS" $FLAGS $BUILD_TOOLCHAIN fail_panic "Could not build libportable!" if [ "$PACKAGE_DIR" ]; then diff --git a/build/tools/dev-defaults.sh b/build/tools/dev-defaults.sh index 44a664150..025b4c697 100644 --- a/build/tools/dev-defaults.sh +++ b/build/tools/dev-defaults.sh @@ -205,11 +205,12 @@ get_default_toolchain_prefix_for_arch () # Get the list of all toolchain names for a given architecture # $1: architecture (e.g. 'arm') +# $2: comma separated versions (optional) # Out: list of toolchain names for this arch (e.g. arm-linux-androideabi-4.6 arm-linux-androideabi-4.8) # Return empty for unknown arch get_toolchain_name_list_for_arch () { - local PREFIX VERSION RET ADD DEFAULT_GCC_VERSION + local PREFIX VERSION RET ADD DEFAULT_GCC_VERSION VERSIONS PREFIX=$(eval echo \"\$DEFAULT_ARCH_TOOLCHAIN_NAME_$1\") if [ -z "$PREFIX" ]; then return 0 @@ -217,7 +218,13 @@ get_toolchain_name_list_for_arch () RET="" DEFAULT_GCC_VERSION=$(get_default_gcc_version_for_arch $1) ADD="" - for VERSION in $DEFAULT_GCC_VERSION_LIST; do + VERSIONS=$(commas_to_spaces $2) + if [ -z "$VERSIONS" ]; then + VERSIONS=$DEFAULT_GCC_VERSION_LIST + else + ADD="yes" # include everything we passed explicitly + fi + for VERSION in $VERSIONS; do if [ -z "$ADD" -a "$VERSION" = "$DEFAULT_GCC_VERSION" ]; then ADD="yes" fi diff --git a/build/tools/gen-platforms.sh b/build/tools/gen-platforms.sh index 55ec69c88..2f7982c43 100755 --- a/build/tools/gen-platforms.sh +++ b/build/tools/gen-platforms.sh @@ -76,7 +76,7 @@ OPTION_ARCH= OPTION_ABI= OPTION_DEBUG_LIBS= OPTION_OVERLAY= -OPTION_GCC_VERSION= +OPTION_GCC_VERSION="default" OPTION_LLVM_VERSION=$DEFAULT_LLVM_VERSION PACKAGE_DIR= @@ -380,13 +380,13 @@ get_default_compiler_for_arch() break; fi done - EXTRA_CFLAGS="-emit-llvm" + EXTRA_CFLAGS= else - if [ -n "$OPTION_GCC_VERSION" ]; then - GCC_VERSION=$OPTION_GCC_VERSION - elif [ "$ARCH" = "mips" ]; then + if [ "$ARCH" = "mips" ]; then # Support for mips32r6 in the new multilib mipsel-* toolchain is only available from 4.9 GCC_VERSION=4.9 + elif [ -n "$OPTION_GCC_VERSION" -a "$OPTION_GCC_VERSION" != "default" ]; then + GCC_VERSION=$OPTION_GCC_VERSION else GCC_VERSION=$(get_default_gcc_version_for_arch $ARCH) fi diff --git a/build/tools/rebuild-all-prebuilt.sh b/build/tools/rebuild-all-prebuilt.sh index 0ce65bc8a..36f789c97 100755 --- a/build/tools/rebuild-all-prebuilt.sh +++ b/build/tools/rebuild-all-prebuilt.sh @@ -117,8 +117,12 @@ if [ "$GCC_VERSION_LIST" != "default" ]; then fi HOST_FLAGS=$HOST_FLAGS" --llvm-version-list=$(spaces_to_commas $LLVM_VERSION_LIST)" +TARGET_FLAGS=$FLAGS + if [ "$TRY64" = "yes" ]; then HOST_FLAGS=$HOST_FLAGS" --try-64" + # If we build only 64-bit host we need to use this flag as well so that correct toolchain is found on target tools build + TARGET_FLAGS=$TARGET_FLAGS" --try-64" fi if [ "$DARWIN_SSH" ]; then HOST_FLAGS=$HOST_FLAGS" --darwin-ssh=$DARWIN_SSH" @@ -133,7 +137,29 @@ echo "COMMAND: $PROGDIR/build-host-prebuilts.sh $HOST_FLAGS $SRC_DIR" $PROGDIR/build-host-prebuilts.sh $HOST_FLAGS "$SRC_DIR" fail_panic "Could not build host prebuilts!" -TARGET_FLAGS=$FLAGS +if [ ! -z "$LLVM_VERSION_LIST" ]; then + LLVM_VERSIONS=$(commas_to_spaces $LLVM_VERSION_LIST) + LLVM_VERSION=${LLVM_VERSIONS%% *} + TARGET_FLAGS=$TARGET_FLAGS" --llvm-version=$LLVM_VERSION" + if [ "$GCC_VERSION_LIST" != "default" ]; then + for ARCH in $(commas_to_spaces $ARCHS); do + if [ "$ARCH" != "${ARCH%%64*}" ] ; then + if [ "${GCC_VERSION_LIST%%$DEFAULT_LLVM_GCC64_VERSION*}" = "$GCC_VERSION_LIST" ]; then + echo "ERROR: LLVM $LLVM_VERSION require GCC $DEFAULT_LLVM_GCC64_VERSION for $ARCH to be available. Try to include it in build list." + exit 1 + fi + else + if [ "${GCC_VERSION_LIST%%$DEFAULT_LLVM_GCC32_VERSION*}" = "$GCC_VERSION_LIST" ]; then + echo "ERROR: LLVM $LLVM_VERSION require GCC $DEFAULT_LLVM_GCC32_VERSION for $ARCH to be available. Try to include it in build list." + exit 1 + fi + fi + done + fi +fi +if [ "$GCC_VERSION_LIST" != "default" ]; then + TARGET_FLAGS=$TARGET_FLAGS" --gcc-version-list=$(spaces_to_commas $GCC_VERSION_LIST)" +fi echo "COMMAND: $PROGDIR/build-target-prebuilts.sh $TARGET_FLAGS $SRC_DIR" $PROGDIR/build-target-prebuilts.sh $TARGET_FLAGS "$SRC_DIR" |