diff options
author | Dan Albert <danalbert@google.com> | 2018-02-05 16:35:31 -0800 |
---|---|---|
committer | Dan Albert <danalbert@google.com> | 2018-02-12 13:54:00 -0800 |
commit | a511ded040ac6c61325d8066599a3beb417ef83a (patch) | |
tree | 674936e0572781bf403dcd2bb542bafc553afb72 | |
parent | 8d17d6e15ed3a8e1c16c668153d12e8f5d97cac3 (diff) | |
download | external_libcxx-a511ded040ac6c61325d8066599a3beb417ef83a.tar.gz external_libcxx-a511ded040ac6c61325d8066599a3beb417ef83a.tar.bz2 external_libcxx-a511ded040ac6c61325d8066599a3beb417ef83a.zip |
Don't use libandroid_support for modern API levels.ndk-r17-beta2ndk-r17-beta1ndk-r17
If we're targeting a new enough platform version, we don't actually
need to cover any gaps in libc for libc++ support. In those cases,
save size in the APK by avoiding libandroid_support.
This is also a requirement for static executables, since using
libandroid_support with a modern libc.a will result in multiple symbol
definition errors.
Test: ndk/checkbuild.py && ndk/run_tests.py
Bug: https://github.com/android-ndk/ndk/issues/272
Change-Id: I4cb76272dc7271a02cba46d3cc20a369a16ff39d
(cherry picked from commit db08a420b9b812321691180e97da1a3facc7391e)
-rw-r--r-- | Android.mk | 43 | ||||
-rw-r--r-- | utils/libcxx/ndk/test/config.py | 14 |
2 files changed, 36 insertions, 21 deletions
diff --git a/Android.mk b/Android.mk index cfb43f2b1..11c161423 100644 --- a/Android.mk +++ b/Android.mk @@ -88,14 +88,18 @@ include $(CLEAR_VARS) LOCAL_MODULE := c++_static LOCAL_SRC_FILES := libs/$(TARGET_ARCH_ABI)/lib$(LOCAL_MODULE)$(TARGET_LIB_EXTENSION) LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes) - -# This doesn't affect the prebuilt itself since this is a prebuilt library, but -# the build system needs to know about the dependency so we can sort the -# exported includes properly. -LOCAL_STATIC_LIBRARIES := libc++abi libandroid_support +LOCAL_STATIC_LIBRARIES := libc++abi LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags) LOCAL_EXPORT_LDFLAGS := $(libcxx_export_ldflags) -LOCAL_EXPORT_STATIC_LIBRARIES := libc++abi libandroid_support +LOCAL_EXPORT_STATIC_LIBRARIES := libc++abi + +ifeq ($(NDK_PLATFORM_NEEDS_ANDROID_SUPPORT),true) + # This doesn't affect the prebuilt itself since this is a prebuilt library, + # but the build system needs to know about the dependency so we can sort the + # exported includes properly. + LOCAL_STATIC_LIBRARIES += libandroid_support + LOCAL_EXPORT_STATIC_LIBRARIES += libandroid_support +endif # We use the LLVM unwinder for 32-bit ARM. ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) @@ -110,13 +114,16 @@ LOCAL_EXPORT_C_INCLUDES := \ $(libcxx_export_includes) \ $(libcxxabi_c_includes) \ -# This doesn't affect the prebuilt itself since this is a prebuilt library, but -# the build system needs to know about the dependency so we can sort the -# exported includes properly. -LOCAL_STATIC_LIBRARIES := libandroid_support LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags) LOCAL_EXPORT_LDFLAGS := $(libcxx_export_ldflags) -LOCAL_EXPORT_STATIC_LIBRARIES := libandroid_support + +ifeq ($(NDK_PLATFORM_NEEDS_ANDROID_SUPPORT),true) + # This doesn't affect the prebuilt itself since this is a prebuilt library, + # but the build system needs to know about the dependency so we can sort the + # exported includes properly. + LOCAL_STATIC_LIBRARIES := libandroid_support + LOCAL_EXPORT_STATIC_LIBRARIES := libandroid_support +endif # We use the LLVM unwinder for 32-bit ARM. ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) @@ -124,7 +131,7 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) endif include $(PREBUILT_SHARED_LIBRARY) -ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI))) +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) # We define this module here rather than in a separate cxx-stl/libunwind because # we don't actually want to make the API available (yet). include $(CLEAR_VARS) @@ -150,10 +157,14 @@ LOCAL_CPP_FEATURES := rtti exceptions LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes) LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags) LOCAL_EXPORT_LDFLAGS := $(libcxx_export_ldflags) -LOCAL_STATIC_LIBRARIES := libc++abi android_support +LOCAL_STATIC_LIBRARIES := libc++abi + +ifeq ($(NDK_PLATFORM_NEEDS_ANDROID_SUPPORT),true) + LOCAL_STATIC_LIBRARIES += android_support +endif # We use the LLVM unwinder for all the 32-bit ARM targets. -ifneq (,$(filter armeabi%,$(TARGET_ARCH_ABI))) +ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) LOCAL_STATIC_LIBRARIES += libunwind LOCAL_EXPORT_STATIC_LIBRARIES += libunwind endif @@ -166,7 +177,9 @@ LOCAL_WHOLE_STATIC_LIBRARIES := c++_static libc++abi LOCAL_EXPORT_C_INCLUDES := $(libcxx_export_includes) LOCAL_EXPORT_CPPFLAGS := $(libcxx_export_cxxflags) LOCAL_EXPORT_LDFLAGS := $(libcxx_export_ldflags) -LOCAL_STATIC_LIBRARIES := android_support +ifeq ($(NDK_PLATFORM_NEEDS_ANDROID_SUPPORT),true) + LOCAL_STATIC_LIBRARIES := android_support +endif LOCAL_LDFLAGS := $(libcxx_ldflags) # Use --as-needed to strip the DT_NEEDED on libstdc++.so (bionic's) that the # driver always links for C++ but we don't use. diff --git a/utils/libcxx/ndk/test/config.py b/utils/libcxx/ndk/test/config.py index 3e4bb8535..7b351bfae 100644 --- a/utils/libcxx/ndk/test/config.py +++ b/utils/libcxx/ndk/test/config.py @@ -56,7 +56,7 @@ class Configuration(libcxx.test.config.Configuration): super(Configuration, self).configure_compile_flags() arch = self.get_lit_conf('arch') - api = self.get_lit_conf('api') + api = int(self.get_lit_conf('api')) sysroot = os.path.join(os.environ['NDK'], 'sysroot') self.cxx.compile_flags.extend(['--sysroot', sysroot]) @@ -77,15 +77,16 @@ class Configuration(libcxx.test.config.Configuration): '-mthumb', ]) - android_support_headers = os.path.join( - os.environ['NDK'], 'sources/android/support/include') - self.cxx.compile_flags.append('-I' + android_support_headers) + if api < 21: + android_support_headers = os.path.join( + os.environ['NDK'], 'sources/android/support/include') + self.cxx.compile_flags.append('-I' + android_support_headers) def configure_link_flags(self): self.cxx.link_flags.append('-nodefaultlibs') arch = self.get_lit_conf('arch') - api = self.get_lit_conf('api') + api = int(self.get_lit_conf('api')) sysroot_path = 'platforms/android-{}/arch-{}'.format(api, arch) platform_sysroot = os.path.join(os.environ['NDK'], sysroot_path) @@ -100,7 +101,8 @@ class Configuration(libcxx.test.config.Configuration): self.cxx.link_flags.append('-gcc-toolchain') self.cxx.link_flags.append(gcc_toolchain) - self.cxx.link_flags.append('-landroid_support') + if api < 21: + self.cxx.link_flags.append('-landroid_support') triple = self.get_lit_conf('target_triple') if triple.startswith('arm-') or triple.startswith('armv7-'): self.cxx.link_flags.append('-lunwind') |