提交 d410a832 编写于 作者: A Andrew Harp 提交者: TensorFlower Gardener

Android: make it possible to build TF with NDK 13+. The default compiler was...

Android: make it possible to build TF with NDK 13+. The default compiler was switched from gcc to clang in 13b, which introduced a number of small incompatibilities.

PiperOrigin-RevId: 167915928
上级 f5074379
......@@ -27,7 +27,6 @@ load("//tensorflow:workspace.bzl", "tf_workspace")
# path = "<PATH_TO_SDK>",
#)
#
# Android NDK r12b is recommended (higher may cause issues with Bazel)
#android_ndk_repository(
# name="androidndk",
# path="<PATH_TO_NDK>",
......
......@@ -79,6 +79,7 @@ cc_binary(
],
linkopts = if_android([
"-landroid",
"-ldl",
"-llog",
"-lm",
"-z defs",
......
......@@ -62,6 +62,7 @@ add_library(tensorflow_inference SHARED
# Include libraries needed for hello-jni lib
target_link_libraries(tensorflow_inference
android
dl
log
m
z
......
......@@ -243,6 +243,7 @@ ifeq ($(TARGET),ANDROID)
CXXFLAGS +=\
--sysroot $(NDK_ROOT)/platforms/android-21/arch-arm \
-Wno-narrowing \
-fomit-frame-pointer \
-march=armv7-a \
-mfloat-abi=softfp \
-mfpu=neon \
......@@ -267,7 +268,8 @@ $(TARGET_NSYNC_LIB) \
-lprotobuf \
-llog \
-lz \
-lm
-lm \
-ldl
LD := $(NDK_ROOT)/toolchains/arm-linux-androideabi-4.9/prebuilt/$(OS_PATH)-x86_64/arm-linux-androideabi/bin/ld
......
......@@ -29,6 +29,7 @@ cc_binary(
defines = ["STANDALONE_DEMO_LIB"],
linkopts = [
"-landroid",
"-ldl",
"-ljnigraphics",
"-llog",
"-lm",
......
......@@ -124,8 +124,8 @@ the Android NDK and SDK must be installed on your system.
1. Install the latest version of Bazel as per the instructions [on the Bazel
website](https://bazel.build/versions/master/docs/install.html).
2. The Android NDK is required to build the native (C/C++) TensorFlow code. The
current recommended version is 12b, which may be found
[here](https://developer.android.com/ndk/downloads/older_releases.html#ndk-12b-downloads).
current recommended version is 14b, which may be found
[here](https://developer.android.com/ndk/downloads/older_releases.html#ndk-14b-downloads).
3. The Android SDK and build tools may be obtained
[here](https://developer.android.com/tools/revisions/build-tools.html), or
alternatively as part of [Android
......
......@@ -167,11 +167,13 @@ def tf_copts():
"-fno-exceptions",
"-ftemplate-depth=900",
]) + if_cuda(["-DGOOGLE_CUDA=1"]) + if_mkl(["-DINTEL_MKL=1", "-fopenmp",]) + if_android_arm(
["-mfpu=neon", "-fomit-frame-pointer"]) + if_linux_x86_64(["-msse3"]) + select({
["-mfpu=neon"]) + if_linux_x86_64(["-msse3"]) + select({
clean_dep("//tensorflow:android"): [
"-std=c++11",
"-DTF_LEAN_BINARY",
"-O2",
"-Wno-narrowing",
"-fomit-frame-pointer",
],
clean_dep("//tensorflow:darwin"): [],
clean_dep("//tensorflow:windows"): WIN_COPTS,
......
......@@ -41,7 +41,7 @@ RUN cd ${ANDROID_DEV_HOME} && \
echo y | android update sdk --no-ui -a --filter tools,platform-tools,android-${ANDROID_API_LEVEL},build-tools-${ANDROID_BUILD_TOOLS_VERSION}
# Install Android NDK.
ENV ANDROID_NDK_FILENAME android-ndk-r12b-linux-x86_64.zip
ENV ANDROID_NDK_FILENAME android-ndk-r14b-linux-x86_64.zip
ENV ANDROID_NDK_URL https://dl.google.com/android/repository/${ANDROID_NDK_FILENAME}
ENV ANDROID_NDK_HOME ${ANDROID_DEV_HOME}/ndk
ENV PATH ${PATH}:${ANDROID_NDK_HOME}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册