From b0cae77b2a49b66dc5df3c0d6b4e1aeb4ce9145d Mon Sep 17 00:00:00 2001 From: Alexey Pelykh Date: Thu, 24 Jan 2013 16:17:52 +0200 Subject: [PATCH] Android toolchain --- makefile | 41 +++++++++++++++++++++++++++++++++-------- src/arm.h | 4 ++++ src/posix.cpp | 16 ++++++++-------- 3 files changed, 45 insertions(+), 16 deletions(-) diff --git a/makefile b/makefile index ab9031331b..60b34a11f3 100755 --- a/makefile +++ b/makefile @@ -357,13 +357,34 @@ ifeq ($(platform),android) asm = arm pointer-size = 4 no-psabi = -Wno-psabi - toolchain = $(ANDROID_NDK)/toolchains/arm-linux-androideabi-4.7/prebuilt/linux-x86/ - cflags = -std=gnu++0x -I$(ANDROID_NDK)/platforms/android-5/arch-arm/usr/include \ - -I$(toolchain)/lib/gcc/arm-linux-androideabi/4.7/include $(common-cflags) - cflags += -marm $(no-psabi) + use-lto = false + ifeq ($(build-platform),cygwin) + ndk = "$$(cygpath -u "$(ANDROID_NDK)")" + else + ndk = $(ANDROID_NDK) + endif + + build-cflags = $(common-cflags) -I$(src) + ifeq ($(subst cygwin,windows,$(subst mingw32,windows,$(build-platform))),windows) + toolchain-host-platform = $(subst cygwin,windows,$(subst mingw32,windows,$(build-platform))) + build-system = windows + build-cxx = i686-w64-mingw32-g++ + build-cc = i686-w64-mingw32-gcc + build-lflags = -lz -lpthread + sysroot = "$$(cygpath -w "$(ndk)/platforms/android-5/arch-arm")" + build-cflags += "-I$(JAVA_HOME)/include/win32" + else + toolchain-host-platform = $(subst cygwin,windows,$(subst mingw32,windows,$(build-platform)))-$(build-arch) + sysroot = $(ndk)/platforms/android-5/arch-arm + build-cflags += "-I$(JAVA_HOME)/include/linux" + endif + toolchain = $(ndk)/toolchains/arm-linux-androideabi-4.7/prebuilt/$(toolchain-host-platform) + cflags = "-I$(sysroot)/usr/include" "-I$(JAVA_HOME)/include/linux" $(common-cflags) "-I$(src)" -std=c++11 -marm $(no-psabi) + lflags = $(common-lflags) -ldl + use-lto = false - cxx = $(toolchain)/bin/arm-linux-androideabi-g++ - cc = $(toolchain)/bin/arm-linux-androideabi-gcc + cxx = $(toolchain)/bin/arm-linux-androideabi-g++ --sysroot="$(sysroot)" + cc = $(toolchain)/bin/arm-linux-androideabi-gcc --sysroot="$(sysroot)" ar = $(toolchain)/bin/arm-linux-androideabi-ar ranlib = $(toolchain)/bin/arm-linux-androideabi-ranlib strip = $(toolchain)/bin/arm-linux-androideabi-strip @@ -540,7 +561,9 @@ ifeq ($(mode),fast) else optimization-cflags = -O3 -g3 -DNDEBUG endif - use-lto = true + ifeq ($(use-lto),) + use-lto = true + endif endif ifeq ($(mode),small) ifeq ($(use-clang),true) @@ -548,7 +571,9 @@ ifeq ($(mode),small) else optimization-cflags = -Os -g3 -DNDEBUG endif - use-lto = true + ifeq ($(use-lto),) + use-lto = true + endif endif ifeq ($(use-lto),true) diff --git a/src/arm.h b/src/arm.h index 15299ec762..7e7a4d61dd 100644 --- a/src/arm.h +++ b/src/arm.h @@ -98,6 +98,10 @@ loadMemoryBarrier() memoryBarrier(); } +#if defined(__ANDROID__) +// http://code.google.com/p/android/issues/detail?id=1803 +extern "C" void __clear_cache (void *beg __attribute__((__unused__)), void *end __attribute__((__unused__))); +#endif inline void syncInstructionCache(const void* start, unsigned size) { diff --git a/src/posix.cpp b/src/posix.cpp index c033956ad5..95c4286b60 100644 --- a/src/posix.cpp +++ b/src/posix.cpp @@ -17,16 +17,16 @@ # include "CoreFoundation/CoreFoundation.h" # include "sys/ucontext.h" # undef assert -#elif defined __ANDROID__ +#elif defined(__ANDROID__) # include /* for sigcontext */ # include /* for stack_t */ -typedef struct ucontext { - unsigned long uc_flags; - struct ucontext *uc_link; - stack_t uc_stack; - struct sigcontext uc_mcontext; - unsigned long uc_sigmask; -} ucontext_t; + typedef struct ucontext { + unsigned long uc_flags; + struct ucontext *uc_link; + stack_t uc_stack; + struct sigcontext uc_mcontext; + unsigned long uc_sigmask; + } ucontext_t; #else # if defined __FreeBSD__ # include "limits.h"