Merge "build-host-gcc.sh: enable libgomp where possible (ARM > 4.4.3)"
diff --git a/build/core/build-binary.mk b/build/core/build-binary.mk
index 379c323..66ff928 100644
--- a/build/core/build-binary.mk
+++ b/build/core/build-binary.mk
@@ -239,9 +239,9 @@
#
LOCAL_OBJECTS := $(LOCAL_SRC_FILES)
$(foreach _ext,$(all_source_extensions),\
- $(eval LOCAL_OBJECTS := $$(LOCAL_OBJECTS:%$(_ext)=%.o))\
+ $(eval LOCAL_OBJECTS := $$(LOCAL_OBJECTS:%$(_ext)=%$$(TARGET_OBJ_EXTENSION)))\
)
-LOCAL_OBJECTS := $(filter %.o,$(LOCAL_OBJECTS))
+LOCAL_OBJECTS := $(filter %$(TARGET_OBJ_EXTENSION),$(LOCAL_OBJECTS))
LOCAL_OBJECTS := $(subst ../,__/,$(LOCAL_OBJECTS))
LOCAL_OBJECTS := $(foreach _obj,$(LOCAL_OBJECTS),$(LOCAL_OBJS_DIR)/$(_obj))
@@ -259,7 +259,7 @@
#
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++/$(TOOLCHAIN_VERSION)/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++$(TARGET_LIB_EXTENSION))
endif
endif
diff --git a/build/core/build-shared-library.mk b/build/core/build-shared-library.mk
index 159aebb..f2e98f8 100644
--- a/build/core/build-shared-library.mk
+++ b/build/core/build-shared-library.mk
@@ -27,7 +27,7 @@
# we are building target objects
my := TARGET_
-$(call handle-module-filename,lib,.so)
+$(call handle-module-filename,lib,$(TARGET_SONAME_EXTENSION))
$(call handle-module-built)
LOCAL_MODULE_CLASS := SHARED_LIBRARY
diff --git a/build/core/build-static-library.mk b/build/core/build-static-library.mk
index cab3758..be30e74 100644
--- a/build/core/build-static-library.mk
+++ b/build/core/build-static-library.mk
@@ -26,7 +26,7 @@
# we are building target objects
my := TARGET_
-$(call handle-module-filename,lib,.a)
+$(call handle-module-filename,lib,$(TARGET_LIB_EXTENSION))
$(call handle-module-built)
LOCAL_MODULE_CLASS := STATIC_LIBRARY
diff --git a/build/core/default-build-commands.mk b/build/core/default-build-commands.mk
index 1f1c230..79e2c6b 100644
--- a/build/core/default-build-commands.mk
+++ b/build/core/default-build-commands.mk
@@ -123,3 +123,7 @@
TARGET_ARFLAGS := crs
TARGET_STRIP = $(TOOLCHAIN_PREFIX)strip
+
+TARGET_OBJ_EXTENSION := .o
+TARGET_LIB_EXTENSION := .a
+TARGET_SONAME_EXTENSION := .so
diff --git a/build/core/definitions.mk b/build/core/definitions.mk
index 8b8d5a0..8e3aaf0 100644
--- a/build/core/definitions.mk
+++ b/build/core/definitions.mk
@@ -1002,7 +1002,7 @@
$(call __ndk_info,$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain spaces)\
$(call __ndk_error,Plase correct error. Aborting)\
)\
- $(if $(filter %.a %.so,$(LOCAL_MODULE_FILENAME)),\
+ $(if $(filter %$(TARGET_LIB_EXTENSION) %$(TARGET_SONAME_EXTENSION),$(LOCAL_MODULE_FILENAME)),\
$(call __ndk_info,$(LOCAL_MAKEFILE):$(LOCAL_MODULE): LOCAL_MODULE_FILENAME should not include file extensions)\
)\
)
@@ -1029,7 +1029,7 @@
$$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain any space)
$$(call __ndk_error,Aborting)
endif
-ifneq (,$$(filter %.a %.so,$$(LOCAL_MODULE_FILENAME)))
+ifneq (,$$(filter %$$(TARGET_LIB_EXTENSION) %$$(TARGET_SONAME_EXTENSION),$$(LOCAL_MODULE_FILENAME)))
$$(call __ndk_info,$$(LOCAL_MAKEFILE):$$(LOCAL_MODULE): LOCAL_MODULE_FILENAME must not contain a file extension)
$$(call __ndk_error,Aborting)
endif
@@ -1067,8 +1067,8 @@
LOCAL_MODULE_FILENAME := $$(strip $$(LOCAL_MODULE_FILENAME))
ifndef LOCAL_MODULE_FILENAME
LOCAL_MODULE_FILENAME := $$(notdir $(LOCAL_SRC_FILES))
- LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%.a=%)
- LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%.so=%)
+ LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%$$(TARGET_LIB_EXTENSION)=%)
+ LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME:%$$(TARGET_SONAME_EXTENSION)=%)
endif
LOCAL_MODULE_FILENAME := $$(LOCAL_MODULE_FILENAME)$1
$$(eval $$(call ev-check-module-filename))
@@ -1333,7 +1333,7 @@
$(subst ../,__/,\
$(eval __obj := $1)\
$(foreach __ext,.c .s .S $(LOCAL_CPP_EXTENSION),\
- $(eval __obj := $(__obj:%$(__ext)=%.o))\
+ $(eval __obj := $(__obj:%$(__ext)=%$(TARGET_OBJ_EXTENSION)))\
)\
$(__obj)\
))
@@ -1445,8 +1445,8 @@
_ORG_FLAGS := $$(_FLAGS)
_ORG_TEXT := $$(_TEXT)
- _OBJ_ASM_ORIGINAL := $$(patsubst %.o,%.s,$$(_ORG_OBJ))
- _OBJ_ASM_FILTERED := $$(patsubst %.o,%.filtered.s,$$(_ORG_OBJ))
+ _OBJ_ASM_ORIGINAL := $$(patsubst %$$(TARGET_OBJ_EXTENSION),%.s,$$(_ORG_OBJ))
+ _OBJ_ASM_FILTERED := $$(patsubst %$$(TARGET_OBJ_EXTENSION),%.filtered.s,$$(_ORG_OBJ))
# If the source file is a plain assembler file, we're going to
# use it directly in our filter.
@@ -1723,12 +1723,12 @@
# static libraries:
# <foo> -> lib<foo>.a by default
-$(call module-class-register,STATIC_LIBRARY,lib,.a)
+$(call module-class-register,STATIC_LIBRARY,lib,$(TARGET_LIB_EXTENSION))
# shared libraries:
# <foo> -> lib<foo>.so
# a shared library is installable.
-$(call module-class-register-installable,SHARED_LIBRARY,lib,.so)
+$(call module-class-register-installable,SHARED_LIBRARY,lib,$(TARGET_SONAME_EXTENSION))
# executable
# <foo> -> <foo>
diff --git a/build/core/prebuilt-library.mk b/build/core/prebuilt-library.mk
index 91e8f3c..4c7d93d 100644
--- a/build/core/prebuilt-library.mk
+++ b/build/core/prebuilt-library.mk
@@ -47,7 +47,7 @@
# If LOCAL_MODULE_FILENAME is defined, it will be used to name the file
# in the TARGET_OUT directory, and then the installation one. Note that
-# if shouldn't have an .a or .so extension nor contain directory separators.
+# it shouldn't have an .a or .so extension nor contain directory separators.
#
# If the variable is not defined, we determine its value from LOCAL_SRC_FILES
#
diff --git a/build/core/prebuilt-shared-library.mk b/build/core/prebuilt-shared-library.mk
index afe5e4b..77ccb11 100644
--- a/build/core/prebuilt-shared-library.mk
+++ b/build/core/prebuilt-shared-library.mk
@@ -22,6 +22,6 @@
LOCAL_MAKEFILE := $(local-makefile)
LOCAL_PREBUILT_PREFIX := lib
-LOCAL_PREBUILT_SUFFIX := .so
+LOCAL_PREBUILT_SUFFIX := $(TARGET_SONAME_EXTENSION)
include $(BUILD_SYSTEM)/prebuilt-library.mk
diff --git a/build/core/prebuilt-static-library.mk b/build/core/prebuilt-static-library.mk
index 26087c3..07d981b 100644
--- a/build/core/prebuilt-static-library.mk
+++ b/build/core/prebuilt-static-library.mk
@@ -22,7 +22,7 @@
LOCAL_MAKEFILE := $(local-makefile)
LOCAL_PREBUILT_PREFIX := lib
-LOCAL_PREBUILT_SUFFIX := .a
+LOCAL_PREBUILT_SUFFIX := $(TARGET_LIB_EXTENSION)
# Prebuilt static libraries don't need to be copied to TARGET_OUT
# to facilitate debugging, so use the prebuilt version directly
diff --git a/build/core/setup-app.mk b/build/core/setup-app.mk
index c972bbc..1e27dc3 100644
--- a/build/core/setup-app.mk
+++ b/build/core/setup-app.mk
@@ -72,7 +72,7 @@
ifeq ($(NDK_APP.$(_app).cleaned_binaries),)
NDK_APP.$(_app).cleaned_binaries := true
clean-installed-binaries::
- $(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_PROJECT_PATH)/libs/%/lib*.so))
+ $(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_PROJECT_PATH)/libs/%/lib*$(TARGET_SONAME_EXTENSION)))
$(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_PROJECT_PATH)/libs/%/gdbserver))
$(hide) $(call host-rm,$(NDK_ALL_ABIS:%=$(NDK_APP_PROJECT_PATH)/libs/%/gdb.setup))
endif
diff --git a/build/core/setup-toolchain.mk b/build/core/setup-toolchain.mk
index 978c4c8..6397772 100644
--- a/build/core/setup-toolchain.mk
+++ b/build/core/setup-toolchain.mk
@@ -66,6 +66,10 @@
# TARGET_TOOLCHAIN_BASE will be 'foo-bar-zoo'
#
TARGET_TOOLCHAIN_BASE := $(subst $(space),-,$(call chop,$(subst -,$(space),$(TARGET_TOOLCHAIN))))
+ # if TARGET_TOOLCHAIN_BASE is llvm, remove clang from NDK_TOOLCHAIN_VERSION
+ ifeq ($(TARGET_TOOLCHAIN_BASE),llvm)
+ NDK_TOOLCHAIN_VERSION := $(subst clang,,$(NDK_TOOLCHAIN_VERSION))
+ endif
TARGET_TOOLCHAIN := $(TARGET_TOOLCHAIN_BASE)-$(NDK_TOOLCHAIN_VERSION)
$(call ndk_log,Using target toolchain '$(TARGET_TOOLCHAIN)' for '$(TARGET_ARCH_ABI)' ABI (through NDK_TOOLCHAIN_VERSION))
else
@@ -144,6 +148,7 @@
NDK_APP_GDBSETUP := $(NDK_APP_DST_DIR)/gdb.setup
ifeq ($(NDK_APP_DEBUGGABLE),true)
+ifeq ($(TARGET_SONAME_EXTENSION),.so)
installed_modules: $(NDK_APP_GDBSERVER)
@@ -173,6 +178,7 @@
# This prevents parallel execution to clear gdb.setup after it has been written to
$(NDK_APP_GDBSETUP): clean-installed-binaries
endif
+endif
# free the dictionary of LOCAL_MODULE definitions
$(call modules-clear)
diff --git a/build/tools/build-analyzer.sh b/build/tools/build-analyzer.sh
index d56c3d9..05e9871 100755
--- a/build/tools/build-analyzer.sh
+++ b/build/tools/build-analyzer.sh
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-# This shell script is used to copy clang tool "scan-build"
+# This shell script is used to copy clang tool "scan-build" and "scan-view"
# for the Android NDK.
#
@@ -56,6 +56,12 @@
exit 1
fi
+ SCAN_VIEW_SRC_DIR=$SRC_DIR/$TOOLCHAIN/clang/tools/scan-view
+ if [ ! -d "$SCAN_VIEW_SRC_DIR" ] ; then
+ echo "ERROR: Source directory does not contain scan-view: $SCAN_VIEW_SRC_DIR"
+ exit 1
+ fi
+
LICENSE_FILE=$SRC_DIR/$TOOLCHAIN/clang/LICENSE.TXT
if [ ! -f "$LICENSE_FILE" ] ; then
echo "ERROR: Source directory does not contain clang license file: $LICENSE_FILE"
@@ -93,18 +99,20 @@
fail_panic "Could not create package directory: $PACKAGE_DIR"
fi
-# copy scan_build
+# copy scan_build and scan_view
SCAN_BUILD_SUBDIR="prebuilt/common/scan-build"
run copy_directory "$SCAN_BUILD_SRC_DIR" "$NDK_DIR/$SCAN_BUILD_SUBDIR"
cp -p "$LICENSE_FILE" "$NDK_DIR/$SCAN_BUILD_SUBDIR"
-
-# remove unneeded file(s)
rm -f $NDK_DIR/$SCAN_BUILD_SUBDIR/scan-build.1
+SCAN_VIEW_SUBDIR="prebuilt/common/scan-view"
+run copy_directory "$SCAN_VIEW_SRC_DIR" "$NDK_DIR/$SCAN_VIEW_SUBDIR"
+cp -p "$LICENSE_FILE" "$NDK_DIR/$SCAN_VIEW_SUBDIR"
+
if [ "$PACKAGE_DIR" ]; then
- ARCHIVE="scan-build.tar.bz2"
+ ARCHIVE="scan-build-view.tar.bz2"
dump "Packaging $ARCHIVE"
- pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SCAN_BUILD_SUBDIR"
+ pack_archive "$PACKAGE_DIR/$ARCHIVE" "$NDK_DIR" "$SCAN_BUILD_SUBDIR" "$SCAN_VIEW_SUBDIR"
fi
dump "Done."
diff --git a/build/tools/build-host-gcc.sh b/build/tools/build-host-gcc.sh
index a2157ef..d6d8250 100755
--- a/build/tools/build-host-gcc.sh
+++ b/build/tools/build-host-gcc.sh
@@ -127,6 +127,9 @@
NDK_DIR=$ANDROID_NDK_ROOT
register_var_option "--ndk-dir=<path>" NDK_DIR "Select NDK install directory"
+BUILD_DIR=
+register_var_option "--build-dir=<path>" BUILD_DIR "Build GCC into directory"
+
PACKAGE_DIR=
register_var_option "--package-dir=<path>" PACKAGE_DIR "Package prebuilt tarballs into directory"
@@ -174,6 +177,10 @@
panic "Please use --toolchain-src-dir=<path> to select toolchain source directory."
fi
+if [ -z "$BUILD_DIR" ]; then
+ BUILD_DIR=/tmp/ndk-$USER/build/host-gcc
+fi
+
case $DEFAULT_LD in
gold|bfd)
;;
@@ -451,7 +458,6 @@
setup_build ()
{
- BUILD_DIR=/tmp/ndk-$USER/build/host-gcc
run_on_setup mkdir -p "$BUILD_DIR"
if [ -n "$FORCE" ]; then
rm -rf "$BUILD_DIR"/*
@@ -489,17 +495,6 @@
fi
}
-get_default_binutils_version_for_gcc ()
-{
- local RET
- case $1 in
- arm-*-4.4.3|x86-*-4.4.3|x86-4.4.3) RET=2.19;;
- *-4.6) RET=2.21;;
- *) RET=2.22;;
- esac
- echo "$RET"
-}
-
# Check that a given compiler generates code correctly
#
# This is to detect bad/broken toolchains, e.g. amd64-mingw32msvc
@@ -1262,16 +1257,11 @@
LD_NAME=$DEFAULT_LD
- # Enable Gold, for specific builds. The version before binutils 2.21
- # is buggy so don't use it
- case $HOST_OS in
- windows) BUILD_GOLD=;; # Gold doesn't compile on Windows!
- darwin) BUILD_GOLD=;; # Building Gold fails with an internal compiler error on Darwin!
- *) BUILD_GOLD=true;;
- esac
+ # Enable Gold globally. It can be built for all hosts.
+ BUILD_GOLD=true
- # Special case, gold in binutil-2.21 doesn't build when targetting mips
- if [ "$BINUTILS_VERSION" = "2.21" -a "$TARGET" = "mipsel-linux-android" ]; then
+ # Special case, gold is not ready for mips yet.
+ if [ "$TARGET" = "mipsel-linux-android" ]; then
BUILD_GOLD=
fi
@@ -1280,6 +1270,12 @@
#
if [ "$BINUTILS_VERSION" = "2.21" -a "$TARGET" = "i686-linux-android" ]; then
USE_LD_DEFAULT=true
+ BUILD_GOLD=
+ fi
+
+ # Another special case. Not or 2.19, it wasn't ready
+ if [ "$BINUTILS_VERSION" = "2.19" ]; then
+ BUILD_GOLD=
fi
if [ "$DEFAULT_LD" = "gold" -a -z "$BUILD_GOLD" ]; then
@@ -1299,6 +1295,7 @@
# The BFD linker is always built, but to build Gold, we need a specific
# option for the binutils configure script. Note that its format has
# changed during development.
+ export host_configargs=
if [ "$BUILD_GOLD" ]; then
# The syntax of the --enable-gold option has changed.
if version_is_greater_than $BINUTILS_VERSION 2.20; then
@@ -1314,11 +1311,19 @@
ARGS=$ARGS" --enable-gold=both/gold"
fi
fi
+ # This ARG needs quoting when passed to run2.
+ GOLD_LDFLAGS_ARG=
if [ "$HOST_OS" = 'windows' ]; then
# gold may have runtime dependency on libgcc_sjlj_1.dll and
# libstdc++-6.dll when built by newer versions of mingw.
# Link them statically to avoid that.
- ARGS=$ARGS" --with-gold-ldflags='-static-libgcc -static-libstdc++'"
+ if version_is_greater_than $BINUTILS_VERSION 2.22; then
+ export host_configargs="--with-gold-ldflags='-static-libgcc -static-libstdc++'"
+ elif version_is_greater_than $BINUTILS_VERSION 2.21; then
+ GOLD_LDFLAGS_ARG="--with-gold-ldflags=-static-libgcc -static-libstdc++"
+ else
+ export LDFLAGS=$LDFLAGS" -static-libgcc -static-libstdc++"
+ fi
fi
fi
diff --git a/build/tools/gen-platforms.sh b/build/tools/gen-platforms.sh
index 0ced51f..2fc7d8a 100755
--- a/build/tools/gen-platforms.sh
+++ b/build/tools/gen-platforms.sh
@@ -68,6 +68,7 @@
OPTION_ARCH=
OPTION_ABI=
OPTION_DEBUG_LIBS=
+OPTION_OVERLAY=
PACKAGE_DIR=
VERBOSE=no
@@ -118,6 +119,9 @@
--debug-libs)
OPTION_DEBUG_LIBS=true
;;
+ --overlay)
+ OPTION_OVERLAY=true
+ ;;
*)
echo "unknown option '$opt', use --help"
exit 1
@@ -565,7 +569,9 @@
# $SRC/android-$PLATFORM/arch-$ARCH/include --> $DST/android-$PLATFORM/arch-$ARCH/usr/include
# $SRC/android-$PLATFORM/arch-$ARCH/lib --> $DST/android-$PLATFORM/arch-$ARCH/usr/lib
#
-rm -rf $DSTDIR/platforms && mkdir -p $DSTDIR/platforms
+if [ -z "$OPTION_OVERLAY" ]; then
+ rm -rf $DSTDIR/platforms && mkdir -p $DSTDIR/platforms
+fi
for ARCH in $ARCHS; do
# Find first platform for this arch
PREV_SYSROOT_DST=
@@ -651,7 +657,9 @@
# $SRC/android-$PLATFORM/samples/ --> $DST/samples
#
dump "Copying generic samples"
- rm -rf $DSTDIR/samples && mkdir -p $DSTDIR/samples
+ if [ -z "OPTION_OVERLAY" ]; then
+ rm -rf $DSTDIR/samples && mkdir -p $DSTDIR/samples
+ fi
copy_src_directory samples samples samples
for PLATFORM in $PLATFORMS; do
diff --git a/build/tools/package-release.sh b/build/tools/package-release.sh
index b6f518b..9e80e80 100755
--- a/build/tools/package-release.sh
+++ b/build/tools/package-release.sh
@@ -456,7 +456,7 @@
fi
# Unpack other host tools
- unpack_prebuilt scan-build "$DSTDIR" "$DSTDIR64"
+ unpack_prebuilt scan-build-view "$DSTDIR" "$DSTDIR64"
# Create an archive for the final package. Extension depends on the
# host system.