Commit f9c49812 authored by Andrew Hsieh's avatar Andrew Hsieh Committed by android code review
Browse files

Merge "Change default GCC to 4.6; Build separate gnu-libstdc++ for GCC 4.4.3 and GCC 4.6"

parents 1187032f 0136e540
......@@ -242,7 +242,7 @@ endif
#
ifneq (,$(call module-has-c++-features,$(LOCAL_MODULE),rtti exceptions))
ifeq (system,$(NDK_APP_STL))
LOCAL_LDLIBS := $(LOCAL_LDLIBS) $(call host-path,$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/$(TARGET_ARCH_ABI)/libsupc++.a)
LOCAL_LDLIBS := $(LOCAL_LDLIBS) $(call host-path,$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libsupc++.a)
endif
endif
......
......@@ -92,6 +92,7 @@ TARGET_PREBUILT_SHARED_LIBRARIES :=
# Define default values for TOOLCHAIN_NAME, this can be overriden in
# the setup file.
TOOLCHAIN_NAME := $(TARGET_TOOLCHAIN)
TOOLCHAIN_VERSION := $(call last,$(subst -,$(space),$(TARGET_TOOLCHAIN)))
# Define the root path of the toolchain in the NDK tree.
TOOLCHAIN_ROOT := $(NDK_ROOT)/toolchains/$(TOOLCHAIN_NAME)
......
......@@ -39,7 +39,7 @@ By default, this will try with the current NDK directory, unless
you use the --ndk-dir=<path> option.
The output will be placed in appropriate sub-directories of
<ndk>/$GNUSTL_SUBDIR, but you can override this with the --out-dir=<path>
<ndk>/$GNUSTL_SUBDIR/<gcc-version>, but you can override this with the --out-dir=<path>
option.
"
......@@ -73,18 +73,6 @@ extract_parameters "$@"
SRCDIR=$(echo $PARAMETERS | sed 1q)
check_toolchain_src_dir "$SRCDIR"
GNUSTL_SRCDIR=$SRCDIR/gcc/gcc-$DEFAULT_GCC_VERSION/libstdc++-v3
if [ ! -d "$GNUSTL_SRCDIR" ]; then
echo "ERROR: Not a valid toolchain source tree."
echo "Can't find: $GNUSTL_SRCDIR"
exit 1
fi
if [ ! -f "$GNUSTL_SRCDIR/configure" ]; then
echo "ERROR: Configure script missing: $GNUSTL_SRCDIR/configure"
exit 1
fi
ABIS=$(commas_to_spaces $ABIS)
# Handle NDK_DIR
......@@ -109,14 +97,16 @@ fail_panic "Could not create build directory: $BUILD_DIR"
# $1: ABI name
# $2: Build directory
# $3: "static" or "shared"
# $4: Destination directory (optional, will default to $GNUSTL_SUBDIR/lib/$ABI)
# $4: GCC version
# $5: Destination directory (optional, will default to $GNUSTL_SUBDIR/<gcc-version>/lib/$ABI)
build_gnustl_for_abi ()
{
local ARCH BINPREFIX SYSROOT
local ARCH BINPREFIX SYSROOT GNUSTL_SRCDIR
local ABI=$1
local BUILDDIR="$2"
local LIBTYPE="$3"
local DSTDIR="$4"
local GCC_VERSION="$4"
local DSTDIR="$5"
local SRC OBJ OBJECTS CFLAGS CXXFLAGS
prepare_target_build $ABI $PLATFORM $NDK_DIR
......@@ -127,14 +117,27 @@ build_gnustl_for_abi ()
# If the output directory is not specified, use default location
if [ -z "$DSTDIR" ]; then
DSTDIR=$NDK_DIR/$GNUSTL_SUBDIR/libs/$ABI
DSTDIR=$NDK_DIR/$GNUSTL_SUBDIR/$GCC_VERSION/libs/$ABI
fi
mkdir -p $DSTDIR
ARCH=$(convert_abi_to_arch $ABI)
BINPREFIX=$NDK_DIR/$(get_default_toolchain_binprefix_for_arch $ARCH)
SYSROOT=$NDK_DIR/$(get_default_platform_sysroot_for_arch $ARCH)
BINPREFIX=$NDK_DIR/$(get_toolchain_binprefix_for_arch $ARCH $GCC_VERSION)
GNUSTL_SRCDIR=$SRCDIR/gcc/gcc-$GCC_VERSION/libstdc++-v3
# Sanity check
if [ ! -d "$GNUSTL_SRCDIR" ]; then
echo "ERROR: Not a valid toolchain source tree."
echo "Can't find: $GNUSTL_SRCDIR"
exit 1
fi
if [ ! -f "$GNUSTL_SRCDIR/configure" ]; then
echo "ERROR: Configure script missing: $GNUSTL_SRCDIR/configure"
exit 1
fi
SYSROOT=$NDK_DIR/$(get_default_platform_sysroot_for_arch $ARCH)
# Sanity check
if [ ! -f "$SYSROOT/usr/lib/libc.a" ]; then
echo "ERROR: Empty sysroot! you probably need to run gen-platforms.sh before this script."
......@@ -189,7 +192,7 @@ build_gnustl_for_abi ()
#LDFLAGS=$LDFLAGS" -lsupc++"
fi
PROJECT="gnustl_$LIBTYPE $ABI"
PROJECT="gnustl_$LIBTYPE gcc-$GCC_VERSION $ABI"
echo "$PROJECT: configuring"
mkdir -p $BUILDDIR && rm -rf $BUILDDIR/* &&
cd $BUILDDIR &&
......@@ -204,7 +207,7 @@ build_gnustl_for_abi ()
--disable-sjlj-exceptions \
--disable-tls \
--disable-libstdcxx-pch \
--with-gxx-include-dir=$INSTALLDIR/include/c++/$DEFAULT_GCC_VERSION
--with-gxx-include-dir=$INSTALLDIR/include/c++/$GCC_VERSION
fail_panic "Could not configure $PROJECT"
......@@ -222,30 +225,32 @@ HAS_COMMON_HEADERS=
# $1: ABI
# $2: Build directory
# $3: GCC_VERSION
copy_gnustl_libs ()
{
local ABI="$1"
local BUILDDIR="$2"
local ARCH=$(convert_abi_to_arch $ABI)
local VERSION=$DEFAULT_GCC_VERSION
local GCC_VERSION="$3"
local PREFIX=$(get_default_toolchain_prefix_for_arch $ARCH)
PREFIX=${PREFIX%%-}
local SDIR="$BUILDDIR/install"
local DDIR="$NDK_DIR/$GNUSTL_SUBDIR"
local DDIR="$NDK_DIR/$GNUSTL_SUBDIR/$GCC_VERSION"
# Copy the common headers only the first time this function is called.
if [ -z "$HAS_COMMON_HEADERS" ]; then
copy_directory "$SDIR/include/c++/$VERSION" "$DDIR/include"
local GCC_VERSION_NO_DOT=$(echo $GCC_VERSION|sed 's/\./_/g')
# Copy the common headers only once per gcc version
if [ -z `var_value HAS_COMMON_HEADERS_$GCC_VERSION_NO_DOT` ]; then
copy_directory "$SDIR/include/c++/$GCC_VERSION" "$DDIR/include"
rm -rf "$DDIR/include/$PREFIX"
HAS_COMMON_HEADERS=true
eval HAS_COMMON_HEADERS_$GCC_VERSION_NO_DOT=true
fi
rm -rf "$DIR/libs/$ABI" &&
mkdir -p "$DDIR/libs/$ABI/include"
# Copy the ABI-specific headers
copy_directory "$SDIR/include/c++/$VERSION/$PREFIX/bits" "$DDIR/libs/$ABI/include/bits"
copy_directory "$SDIR/include/c++/$GCC_VERSION/$PREFIX/bits" "$DDIR/libs/$ABI/include/bits"
# Copy the ABI-specific libraries
# Note: the shared library name is libgnustl_shared.so due our custom toolchain patch
......@@ -256,29 +261,33 @@ copy_gnustl_libs ()
for ABI in $ABIS; do
build_gnustl_for_abi $ABI "$BUILD_DIR" static
build_gnustl_for_abi $ABI "$BUILD_DIR" shared
copy_gnustl_libs $ABI "$BUILD_DIR"
for VERSION in $DEFAULT_GCC_VERSION_LIST; do
for ABI in $ABIS; do
build_gnustl_for_abi $ABI "$BUILD_DIR" static $VERSION
build_gnustl_for_abi $ABI "$BUILD_DIR" shared $VERSION
copy_gnustl_libs $ABI "$BUILD_DIR" $VERSION
done
done
# If needed, package files into tarballs
if [ -n "$PACKAGE_DIR" ] ; then
# First, the headers as a single package
PACKAGE="$PACKAGE_DIR/gnu-libstdc++-headers.tar.bz2"
dump "Packaging: $PACKAGE"
pack_archive "$PACKAGE" "$NDK_DIR" "$GNUSTL_SUBDIR/include"
# Then, one package per ABI for libraries
for ABI in $ABIS; do
FILES=""
for LIB in include/bits libsupc++.a libgnustl_static.a libgnustl_shared.so; do
FILES="$FILES $GNUSTL_SUBDIR/libs/$ABI/$LIB"
done
PACKAGE="$PACKAGE_DIR/gnu-libstdc++-libs-$ABI.tar.bz2"
for VERSION in $DEFAULT_GCC_VERSION_LIST; do
# First, the headers as a single package for a given gcc version
PACKAGE="$PACKAGE_DIR/gnu-libstdc++-headers-$VERSION.tar.bz2"
dump "Packaging: $PACKAGE"
pack_archive "$PACKAGE" "$NDK_DIR" "$FILES"
fail_panic "Could not package $ABI STLport binaries!"
pack_archive "$PACKAGE" "$NDK_DIR" "$GNUSTL_SUBDIR/$VERSION/include"
# Then, one package per version/ABI for libraries
for ABI in $ABIS; do
FILES=""
for LIB in include/bits libsupc++.a libgnustl_static.a libgnustl_shared.so; do
FILES="$FILES $GNUSTL_SUBDIR/$VERSION/libs/$ABI/$LIB"
done
PACKAGE="$PACKAGE_DIR/gnu-libstdc++-libs-$VERSION-$ABI.tar.bz2"
dump "Packaging: $PACKAGE"
pack_archive "$PACKAGE" "$NDK_DIR" "$FILES"
fail_panic "Could not package $ABI STLport binaries!"
done
done
fi
......
......@@ -40,9 +40,10 @@ rm -rf $DIR/prebuilt
# Remove prebuilt binaries
rm -rf $DIR/$STLPORT_SUBDIR/libs
rm -rf $DIR/$GNUSTL_SUBDIR/include
rm -rf $DIR/$GNUSTL_SUBDIR/libs
rm -rf $DIR/$GABIXX_SUBDIR/libs
for VERSION in $DEFAULT_GCC_VERSION_LIST; do
rm -rf $DIR/$GNUSTL_SUBDIR/$VERSION
done
rm -f $DIR/ndk-stack*
......
......@@ -26,7 +26,7 @@ GNUSTL_SUBDIR=sources/cxx-stl/gnu-libstdc++
TOOLCHAIN_GIT_DATE=2012-06-30
# The space-separated list of all GCC versions we support in this NDK
DEFAULT_GCC_VERSION_LIST="4.4.3 4.6"
DEFAULT_GCC_VERSION_LIST="4.6 4.4.3"
# The default GCC version for this NDK, i.e. the first item in
# $DEFAULT_GCC_VERSION_LIST
......@@ -110,11 +110,20 @@ get_default_abis_for_arch ()
echo "$RET"
}
# Return the default name for a given architecture
# Return toolchain name for given architecture and GCC version
# $1: Architecture name (e.g. 'arm')
# $2: GCC version (e.g. '4.6ʼ)
# Out: default arch-specific toolchain name (e.g. 'arm-linux-androideabi-$GCC_VERSION')
# Return empty for unknown arch
get_toolchain_name_for_arch ()
{
eval echo \"\${DEFAULT_ARCH_TOOLCHAIN_NAME_$1}-$2\"
}
# Return the default toolchain name for a given architecture
# $1: Architecture name (e.g. 'arm')
# Out: default arch-specific toolchain name (e.g. 'arm-linux-androideabi-$DEFAULT_GCC_VERSION')
# Return empty for unknown arch
get_default_toolchain_name_for_arch ()
{
eval echo \"\${DEFAULT_ARCH_TOOLCHAIN_NAME_$1}-$DEFAULT_GCC_VERSION\"
......
......@@ -165,7 +165,7 @@ run copy_directory_nolinks "$SRC_SYSROOT" "$TMPDIR/sysroot"
dump "Copying libstdc++ headers and libraries..."
GNUSTL_DIR=$NDK_DIR/$GNUSTL_SUBDIR
GNUSTL_DIR=$NDK_DIR/$GNUSTL_SUBDIR/$GCC_VERSION
GNUSTL_LIBS=$GNUSTL_DIR/libs
ABI_STL="$TMPDIR/$ABI_CONFIGURE_TARGET"
......
......@@ -337,11 +337,15 @@ if [ -z "$PREBUILT_NDK" ]; then
unpack_prebuilt $ARCH-gdbserver.tar.bz2 "$REFERENCE"
done
# Unpack C++ runtimes
unpack_prebuilt gnu-libstdc++-headers.tar.bz2 "$REFERENCE"
for VERSION in $DEFAULT_GCC_VERSION_LIST; do
unpack_prebuilt gnu-libstdc++-headers-$VERSION.tar.bz2 "$REFERENCE"
done
for ABI in $ABIS; do
unpack_prebuilt gabixx-libs-$ABI.tar.bz2 "$REFERENCE"
unpack_prebuilt stlport-libs-$ABI.tar.bz2 "$REFERENCE"
unpack_prebuilt gnu-libstdc++-libs-$ABI.tar.bz2 "$REFERENCE"
for VERSION in $DEFAULT_GCC_VERSION_LIST; do
unpack_prebuilt gnu-libstdc++-libs-$VERSION-$ABI.tar.bz2 "$REFERENCE"
done
done
fi
......@@ -387,9 +391,11 @@ for SYSTEM in $SYSTEMS; do
echo "WARNING: Could not find STLport source tree!"
fi
copy_prebuilt "$GNUSTL_SUBDIR/include" "$GNUSTL_SUBDIR"
for STL_ABI in $PREBUILT_ABIS; do
copy_prebuilt "$GNUSTL_SUBDIR/libs/$STL_ABI" "$GNUSTL_SUBDIR/libs"
for VERSION in $DEFAULT_GCC_VERSION_LIST; do
copy_prebuilt "$GNUSTL_SUBDIR/$VERSION/include" "$GNUSTL_SUBDIR/$VERSION/"
for STL_ABI in $PREBUILT_ABIS; do
copy_prebuilt "$GNUSTL_SUBDIR/$VERSION/libs/$STL_ABI" "$GNUSTL_SUBDIR/$VERSION/libs"
done
done
else
# Unpack gdbserver
......
......@@ -1036,21 +1036,31 @@ convert_archs_to_abis ()
echo "$RET"
}
# Return the default binary path prefix for a given architecture
# For example: arm -> toolchains/arm-linux-androideabi-4.4.3/prebuilt/<system>/bin/arm-linux-androideabi-
# Return the default toolchain binary path prefix for given architecture and gcc version
# For example: arm 4.6 -> toolchains/arm-linux-androideabi-4.6/prebuilt/<system>/bin/arm-linux-androideabi-
# $1: Architecture name
# $2: optional, system name, defaults to $HOST_TAG
get_default_toolchain_binprefix_for_arch ()
# $2: GCC version
# $3: optional, system name, defaults to $HOST_TAG
get_toolchain_binprefix_for_arch ()
{
local NAME PREFIX DIR BINPREFIX
local SYSTEM=${2:-$(get_prebuilt_host_tag)}
NAME=$(get_default_toolchain_name_for_arch $1)
local SYSTEM=${3:-$(get_prebuilt_host_tag)}
NAME=$(get_toolchain_name_for_arch $1 $2)
PREFIX=$(get_default_toolchain_prefix_for_arch $1)
DIR=$(get_toolchain_install . $NAME $SYSTEM)
BINPREFIX=${DIR#./}/bin/$PREFIX-
echo "$BINPREFIX"
}
# Return the default toochain binary path prefix for a given architecture
# For example: arm -> toolchains/arm-linux-androideabi-4.6/prebuilt/<system>/bin/arm-linux-androideabi-
# $1: Architecture name
# $2: optional, system name, defaults to $HOST_TAG
get_default_toolchain_binprefix_for_arch ()
{
get_toolchain_binprefix_for_arch $1 $DEFAULT_GCC_VERSION $2
}
# Return default API level for a given arch
# This is the level used to build the toolchains.
#
......
......@@ -9,19 +9,19 @@ gnustl_exported_cppflags := $(strip \
$(if $(filter rtti,$(APP_GNUSTL_FORCE_CPP_FEATURES)),-frtti))
# Include path to export
gnustl_exported_c_includes := $(LOCAL_PATH)/include $(LOCAL_PATH)/libs/$(TARGET_ARCH_ABI)/include
gnustl_exported_c_includes := $(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/include $(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/include
include $(CLEAR_VARS)
LOCAL_MODULE := gnustl_static
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libgnustl_static.a
LOCAL_SRC_FILES := $(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libgnustl_static.a
LOCAL_EXPORT_CPPFLAGS := $(gnustl_exported_cppflags)
LOCAL_EXPORT_C_INCLUDES := $(gnustl_exported_c_includes)
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := gnustl_shared
LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/libgnustl_shared.so
LOCAL_SRC_FILES := $(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libgnustl_shared.so
LOCAL_EXPORT_CPPFLAGS := $(gnustl_exported_cppflags)
LOCAL_EXPORT_C_INCLUDES := $(gnustl_exported_c_includes)
LOCAL_EXPORT_LDLIBS := $(call host-path,$(LOCAL_PATH)/libs/$(TARGET_ARCH_ABI)/libsupc++.a)
LOCAL_EXPORT_LDLIBS := $(call host-path,$(LOCAL_PATH)/$(TOOLCHAIN_VERSION)/libs/$(TARGET_ARCH_ABI)/libsupc++.a)
include $(PREBUILT_SHARED_LIBRARY)
......@@ -226,10 +226,13 @@ STLPORT_LIBS=$NDK/sources/cxx-stl/stlport/libs/armeabi-v7a
check_armv7_elf_binary $STLPORT_LIBS/libstlport_shared.so
check_armv7_elf_binary $STLPORT_LIBS/libstlport_static.a
GNUSTL_LIBS=$NDK/sources/cxx-stl/gnu-libstdc++/libs/armeabi-v7a
check_armv7_elf_binary $GNUSTL_LIBS/libsupc++.a
check_armv7_elf_binary $GNUSTL_LIBS/libgnustl_shared.so
check_armv7_elf_binary $GNUSTL_LIBS/libgnustl_static.a
. $NDK/build/tools/dev-defaults.sh
for VERSION in $DEFAULT_GCC_VERSION_LIST; do
GNUSTL_LIBS=$NDK/sources/cxx-stl/gnu-libstdc++/$VERSION/libs/armeabi-v7a
check_armv7_elf_binary $GNUSTL_LIBS/libsupc++.a
check_armv7_elf_binary $GNUSTL_LIBS/libgnustl_shared.so
check_armv7_elf_binary $GNUSTL_LIBS/libgnustl_static.a
done
echo "Done!"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment