Merge changes I152eb090,Ic40360bf

* changes:
  arm64: Fix the sdk_arm64 build products
  arm64: Fix aosp_arm64 system image.
diff --git a/core/binary.mk b/core/binary.mk
index 437361b..4162a12 100644
--- a/core/binary.mk
+++ b/core/binary.mk
@@ -133,12 +133,12 @@
 my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
 my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
 
-my_clang := $(LOCAL_CLANG)
+my_clang := $(strip $(LOCAL_CLANG))
 ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
-my_clang := $(LOCAL_CLANG_$(my_32_64_bit_suffix))
+my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
 endif
 ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
-my_clang := $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
+my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
 endif
 
 # clang is enabled by default for host builds
@@ -312,7 +312,7 @@
 endif
 
 ifeq ($(strip $(my_cc)),)
-  ifeq ($(strip $(my_clang)),true)
+  ifeq ($(my_clang),true)
     my_cc := $(CLANG)
   else
     my_cc := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CC)
@@ -328,7 +328,7 @@
 $(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
 
 ifeq ($(strip $(my_cxx)),)
-  ifeq ($(strip $(my_clang)),true)
+  ifeq ($(my_clang),true)
     my_cxx := $(CLANG_CXX)
   else
     my_cxx := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)CXX)
@@ -378,7 +378,7 @@
 # actually used (although they are usually empty).
 arm_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(arm_objects_mode)_CFLAGS)
 normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
-ifeq ($(strip $(my_clang)),true)
+ifeq ($(my_clang),true)
 arm_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(arm_objects_cflags))
 normal_objects_cflags := $(call $(LOCAL_2ND_ARCH_VAR_PREFIX)convert-to-$(my_host)clang-flags,$(normal_objects_cflags))
 endif
diff --git a/core/combo/include/arch/darwin-x86/AndroidConfig.h b/core/combo/include/arch/darwin-x86/AndroidConfig.h
index 44de4cd..db3f47f 100644
--- a/core/combo/include/arch/darwin-x86/AndroidConfig.h
+++ b/core/combo/include/arch/darwin-x86/AndroidConfig.h
@@ -42,12 +42,6 @@
 #define HAVE_PTHREADS
 
 /*
- * Do we have the futex syscall?
- */
-
-/* #define HAVE_FUTEX */
-
-/*
  * Process creation model.  Choose one:
  *
  * HAVE_FORKEXEC - use fork() and exec()
@@ -86,11 +80,6 @@
 #define  HAVE_TERMIO_H
 
 /*
- * Define this if you have <sys/sendfile.h>
- */
-/* #define  HAVE_SYS_SENDFILE_H 1 */
-
-/*
  * Define this if you build against MSVCRT.DLL
  */
 /* #define HAVE_MS_C_RUNTIME */
@@ -117,11 +106,6 @@
 /* #define HAVE_GETHOSTBYNAME_R */
 
 /*
- * Define this if we have ioctl().
- */
-/* #define HAVE_IOCTL */
-
-/*
  * Define this if we want to use WinSock.
  */
 /* #define HAVE_WINSOCK */
@@ -165,18 +149,6 @@
 #define HAVE_BACKTRACE 0
 
 /*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-/* #define HAVE_GETTID */
-
-
-/*
  * Add any extra platform-specific defines here.
  */
 #define _THREAD_SAFE
@@ -221,11 +193,6 @@
 #define OS_SHARED_LIB_FORMAT_STR    "lib%s.dylib"
 
 /*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
@@ -248,11 +215,6 @@
 #define HAVE_STRLCPY 1
 
 /*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
  * Define if the BSD funopen() function exists on the system.
  */
 #define HAVE_FUNOPEN 1
diff --git a/core/combo/include/arch/linux-arm/AndroidConfig.h b/core/combo/include/arch/linux-arm/AndroidConfig.h
index 0eb6c72..c2a2134 100644
--- a/core/combo/include/arch/linux-arm/AndroidConfig.h
+++ b/core/combo/include/arch/linux-arm/AndroidConfig.h
@@ -42,19 +42,6 @@
 #define HAVE_PTHREADS
 
 /*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
  * Process creation model.  Choose one:
  *
  * HAVE_FORKEXEC - use fork() and exec()
@@ -93,11 +80,6 @@
 #define  HAVE_TERMIO_H 1
 
 /*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
  * Define this if you build against MSVCRT.DLL
  */
 /* #define HAVE_MS_C_RUNTIME */
@@ -124,11 +106,6 @@
 /* #define HAVE_GETHOSTBYNAME_R */
 
 /*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
  * Define this if we want to use WinSock.
  */
 /* #define HAVE_WINSOCK */
@@ -173,17 +150,6 @@
  */
 #define HAVE_BACKTRACE 0
 
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
 /* 
  * Defined if we have the sched_setscheduler() call
  */
@@ -258,11 +224,6 @@
 #define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
 
 /*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
@@ -283,11 +244,6 @@
 #define HAVE_STRLCPY 1
 
 /*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
  * Define if the BSD funopen() function exists on the system.
  */
 #define HAVE_FUNOPEN 1
diff --git a/core/combo/include/arch/linux-arm64/AndroidConfig.h b/core/combo/include/arch/linux-arm64/AndroidConfig.h
index bcbda8f..93e034f 100644
--- a/core/combo/include/arch/linux-arm64/AndroidConfig.h
+++ b/core/combo/include/arch/linux-arm64/AndroidConfig.h
@@ -42,19 +42,6 @@
 #define HAVE_PTHREADS
 
 /*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
  * Process creation model.  Choose one:
  *
  * HAVE_FORKEXEC - use fork() and exec()
@@ -93,11 +80,6 @@
 #define  HAVE_TERMIO_H 1
 
 /*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
  * Define this if you build against MSVCRT.DLL
  */
 /* #define HAVE_MS_C_RUNTIME */
@@ -124,11 +106,6 @@
 /* #define HAVE_GETHOSTBYNAME_R */
 
 /*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
  * Define this if we want to use WinSock.
  */
 /* #define HAVE_WINSOCK */
@@ -169,17 +146,6 @@
 #define HAVE_BACKTRACE 0
 
 /*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
-/*
  * Defined if we have the sched_setscheduler() call
  */
 #define HAVE_SCHED_SETSCHEDULER
@@ -253,11 +219,6 @@
 #define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
 
 /*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
@@ -278,11 +239,6 @@
 #define HAVE_STRLCPY 1
 
 /*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
  * Define if the BSD funopen() function exists on the system.
  */
 #define HAVE_FUNOPEN 1
diff --git a/core/combo/include/arch/linux-mips/AndroidConfig.h b/core/combo/include/arch/linux-mips/AndroidConfig.h
index 076d711..4a0ddc1 100644
--- a/core/combo/include/arch/linux-mips/AndroidConfig.h
+++ b/core/combo/include/arch/linux-mips/AndroidConfig.h
@@ -42,19 +42,6 @@
 #define HAVE_PTHREADS
 
 /*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
  * Process creation model.  Choose one:
  *
  * HAVE_FORKEXEC - use fork() and exec()
@@ -93,11 +80,6 @@
 #define  HAVE_TERMIO_H 1
 
 /*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
  * Define this if you build against MSVCRT.DLL
  */
 /* #define HAVE_MS_C_RUNTIME */
@@ -124,11 +106,6 @@
 /* #define HAVE_GETHOSTBYNAME_R */
 
 /*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
  * Define this if we want to use WinSock.
  */
 /* #define HAVE_WINSOCK */
@@ -179,17 +156,6 @@
 #define HAVE_BACKTRACE 0
 
 /*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
-/*
  * Defined if we have the sched_setscheduler() call
  */
 #define HAVE_SCHED_SETSCHEDULER
@@ -275,11 +241,6 @@
 #define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
 
 /*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
@@ -300,11 +261,6 @@
 #define HAVE_STRLCPY 1
 
 /*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
  * Define if the BSD funopen() function exists on the system.
  */
 #define HAVE_FUNOPEN 1
diff --git a/core/combo/include/arch/linux-mips64/AndroidConfig.h b/core/combo/include/arch/linux-mips64/AndroidConfig.h
index 7ded3ce..eb2421a 100644
--- a/core/combo/include/arch/linux-mips64/AndroidConfig.h
+++ b/core/combo/include/arch/linux-mips64/AndroidConfig.h
@@ -42,19 +42,6 @@
 #define HAVE_PTHREADS
 
 /*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
  * Process creation model.  Choose one:
  *
  * HAVE_FORKEXEC - use fork() and exec()
@@ -93,11 +80,6 @@
 #define  HAVE_TERMIO_H 1
 
 /*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
  * Define this if you build against MSVCRT.DLL
  */
 /* #define HAVE_MS_C_RUNTIME */
@@ -124,11 +106,6 @@
 /* #define HAVE_GETHOSTBYNAME_R */
 
 /*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
  * Define this if we want to use WinSock.
  */
 /* #define HAVE_WINSOCK */
@@ -169,17 +146,6 @@
 #define HAVE_BACKTRACE 0
 
 /*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
-/*
  * Defined if we have the sched_setscheduler() call
  */
 #define HAVE_SCHED_SETSCHEDULER
@@ -265,11 +231,6 @@
 #define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
 
 /*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
@@ -290,11 +251,6 @@
 #define HAVE_STRLCPY 1
 
 /*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
  * Define if the BSD funopen() function exists on the system.
  */
 #define HAVE_FUNOPEN 1
diff --git a/core/combo/include/arch/linux-x86/AndroidConfig.h b/core/combo/include/arch/linux-x86/AndroidConfig.h
index ebb95b0..68dbee0 100644
--- a/core/combo/include/arch/linux-x86/AndroidConfig.h
+++ b/core/combo/include/arch/linux-x86/AndroidConfig.h
@@ -42,12 +42,6 @@
 #define HAVE_PTHREADS
 
 /*
- * Do we have the futex syscall?
- */
-
-#define HAVE_FUTEX
-
-/*
  * Process creation model.  Choose one:
  *
  * HAVE_FORKEXEC - use fork() and exec()
@@ -86,11 +80,6 @@
 #define  HAVE_TERMIO_H 1
 
 /*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
  * Define this if you build against MSVCRT.DLL
  */
 /* #define HAVE_MS_C_RUNTIME */
@@ -117,11 +106,6 @@
 #define HAVE_GETHOSTBYNAME_R
 
 /*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
  * Define this if we want to use WinSock.
  */
 /* #define HAVE_WINSOCK */
@@ -166,17 +150,6 @@
  */
 #define HAVE_BACKTRACE 1
 
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-/* #define HAVE_GETTID */
-
 /* 
  * Defined if we have the sched_setscheduler() call
  */
@@ -238,11 +211,6 @@
 #define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
 
 /*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
@@ -263,11 +231,6 @@
 /* #define HAVE_STRLCPY 1 */
 
 /*
- * Define if the open_memstream() function exists on the system.
- */
-#define HAVE_OPEN_MEMSTREAM 1
-
-/*
  * Define if the BSD funopen() function exists on the system.
  */
 /* #define HAVE_FUNOPEN 1 */
diff --git a/core/combo/include/arch/target_linux-x86/AndroidConfig.h b/core/combo/include/arch/target_linux-x86/AndroidConfig.h
index 5b56b51..25b5973 100644
--- a/core/combo/include/arch/target_linux-x86/AndroidConfig.h
+++ b/core/combo/include/arch/target_linux-x86/AndroidConfig.h
@@ -28,19 +28,6 @@
 #define HAVE_PTHREADS
 
 /*
- * Do we have pthread_setname_np()?
- *
- * (HAVE_PTHREAD_SETNAME_NP is used by WebKit to enable a function with
- * the same name but different parameters, so we can't use that here.)
- */
-#define HAVE_ANDROID_PTHREAD_SETNAME_NP
-
-/*
- * Do we have the futex syscall?
- */
-#define HAVE_FUTEX
-
-/*
  * Process creation model.  Choose one:
  *
  * HAVE_FORKEXEC - use fork() and exec()
@@ -79,11 +66,6 @@
 #define  HAVE_TERMIO_H 1
 
 /*
- * Define this if you have <sys/sendfile.h>
- */
-#define  HAVE_SYS_SENDFILE_H 1
-
-/*
  * Define this if you build against have Microsoft C runtime (MSVCRT.DLL)
  */
 /* #define HAVE_MS_C_RUNTIME */
@@ -110,11 +92,6 @@
 /* #define HAVE_GETHOSTBYNAME_R */
 
 /*
- * Define this if we have ioctl().
- */
-#define HAVE_IOCTL
-
-/*
  * Define this if we want to use WinSock.
  */
 /* #define HAVE_WINSOCK */
@@ -162,17 +139,6 @@
  */
 #define HAVE_BACKTRACE 0
 
-/*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
- * Defined if we have the gettid() system call.
- */
-#define HAVE_GETTID
-
 /* 
  * Defined if we have the sched_setscheduler() call
  */
@@ -247,11 +213,6 @@
 #define OS_SHARED_LIB_FORMAT_STR    "lib%s.so"
 
 /*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '/'
@@ -272,11 +233,6 @@
 #define HAVE_STRLCPY 1
 
 /*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
  * Define if the BSD funopen() function exists on the system.
  */
 #define HAVE_FUNOPEN 1
diff --git a/core/combo/include/arch/windows/AndroidConfig.h b/core/combo/include/arch/windows/AndroidConfig.h
index 0a52674..8aa9e7b 100644
--- a/core/combo/include/arch/windows/AndroidConfig.h
+++ b/core/combo/include/arch/windows/AndroidConfig.h
@@ -64,13 +64,6 @@
 #define HAVE_WIN32_THREADS
 
 /*
- * Do we have the futex syscall?
- */
-
-/* #define HAVE_FUTEX */
-
-
-/*
  * Process creation model.  Choose one:
  *
  * HAVE_FORKEXEC - use fork() and exec()
@@ -119,13 +112,6 @@
 #endif
 
 /*
- * Define this if you have <sys/sendfile.h>
- */
-#ifdef __CYGWIN__
-#  define  HAVE_SYS_SENDFILE_H 1
-#endif
-
-/*
  * Define this if you build against MSVCRT.DLL
  */
 #ifndef __CYGWIN__
@@ -151,11 +137,6 @@
 /* #define HAVE_GETHOSTBYNAME_R */
 
 /*
- * Define this if we have ioctl().
- */
-/* #define HAVE_IOCTL */
-
-/*
  * Define this if we want to use WinSock.
  */
 #ifndef __CYGWIN__
@@ -207,12 +188,6 @@
 #define HAVE_BACKTRACE 0
 
 /*
- * Defined if we have the cxxabi.h header for demangling C++ symbols.  If
- * not defined, stack crawls will be displayed with raw mangled symbols
- */
-#define HAVE_CXXABI 0
-
-/*
  * Define if tm struct has tm_gmtoff field
  */
 /* #define HAVE_TM_GMTOFF 1 */
@@ -258,11 +233,6 @@
 #define OS_SHARED_LIB_FORMAT_STR    "lib%s.dll"
 
 /*
- * type for the third argument to mincore().
- */
-#define MINCORE_POINTER_TYPE unsigned char *
-
-/*
  * The default path separator for the platform
  */
 #define OS_PATH_SEPARATOR '\\'
@@ -288,11 +258,6 @@
 /* #define HAVE_STRLCPY 1 */
 
 /*
- * Define if the open_memstream() function exists on the system.
- */
-/* #define HAVE_OPEN_MEMSTREAM 1 */
-
-/*
  * Define if the BSD funopen() function exists on the system.
  */
 /* #define HAVE_FUNOPEN 1 */
diff --git a/core/definitions.mk b/core/definitions.mk
index b5762e3..9b8a299 100644
--- a/core/definitions.mk
+++ b/core/definitions.mk
@@ -1176,7 +1176,7 @@
 
 # $(1): the full path of the source static library.
 define _extract-and-include-single-target-whole-static-lib
-@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]"
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(strip $(1))]"
 $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
     rm -rf $$ldir; \
     mkdir -p $$ldir; \
@@ -1190,8 +1190,16 @@
 
 endef
 
+# $(1): the full path of the source static library.
+define extract-and-include-whole-static-libs-first
+$(if $(strip $(1)),
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(strip $(1))]"
+$(hide) cp $(1) $@)
+endef
+
 define extract-and-include-target-whole-static-libs
-$(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
+$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
     $(call _extract-and-include-single-target-whole-static-lib, $(lib)))
 endef
 
@@ -1213,7 +1221,7 @@
 
 # $(1): the full path of the source static library.
 define _extract-and-include-single-host-whole-static-lib
-@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(1)]"
+@echo "preparing StaticLib: $(PRIVATE_MODULE) [including $(strip $(1))]"
 $(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
     rm -rf $$ldir; \
     mkdir -p $$ldir; \
@@ -1228,7 +1236,8 @@
 endef
 
 define extract-and-include-host-whole-static-libs
-$(foreach lib,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES), \
+$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)))
+$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
     $(call _extract-and-include-single-host-whole-static-lib, $(lib)))
 endef