From 4ac4231ca1eb2513bfd6bacd974a0aa190a76d2d Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 20 Jul 2016 11:02:18 -0700 Subject: [PATCH 1/3] Add LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES. This allows a module to avoid being installed to the common library directory. Test: Prevents copying of NDK libraries with the NDK sysroot patches. Bug: http://b/27533932 Change-Id: I24f11d5a70595bcd524ac5bd85034c226d2de211 --- core/clear_vars.mk | 1 + core/prebuilt_internal.mk | 15 ++++++++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/core/clear_vars.mk b/core/clear_vars.mk index 31b337a130..562a272605 100644 --- a/core/clear_vars.mk +++ b/core/clear_vars.mk @@ -199,6 +199,7 @@ LOCAL_NOTICE_FILE:= # to avoid installing the presigned apks with classes.dex unstripped. LOCAL_REPLACE_PREBUILT_APK_INSTALLED:= LOCAL_NDK_VERSION:=current +LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES:= LOCAL_LOGTAGS_FILES:= # arch specific variables diff --git a/core/prebuilt_internal.mk b/core/prebuilt_internal.mk index 90e9547b3a..701414a774 100644 --- a/core/prebuilt_internal.mk +++ b/core/prebuilt_internal.mk @@ -46,9 +46,18 @@ my_pack_module_relocations := $(firstword \ $(LOCAL_PACK_MODULE_RELOCATIONS)) ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)) - # Put the built targets of all shared libraries in a common directory - # to simplify the link line. - OVERRIDE_BUILT_MODULE_PATH := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES) + # LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES indicates that this prebuilt should be + # installed to the common directory of libraries. This is needed for the NDK + # shared libraries built by soong, as we build many different versions of each + # library (one for each API level). Since they all have the same basename, + # they'd clobber each other (as well as any platform libraries by the same + # name). + ifneq ($(LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES),false) + # Put the built targets of all shared libraries in a common directory + # to simplify the link line. + OVERRIDE_BUILT_MODULE_PATH := \ + $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES) + endif ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),) # Strip but not try to add debuglink my_strip_module := no_debuglink From 02bf138d64a09166f5fe16b6ea83adaf60fad185 Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Thu, 21 Jul 2016 10:04:12 -0700 Subject: [PATCH 2/3] Use the just built NDK headers and libs. The list of libraries is currently empty. Will add migrated libraries in a follow up patch. Test: Still builds. Bug: http://b/27533932 Change-Id: Ibd9750620ca2ae86fe888a8a993bd26493bc1c8a --- core/binary.mk | 58 +++++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 50 insertions(+), 8 deletions(-) diff --git a/core/binary.mk b/core/binary.mk index 41520c23a1..85d084f666 100644 --- a/core/binary.mk +++ b/core/binary.mk @@ -70,6 +70,9 @@ ifdef LOCAL_SDK_VERSION $(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module) endif + # Make sure we've built the NDK. + my_additional_dependencies += ndk + # mips32r6 is not supported by the NDK. No released NDK contains these # libraries, but the r10 in prebuilts/ndk had a local hack to add them :( # @@ -81,9 +84,31 @@ ifdef LOCAL_SDK_VERSION endif endif - my_ndk_source_root := $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources - my_ndk_sysroot := $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/platforms/android-$(LOCAL_SDK_VERSION)/arch-$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) - my_ndk_sysroot_include := $(my_ndk_sysroot)/usr/include + my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) + ifneq (,$(filter arm64 mips64 x86_64,$(my_arch))) + my_min_sdk_version := 21 + else + my_min_sdk_version := 9 + endif + + # Historically we've just set up a bunch of symlinks in prebuilts/ndk to map + # missing API levels to existing ones where necessary, but we're not doing + # that for the generated libraries. Clip the API level to the minimum where + # appropriate. + my_ndk_api := \ + $(shell if [ $(LOCAL_SDK_VERSION) -lt $(my_min_sdk_version) ]; then \ + echo $(my_min_sdk_version); else echo $(LOCAL_SDK_VERSION); fi) + + my_ndk_source_root := \ + $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources + my_ndk_sysroot := \ + $(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/platforms/android-$(my_ndk_api)/arch-$(my_arch) + my_built_ndk := $(SOONG_OUT_DIR)/ndk + my_ndk_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_TRIPLE) + my_ndk_sysroot_include := \ + $(my_built_ndk)/sysroot/usr/include \ + $(my_built_ndk)/sysroot/usr/include/$(my_ndk_triple) \ + $(my_ndk_sysroot)/usr/include \ # x86_64 and and mips64 are both multilib toolchains, so their libraries are # installed in /usr/lib64. Aarch64, on the other hand, is not a multilib @@ -92,14 +117,19 @@ ifdef LOCAL_SDK_VERSION # Mips32r6 is yet another variation, with libraries installed in libr6. # # For the rest, the libraries are installed simply to /usr/lib. - ifneq (,$(filter x86_64 mips64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))) - my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib64 + ifneq (,$(filter x86_64 mips64,$(my_arch))) + my_ndk_libdir_name := lib64 else ifeq (mips32r6,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH_VARIANT)) - my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/libr6 + my_ndk_libdir_name := libr6 else - my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib + my_ndk_libdir_name := lib endif + my_ndk_platform_dir := \ + $(my_built_ndk)/platforms/android-$(my_ndk_api)/arch-$(my_arch) + my_built_ndk_libs := $(my_ndk_platform_dir)/usr/$(my_ndk_libdir_name) + my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/$(my_ndk_libdir_name) + # The bionic linker now has support for packed relocations and gnu style # hashes (which are much faster!), but shipping to older devices requires # the old style hash. Fortunately, we can build with both and it'll work @@ -180,6 +210,11 @@ ifdef LOCAL_SDK_VERSION endif endif endif + + my_generated_ndk_shared_libraries := \ + $(filter $(NDK_MIGRATED_LIBS),$(my_system_shared_libraries)) + my_system_shared_libraries := \ + $(filter-out $(NDK_MIGRATED_LIBS),$(my_system_shared_libraries)) endif # MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because @@ -1365,7 +1400,14 @@ my_system_shared_libraries_fullpath := \ $(addprefix $(my_ndk_sysroot_lib)/, \ $(addsuffix $(so_suffix), $(my_system_shared_libraries))) -built_shared_libraries += $(my_system_shared_libraries_fullpath) +my_built_ndk_shared_libraries_fullpath := \ + $(addprefix $(my_built_ndk_libs)/,\ + $(addsuffix $(so_suffix),$(my_generated_ndk_shared_libraries))) + +built_shared_libraries += \ + $(my_built_ndk_shared_libraries_fullpath) \ + $(my_system_shared_libraries_fullpath) \ + else built_shared_libraries := \ $(addprefix $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATE_LIBRARIES)/, \ From c61174aac16995d9c56a5ee91e99c7df2d0f27df Mon Sep 17 00:00:00 2001 From: Dan Albert Date: Wed, 27 Jul 2016 21:57:49 -0700 Subject: [PATCH 3/3] Add a phony target for the NDK sysroots. `make ndk` will build all the NDK sysroots. Test: make ndk Bug: http://b/27533932 Change-Id: Ic2f5bf61f8911f7b8d08a473f2fe0576f3e06224 --- core/main.mk | 3 +++ 1 file changed, 3 insertions(+) diff --git a/core/main.mk b/core/main.mk index b99de492db..59e9524a9a 100644 --- a/core/main.mk +++ b/core/main.mk @@ -1125,4 +1125,7 @@ nothing: tidy_only: @echo Successfully make tidy_only. +ndk: $(SOONG_OUT_DIR)/ndk.timestamp +.PHONY: ndk + endif # KATI