forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[android] get lldb tests working against newer Android NDKs
Android introduced a unified tools layout in NDK r19 (2019) and removed the old layout in r22 (2021). Running lldb tests with NDK r22 or newer fails when compiling the test inferiors. This change updates `Android.rules` to match the newer unified tools structure introduced in NDK r19, which is described in more detail at android/ndk#780. NOTE: After this change, ONLY NDK r19c and later can be used when running the lldb tests. The pre-2019 NDK structure is no longer supported.
- Loading branch information
1 parent
296ffc1
commit 476a010
Showing
1 changed file
with
23 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,81 +1,49 @@ | ||
NDK_ROOT := $(shell dirname $(CC))/../../../../.. | ||
|
||
ifeq "$(findstring 64, $(ARCH))" "64" | ||
# lowest 64-bit API level | ||
API_LEVEL := 21 | ||
else ifeq "$(ARCH)" "i386" | ||
# clone(2) declaration is present only since this api level | ||
API_LEVEL := 17 | ||
ifeq "$(HOST_OS)" "Linux" | ||
HOST_TAG := linux-x86_64 | ||
else ifeq "$(HOST_OS)" "Darwin" | ||
HOST_TAG := darwin-x86_64 | ||
else | ||
# lowest supported 32-bit API level | ||
API_LEVEL := 16 | ||
HOST_TAG := windows-x86_64 | ||
endif | ||
|
||
ifeq "$(ARCH)" "arm" | ||
SYSROOT_ARCH := arm | ||
STL_ARCH := armeabi-v7a | ||
TRIPLE := armv7-none-linux-androideabi | ||
ARCH_CFLAGS += -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm | ||
else ifeq "$(ARCH)" "aarch64" | ||
SYSROOT_ARCH := arm64 | ||
STL_ARCH := arm64-v8a | ||
TRIPLE := aarch64-none-linux-android | ||
else ifeq "$(ARCH)" "i386" | ||
SYSROOT_ARCH := x86 | ||
STL_ARCH := x86 | ||
TRIPLE := i686-none-linux-android | ||
else | ||
SYSROOT_ARCH := $(ARCH) | ||
STL_ARCH := $(ARCH) | ||
TRIPLE := $(ARCH)-none-linux-android | ||
endif | ||
|
||
ifeq "$(findstring 86,$(ARCH))" "86" | ||
TOOLCHAIN_DIR := $(STL_ARCH)-4.9 | ||
else ifeq "$(ARCH)" "arm" | ||
TOOLCHAIN_DIR := arm-linux-androideabi-4.9 | ||
else | ||
TOOLCHAIN_DIR := $(subst -none,,$(TRIPLE))-4.9 | ||
endif | ||
TOOLCHAIN_SYSROOT := $(NDK_ROOT)/toolchains/llvm/prebuilt/$(HOST_TAG)/sysroot | ||
|
||
ifeq "$(ARCH)" "arm" | ||
TOOL_PREFIX := arm-linux-androideabi | ||
else | ||
TOOL_PREFIX := $(subst -none,,$(TRIPLE)) | ||
endif | ||
# lowest 64-bit API level | ||
API_LEVEL := 21 | ||
|
||
ifeq "$(HOST_OS)" "Linux" | ||
HOST_TAG := linux-x86_64 | ||
else ifeq "$(HOST_OS)" "Darwin" | ||
HOST_TAG := darwin-x86_64 | ||
ifeq "$(ARCH)" "arm" | ||
ARCH_DIR := arm-linux-androideabi | ||
else | ||
HOST_TAG := windows-x86_64 | ||
ARCH_DIR := $(subst -none,,$(TRIPLE)) | ||
endif | ||
|
||
GCC_TOOLCHAIN = $(NDK_ROOT)/toolchains/$(TOOLCHAIN_DIR)/prebuilt/$(HOST_TAG) | ||
|
||
OBJCOPY ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-objcopy | ||
ARCHIVER ?= $(GCC_TOOLCHAIN)/bin/$(TOOL_PREFIX)-ar | ||
|
||
ifeq "$(findstring clang,$(CC))" "clang" | ||
ARCH_CFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN) | ||
ARCH_LDFLAGS += -target $(TRIPLE) --gcc-toolchain=$(GCC_TOOLCHAIN) | ||
endif | ||
|
||
ARCH_CFLAGS += --sysroot=$(NDK_ROOT)/sysroot \ | ||
-isystem $(NDK_ROOT)/sysroot/usr/include/$(TOOL_PREFIX) \ | ||
-D__ANDROID_API__=$(API_LEVEL) \ | ||
-isystem $(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH)/usr/include | ||
|
||
ARCH_LDFLAGS += --sysroot=$(NDK_ROOT)/platforms/android-$(API_LEVEL)/arch-$(SYSROOT_ARCH) -lm | ||
ARCH_CFLAGS += \ | ||
--target=$(TRIPLE) \ | ||
--sysroot=$(TOOLCHAIN_SYSROOT) \ | ||
-D __ANDROID_API__=$(API_LEVEL) \ | ||
|
||
ARCH_CXXFLAGS += \ | ||
-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++/include \ | ||
-isystem $(NDK_ROOT)/sources/android/support/include \ | ||
-isystem $(NDK_ROOT)/sources/cxx-stl/llvm-libc++abi/include | ||
-isystem $(TOOLCHAIN_SYSROOT)/usr/include/c++/v1 \ | ||
|
||
ARCH_LDFLAGS += \ | ||
-L$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH) \ | ||
$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(STL_ARCH)/libc++_static.a \ | ||
--target=$(TRIPLE) \ | ||
--sysroot=$(TOOLCHAIN_SYSROOT) \ | ||
--prefix=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ | ||
--library-directory=$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/$(API_LEVEL) \ | ||
$(TOOLCHAIN_SYSROOT)/usr/lib/$(ARCH_DIR)/libc++_static.a \ | ||
-lm \ | ||
-lc++abi \ | ||
-nostdlib++ | ||
-nostdlib++ \ |