Skip to content

Commit

Permalink
Fix API 30+ in ndk-build for LP64 ABIs.
Browse files Browse the repository at this point in the history
Test: Targeted API 30, saw compiler get API 30. Targeted API 16, saw
compiler get API 16 for LP32 and 21 for LP64. Once API 30 sysroot is
submitted I can also add a test that builds against API 30.
Bug: android/ndk#1201
Change-Id: I0183d5e803234b25993944df0de9c8c88e7e2004
  • Loading branch information
DanAlbert committed Mar 7, 2020
1 parent 5d2277d commit cf1601f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 16 deletions.
19 changes: 9 additions & 10 deletions build/core/setup-abi.mk
Original file line number Diff line number Diff line change
Expand Up @@ -26,17 +26,19 @@ endif

TARGET_OUT := $(NDK_APP_OUT)/$(_app)/$(TARGET_ARCH_ABI)

# For x86 and mips: the minimal platform level is android-9
TARGET_PLATFORM_SAVED := $(TARGET_PLATFORM)
TARGET_PLATFORM_LEVEL := $(APP_PLATFORM_LEVEL)

# For 64-bit ABIs: the minimal platform level is android-21
# 64-bit ABIs were first supported in API 21. Pull up these ABIs if the app has
# a lower minSdkVersion.
ifneq ($(filter $(NDK_KNOWN_DEVICE_ABI64S),$(TARGET_ARCH_ABI)),)
$(foreach _plat,3 4 5 8 9 10 11 12 13 14 15 16 17 18 19 20,\
$(eval TARGET_PLATFORM := $$(subst android-$(_plat),android-21,$$(TARGET_PLATFORM)))\
)
ifneq ($(call lt,$(TARGET_PLATFORM_LEVEL),21),)
TARGET_PLATFORM_LEVEL := 21
endif
endif

TARGET_PLATFORM_LEVEL := $(strip $(subst android-,,$(TARGET_PLATFORM)))
# Not used by ndk-build, but are documented for use by Android.mk files.
TARGET_PLATFORM := android-$(TARGET_PLATFORM_LEVEL)
TARGET_ABI := $(TARGET_PLATFORM)-$(TARGET_ARCH_ABI)

# 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
Expand Down Expand Up @@ -82,6 +84,3 @@ ifeq ($(TARGET_ARCH_ABI),x86_64)
endif

include $(BUILD_SYSTEM)/setup-toolchain.mk

# Restore TARGET_PLATFORM, see above.
TARGET_PLATFORM := $(TARGET_PLATFORM_SAVED)
3 changes: 0 additions & 3 deletions build/core/setup-app.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,6 @@ $(foreach __name,$(NDK_APP_VARS),\
ndk-app-$(_app): $(NDK_APP_MODULES)
all: ndk-app-$(_app)

# which platform/abi/toolchain are we going to use?
TARGET_PLATFORM := $(call get,$(_map),APP_PLATFORM)

# The ABI(s) to use
NDK_APP_ABI := $(subst $(comma),$(space),$(strip $(NDK_APP_ABI)))
ifndef NDK_APP_ABI
Expand Down
4 changes: 1 addition & 3 deletions build/core/setup-toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
# to setup the target toolchain for a given platform/abi combination.
#

$(call assert-defined,TARGET_PLATFORM TARGET_ARCH TARGET_ARCH_ABI)
$(call assert-defined,TARGET_PLATFORM_LEVEL TARGET_ARCH TARGET_ARCH_ABI)
$(call assert-defined,NDK_APPS NDK_APP_STL)

# Check that we have a toolchain that supports the current ABI.
Expand Down Expand Up @@ -61,8 +61,6 @@ else # NDK_TOOLCHAIN is not empty
TARGET_TOOLCHAIN := $(NDK_TOOLCHAIN)
endif # NDK_TOOLCHAIN is not empty

TARGET_ABI := $(TARGET_PLATFORM)-$(TARGET_ARCH_ABI)

TARGET_PREBUILT_SHARED_LIBRARIES :=

# Define default values for TOOLCHAIN_NAME, this can be overriden in
Expand Down
3 changes: 3 additions & 0 deletions docs/changelogs/Changelog-r21.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,11 @@ For Android Studio issues, follow the docs on the [Android Studio site].
debugging. The error from gdb that confirms you were affected by this was
`gdb-8.3/gdb/psymtab.c:316: internal-error: sect_index_text not initialized`.
* [Issue 1166]: Rehid unwinder symbols all architectures.
* [Issue 1201]: Fixed issue in ndk-build that was causing `APP_PLATFORM` to be
corrupted for API 30+ with LP64 ABIs.

[Issue 1166]: https://github.com/android/ndk/issues/1166
[Issue 1201]: https://github.com/android/ndk/issues/1201

## Changes

Expand Down

0 comments on commit cf1601f

Please sign in to comment.