* Fix cmake detection in msys

* Fix toolchain file on windows

* Make android 64 bit work

* Fix libnd4j build script on msys

* Update build script for windows/linux

* Encoding issue for ci

* Update pom.xml

* Update pom.xml

* Update pom.xml

* Remove mingw

* Ensure android x86 builds are inline with arm builds

* Update toolchains and env variables for x86

* Move profile for build program up to parent

* Fix blas vendor and add comment

* Update cuda presets version

* Set default value and move properties back to child pom

* Change program from hard coded to use the script as the program

* Update pom.xml

* Update pom.xml

* Static lib fix

* Update static lib output

* Get rid of old comments

* Update static for buiding
master
Adam Gibson 2020-03-19 14:53:21 +09:00 committed by GitHub
parent 9c77bfa85f
commit 0cf4a45573
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 193 additions and 141 deletions

View File

@ -79,10 +79,11 @@ if(NOT SD_CUDA)
if ("${OPENBLAS_PATH}" STREQUAL "")
#we don't want OpenBLAS on Apple
if (NOT APPLE)
# note: this is not a typo
set(BLA_VENDOR "OpenBLAS")
endif()
# look around for system blas instead
# look around for system blas instead, see: https://cmake.org/cmake/help/latest/module/FindBLAS.html
find_package(BLAS REQUIRED)
if (BLAS_FOUND)
message("Found external BLAS implementation: ${BLAS_LIBRARIES} ")
@ -91,6 +92,7 @@ if(NOT SD_CUDA)
else()
# if we have externally provided OPENBLAS_PATH - let's use it
set(HAVE_OPENBLAS 1)
message("Setting openblas")
include_directories(${OPENBLAS_PATH}/include/)
link_directories(${OPENBLAS_PATH} ${OPENBLAS_PATH}/lib/)
set(OPENBLAS_LIBRARIES openblas)

View File

@ -49,7 +49,7 @@ if (SD_IOS_BUILD)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DSD_IOS_BUILD=true")
endif()
if(WIN32)
if(WIN32 AND NOT ANDROID)
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wa,-mbig-obj")
@ -231,7 +231,11 @@ if(SD_CUDA)
${LOOPS_SOURCES} ${ARRAY_SOURCES} ${TYPES_SOURCES}
${MEMORY_SOURCES} ${GRAPH_SOURCES} ${CUSTOMOPS_SOURCES} ${INDEXING_SOURCES} ${EXCEPTIONS_SOURCES} ${OPS_SOURCES} ${PERF_SOURCES} ${CUSTOMOPS_CUDNN_SOURCES} ${CUSTOMOPS_MKLDNN_SOURCES})
add_library(${SD_LIBRARY_NAME} SHARED $<TARGET_OBJECTS:nd4jobj>)
# Don't output dynamic linked lib when a static lib build is specified unless the tests are built
if(NOT SD_STATIC_LIB OR SD_BUILD_TESTS)
add_library(${SD_LIBRARY_NAME} SHARED $<TARGET_OBJECTS:nd4jobj>)
endif()
if (WIN32)
message("MSVC runtime for library: ${MSVC_RT_LIB}")
@ -241,7 +245,7 @@ if(SD_CUDA)
if (SD_BUILD_TESTS OR SD_STATIC_LIB)
add_library(${SD_LIBRARY_NAME}static STATIC $<TARGET_OBJECTS:nd4jobj>)
set_property(TARGET ${SD_LIBRARY_NAME}static PROPERTY MSVC_RUNTIME_LIBRARY "${MSVC_RT_LIB}$<$<CONFIG:Debug>:Debug>")
install(TARGETS ${SD_LIBRARY_NAME}static DESTINATION .)
install(TARGETS ${SD_LIBRARY_NAME}static DESTINATION .)
endif()
# on windows we want to make sure we use MT or MD, but since we use it in one lib, we must use it everywhere to avoid conflicts
@ -320,14 +324,16 @@ elseif(SD_CPU)
${MEMORY_SOURCES} ${GRAPH_SOURCES} ${CUSTOMOPS_SOURCES} ${EXCEPTIONS_SOURCES} ${INDEXING_SOURCES} ${CUSTOMOPS_MKLDNN_SOURCES} ${CUSTOMOPS_GENERIC_SOURCES}
${OPS_SOURCES} ${PERF_SOURCES})
if(IOS)
add_library(${SD_LIBRARY_NAME} STATIC $<TARGET_OBJECTS:nd4jobj>)
add_library(${SD_LIBRARY_NAME} STATIC $<TARGET_OBJECTS:nd4jobj>)
else()
# static library is built only if we're going to build tests, skip otherwise
if (SD_BUILD_TESTS OR SD_STATIC_LIB)
add_library(${SD_LIBRARY_NAME}static STATIC $<TARGET_OBJECTS:nd4jobj>)
endif()
add_library(${SD_LIBRARY_NAME} SHARED $<TARGET_OBJECTS:nd4jobj>)
if(SD_BUILD_TESTS OR NOT SD_STATIC_LIB)
add_library(${SD_LIBRARY_NAME} SHARED $<TARGET_OBJECTS:nd4jobj>)
endif()
endif()
# we're including {MKLDNN} here in case of building from sources. in future that'll replace {MKLDNN_LIBRARIES}. same applies to BLAS

View File

@ -21,6 +21,33 @@ set -eu
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd "$DIR"
setwindows_msys() {
if [[ $KERNEL == *"windows"* ]]; then
export CMAKE_COMMAND="$CMAKE_COMMAND -G \"MSYS Makefiles\""
fi
}
setandroid_defaults() {
if [[ -z ${ANDROID_NDK:-} ]]; then
export ANDROID_NDK=$HOME/Android/android-ndk/
echo "No ANDROID_NDK variable set. Setting to default of $ANDROID_NDK"
else
echo "USING ANDROID NDK $ANDROID_NDK"
fi
if [[ -z ${ANDROID_VERSION:-} ]]; then
export ANDROID_VERSION=21
echo "No ANDROID_VERSION variable set. Setting to default of $ANDROID_VERSION"
else
echo "USING ANDROID VERSION $ANDROID_VERSION"
# android needs static linking
fi
}
export CMAKE_COMMAND="cmake"
if which cmake3 &> /dev/null; then
export CMAKE_COMMAND="cmake3"
@ -57,7 +84,7 @@ VERBOSE_ARG="VERBOSE=1"
HELPER=
CHECK_VECTORIZATION="OFF"
NAME=
while [[ $# > 0 ]]
while [[ $# -gt 0 ]]
do
key="$1"
value="${2:-}"
@ -141,7 +168,7 @@ case $key in
# unknown option
;;
esac
if [[ $# > 0 ]]; then
if [[ $# -gt 0 ]]; then
shift # past argument or value
fi
done
@ -154,6 +181,8 @@ if [ "$(uname)" == "Darwin" ]; then
elif [ "$(expr substr $(uname -s) 1 5)" == "MINGW" ] || [ "$(expr substr $(uname -s) 1 4)" == "MSYS" ]; then
HOST="windows"
KERNEL="windows-x86_64"
# need to set build path separator, it ends up being wrong on msys2
BUILD_PATH_SEPARATOR=";"
echo "Running windows"
elif [ "$(uname -m)" == "ppc64le" ]; then
if [ -z "$ARCH" ]; then
@ -166,9 +195,9 @@ if [ -z "$OS" ]; then
OS="$HOST"
fi
if [[ -z ${ANDROID_NDK:-} ]]; then
export ANDROID_NDK=$HOME/Android/android-ndk/
fi
echo "RUNNING BUILD FOR OS $OS"
case "$OS" in
linux-armhf)
@ -190,44 +219,67 @@ case "$OS" in
if [ -z "$ARCH" ]; then
ARCH="armv7-a"
fi
setandroid_defaults
export ANDROID_BIN="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/$KERNEL/"
export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/llvm-libc++/"
export ANDROID_CC="$ANDROID_NDK/toolchains/llvm/prebuilt/$KERNEL/bin/clang"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-21/arch-arm/"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-$ANDROID_VERSION/arch-arm/"
export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-arm.cmake -DSD_ANDROID_BUILD=true"
setwindows_msys
;;
android-arm64)
if [ -z "$ARCH" ]; then
ARCH="armv8-a"
fi
setandroid_defaults
echo "BUILDING ANDROID ARM with KERNEL $KERNEL"
export ANDROID_BIN="$ANDROID_NDK/toolchains/aarch64-linux-android-4.9/prebuilt/$KERNEL/"
export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/llvm-libc++/"
export ANDROID_CC="$ANDROID_NDK/toolchains/llvm/prebuilt/$KERNEL/bin/clang"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-21/arch-arm64/"
export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-arm64.cmake -DSD_ANDROID_BUILD=true"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-$ANDROID_VERSION/arch-arm64/"
export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-arm64.cmake -DSD_ANDROID_BUILD=true"
setwindows_msys
;;
android-x86)
if [ -z "$ARCH" ]; then
ARCH="i686"
fi
export ANDROID_BIN="$ANDROID_NDK/toolchains/x86-4.9/prebuilt/$KERNEL/"
echo "BUILDING ANDROID x86"
setandroid_defaults
export ANDROID_BIN="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/$KERNEL/"
export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/llvm-libc++/"
export ANDROID_CC="$ANDROID_NDK/toolchains/llvm/prebuilt/$KERNEL/bin/clang"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-21/arch-x86/"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-$ANDROID_VERSION/arch-x86/"
export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-x86.cmake -DSD_ANDROID_BUILD=true"
setwindows_msys
;;
android-x86_64)
if [ -z "$ARCH" ]; then
ARCH="x86-64"
fi
export ANDROID_BIN="$ANDROID_NDK/toolchains/x86_64-4.9/prebuilt/$KERNEL/"
echo "BUILDING ANDROID x86_64"
setandroid_defaults
export ANDROID_BIN="$ANDROID_NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/$KERNEL/"
export ANDROID_CPP="$ANDROID_NDK/sources/cxx-stl/llvm-libc++/"
export ANDROID_CC="$ANDROID_NDK/toolchains/llvm/prebuilt/$KERNEL/bin/clang"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-21/arch-x86_64/"
export ANDROID_ROOT="$ANDROID_NDK/platforms/android-$ANDROID_VERSION/arch-x86_64/"
export CMAKE_COMMAND="$CMAKE_COMMAND -DCMAKE_TOOLCHAIN_FILE=cmake/android-x86_64.cmake -DSD_ANDROID_BUILD=true"
setwindows_msys
;;
ios-x86_64)
@ -312,6 +364,7 @@ case "$OS" in
PARALLEL="true"
VERBOSE_ARG="-v"
else
echo "SETTING UP WINDOWS"
export CMAKE_COMMAND="cmake -G \"MSYS Makefiles\""
export MAKE_COMMAND="make"
export CC=/mingw64/bin/gcc
@ -400,9 +453,9 @@ if [ -z "$NAME" ]; then
fi
if [ "$LIBTYPE" == "dynamic" ]; then
SHARED_LIBS_ARG="-DSD_SHARED_LIB=OFF"
SHARED_LIBS_ARG="-DSD_SHARED_LIB=ON -DSD_STATIC_LIB=OFF"
else
SHARED_LIBS_ARG="-DSD_SHARED_LIB=ON"
SHARED_LIBS_ARG="-DSD_SHARED_LIB=OFF -DSD_STATIC_LIB=ON"
fi
if [ "$BUILD" == "release" ]; then
@ -464,11 +517,14 @@ if [ "$CHIP" == "cuda" ] && [ -n "$CHIP_VERSION" ]; then
esac
fi
[[ -z ${OPENBLAS_PATH:-} ]] && OPENBLAS_PATH=""
OPENBLAS_PATH="${OPENBLAS_PATH//\\//}"
if [[ -n "${BUILD_PATH:-}" ]]; then
PREVIFS="$IFS"
IFS="$BUILD_PATH_SEPARATOR"
echo "BUILD PATH BUILD_PATH_SEPARATOR IS $BUILD_PATH_SEPARATOR"
for P in $BUILD_PATH; do
if [[ -f "$P/include/openblas_config.h" ]]; then
OPENBLAS_PATH="$P"
@ -485,6 +541,7 @@ fi
# replace any backslash with a slash
OPENBLAS_PATH="${OPENBLAS_PATH//\\//}"
mkbuilddir() {
if [ "$CLEAN" == "true" ]; then
echo "Removing blasbuild"
@ -537,7 +594,7 @@ echo CHECK_VECTORIZATION = "$CHECK_VECTORIZATION"
echo HELPERS = "$HELPERS"
mkbuilddir
pwd
eval $CMAKE_COMMAND "$BLAS_ARG" "$ARCH_ARG" "$NAME_ARG" -DSD_CHECK_VECTORIZATION="${CHECK_VECTORIZATION}" $HELPERS "$SHARED_LIBS_ARG" "$MINIFIER_ARG" "$OPERATIONS_ARG" "$BUILD_TYPE" "$PACKAGING_ARG" "$EXPERIMENTAL_ARG" "$TESTS_ARG" "$CUDA_COMPUTE" -DOPENBLAS_PATH="$OPENBLAS_PATH" -DDEV=FALSE -DCMAKE_NEED_RESPONSE=YES -DMKL_MULTI_THREADED=TRUE ../..
eval "$CMAKE_COMMAND" "$BLAS_ARG" "$ARCH_ARG" "$NAME_ARG" -DSD_CHECK_VECTORIZATION="${CHECK_VECTORIZATION}" "$HELPERS" "$SHARED_LIBS_ARG" "$MINIFIER_ARG" "$OPERATIONS_ARG" "$BUILD_TYPE" "$PACKAGING_ARG" "$EXPERIMENTAL_ARG" "$TESTS_ARG" "$CUDA_COMPUTE" -DOPENBLAS_PATH="$OPENBLAS_PATH" -DDEV=FALSE -DCMAKE_NEED_RESPONSE=YES -DMKL_MULTI_THREADED=TRUE ../..
if [ "$PARALLEL" == "true" ]; then
MAKE_ARGUMENTS="$MAKE_ARGUMENTS -j $MAKEJ"
@ -551,9 +608,10 @@ if [ "$CHECK_VECTORIZATION" == "ON" ]; then
if [ "$MAKE_COMMAND" == "make" ]; then
MAKE_ARGUMENTS="$MAKE_ARGUMENTS --output-sync=target"
fi
exec 3>&1
eval $MAKE_COMMAND $MAKE_ARGUMENTS 2>&1 >&3 3>&- | python3 ../../auto_vectorization/auto_vect.py && cd ../../..
eval "$MAKE_COMMAND" "$MAKE_ARGUMENTS" 2>&1 >&3 3>&- | python3 ../../auto_vectorization/auto_vect.py && cd ../../..
exec 3>&-
else
eval $MAKE_COMMAND $MAKE_ARGUMENTS && cd ../../..
fi
eval "$MAKE_COMMAND" "$MAKE_ARGUMENTS" && cd ../../..
fi

View File

@ -1,27 +1,22 @@
# CMake toolchain to build for Android 5.0 or newer. Sample usage:
#
# ANDROID_BIN="/path/to/android-ndk/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/" \
# ANDROID_CPP="/path/to/android-ndk/sources/cxx-stl/llvm-libc++/" \
# ANDROID_CC="/path/to/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" \
# ANDROID_ROOT="/path/to/android-ndk/platforms/android-21/arch-arm/" \
# cmake -DCMAKE_TOOLCHAIN_FILE=android-arm.cmake -DCMAKE_INSTALL_PREFIX=..
#
# If you really need to use libnd4j on a CPU with no FPU, replace "libs/armeabi-v7a" by "libs/armeabi" and
# "-march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16" with "-march=armv5te -mtune=xscale -msoft-float"
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
set(CMAKE_ANDROID_NDK "$ENV{ANDROID_NDK}")
set(CMAKE_ANDROID_STL_TYPE c++_shared)
set(CMAKE_SYSTEM_VERSION "$ENV{ANDROID_VERSION}")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
set(CMAKE_SYSTEM_NAME UnixPaths)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(ANDROID TRUE)
if (WIN32)
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}.exe")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++.exe")
else()
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++")
endif (WIN32)
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -target armv7-none-linux-androideabi -Wl,--fix-cortex-a8 -Wl,--no-undefined -z text -o <TARGET> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -lm -lc")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -target armv7-none-linux-androideabi -Wl,--fix-cortex-a8 -Wl,--no-undefined -z text -o <TARGET> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -L$ENV{ANDROID_CPP}/libs/armeabi-v7a/ -nostdlib++ -lc++_static -lc++abi -landroid_support -lm -lc")
set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -target armv7-none-linux-androideabi -Wl,--fix-cortex-a8 -Wl,--no-undefined -z text -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -lm -lc")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -target armv7-none-linux-androideabi -Wl,--fix-cortex-a8 -Wl,--no-undefined -z text -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -L$ENV{ANDROID_CPP}/libs/armeabi-v7a/ -nostdlib++ -lc++_static -lc++abi -landroid_support -lm -lc")
add_definitions(-D__ANDROID_API__=$ENV{ANDROID_VERSION} -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target aarch64-none-linux-android -march=armv8-a)
add_definitions(-D__ANDROID_API__=21 -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target armv7-none-linux-androideabi -march=armv7-a -mfloat-abi=softfp -mfpu=vfpv3-d16)
include_directories("$ENV{ANDROID_CPP}/include/" "$ENV{ANDROID_CPP}/../llvm-libc++abi/include/" "$ENV{ANDROID_NDK}/sources/android/support/include/" "$ENV{ANDROID_CPP}/libs/armeabi-v7a/include/" "$ENV{ANDROID_NDK}/sysroot/usr/include/" "$ENV{ANDROID_NDK}/sysroot/usr/include/arm-linux-androideabi/" "$ENV{ANDROID_ROOT}/usr/include/")

View File

@ -1,24 +1,22 @@
# CMake toolchain to build for Android 5.0 or newer. Sample usage:
#
# ANDROID_BIN="/path/to/android-ndk/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/" \
# ANDROID_CPP="/path/to/android-ndk/sources/cxx-stl/llvm-libc++/" \
# ANDROID_CC="/path/to/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" \
# ANDROID_ROOT="/path/to/android-ndk/platforms/android-21/arch-arm64/" \
# cmake -DCMAKE_TOOLCHAIN_FILE=android-arm64.cmake -DCMAKE_INSTALL_PREFIX=..
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_ANDROID_ARCH_ABI arm64-v8a)
set(CMAKE_ANDROID_NDK "$ENV{ANDROID_NDK}")
set(CMAKE_ANDROID_STL_TYPE c++_shared)
set(CMAKE_SYSTEM_VERSION "$ENV{ANDROID_VERSION}")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
set(CMAKE_SYSTEM_NAME UnixPaths)
set(CMAKE_SYSTEM_PROCESSOR arm64)
set(ANDROID TRUE)
if (WIN32)
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}.exe")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++.exe")
else()
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++")
endif (WIN32)
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -target aarch64-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -lm -lc")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -target aarch64-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -L$ENV{ANDROID_CPP}/libs/arm64-v8a/ -nostdlib++ -lc++_static -lc++abi -lm -lc")
set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -target aarch64-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -lm -lc")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -target aarch64-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -L$ENV{ANDROID_CPP}/libs/arm64-v8a/ -nostdlib++ -lc++_static -lc++abi -lm -lc")
add_definitions(-D__ANDROID_API__=$ENV{ANDROID_VERSION} -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target aarch64-none-linux-android -march=armv8-a)
add_definitions(-D__ANDROID_API__=21 -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target aarch64-none-linux-android -march=armv8-a)
include_directories("$ENV{ANDROID_CPP}/include/" "$ENV{ANDROID_CPP}/../llvm-libc++abi/include/" "$ENV{ANDROID_NDK}/sources/android/support/include/" "$ENV{ANDROID_CPP}/libs/arm64-v8a/include/" "$ENV{ANDROID_NDK}/sysroot/usr/include/" "$ENV{ANDROID_NDK}/sysroot/usr/include/aarch64-linux-android/" "$ENV{ANDROID_ROOT}/usr/include/")

View File

@ -1,24 +1,22 @@
# CMake toolchain to build for Android 5.0 or newer. Sample usage:
#
# ANDROID_BIN="/path/to/android-ndk/toolchains/x86-4.9/prebuilt/linux-x86_64/" \
# ANDROID_CPP="/path/to/android-ndk/sources/cxx-stl/llvm-libc++/" \
# ANDROID_CC="/path/to/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" \
# ANDROID_ROOT="/path/to/android-ndk/platforms/android-21/arch-x86/" \
# cmake -DCMAKE_TOOLCHAIN_FILE=android-x86.cmake -DCMAKE_INSTALL_PREFIX=..
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_ANDROID_ARCH_ABI x86)
set(CMAKE_ANDROID_NDK "$ENV{ANDROID_NDK}")
set(CMAKE_ANDROID_STL_TYPE c++_shared)
set(CMAKE_SYSTEM_VERSION "$ENV{ANDROID_VERSION}")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
set(CMAKE_SYSTEM_NAME UnixPaths)
set(CMAKE_SYSTEM_PROCESSOR atom)
set(ANDROID TRUE)
if (WIN32)
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}.exe")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++.exe")
else()
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++")
endif (WIN32)
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -target i686-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -lm -lc")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -target i686-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -L$ENV{ANDROID_CPP}/libs/x86/ -nostdlib++ -lc++_static -lc++abi -landroid_support -lm -lc")
set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -target i686-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -lm -lc")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -target i686-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -L$ENV{ANDROID_CPP}/libs/x86/ -nostdlib++ -lc++_static -lc++abi -landroid_support -lm -lc")
add_definitions(-D__ANDROID_API__=$ENV{ANDROID_VERSION} -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target x86-none-linux-android)
add_definitions(-D__ANDROID_API__=21 -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target i686-none-linux-android -march=i686 -mtune=atom -mssse3 -mfpmath=sse)
include_directories("$ENV{ANDROID_CPP}/include/" "$ENV{ANDROID_CPP}/../llvm-libc++abi/include/" "$ENV{ANDROID_NDK}/sources/android/support/include/" "$ENV{ANDROID_CPP}/libs/x86/include/" "$ENV{ANDROID_NDK}/sysroot/usr/include/" "$ENV{ANDROID_NDK}/sysroot/usr/include/i686-linux-android/" "$ENV{ANDROID_ROOT}/usr/include/")

View File

@ -1,24 +1,21 @@
# CMake toolchain to build for Android 5.0 or newer. Sample usage:
#
# ANDROID_BIN="/path/to/android-ndk/toolchains/x86_64-4.9/prebuilt/linux-x86_64/" \
# ANDROID_CPP="/path/to/android-ndk/sources/cxx-stl/llvm-libc++/" \
# ANDROID_CC="/path/to/android-ndk/toolchains/llvm/prebuilt/linux-x86_64/bin/clang" \
# ANDROID_ROOT="/path/to/android-ndk/platforms/android-21/arch-x86_64/" \
# cmake -DCMAKE_TOOLCHAIN_FILE=android-x86_64.cmake -DCMAKE_INSTALL_PREFIX=..
set(CMAKE_SYSTEM_NAME UnixPaths)
set(CMAKE_SYSTEM_PROCESSOR atom64)
set(CMAKE_SYSTEM_NAME Android)
set(CMAKE_ANDROID_ARCH_ABI x86_64)
set(CMAKE_ANDROID_NDK "$ENV{ANDROID_NDK}")
set(CMAKE_ANDROID_STL_TYPE c++_shared)
set(CMAKE_SYSTEM_VERSION "$ENV{ANDROID_VERSION}")
set(CMAKE_ANDROID_NDK_TOOLCHAIN_VERSION clang)
set(ANDROID TRUE)
if (WIN32)
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}.exe")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++.exe")
else()
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++")
endif (WIN32)
set(CMAKE_C_COMPILER "$ENV{ANDROID_CC}")
set(CMAKE_CXX_COMPILER "$ENV{ANDROID_CC}++")
set(CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -target x86_64-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -lm -lc")
set(CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -target x86_64-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -L$ENV{ANDROID_CPP}/libs/x86_64/ -nostdlib++ -lc++_static -lc++abi -lm -lc")
set(CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -target x86_64-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -lm -lc")
set(CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -target x86_64-none-linux-android -Wl,--no-undefined -z text -o <TARGET> <OBJECTS> <LINK_LIBRARIES> -gcc-toolchain $ENV{ANDROID_BIN} --sysroot=$ENV{ANDROID_ROOT} -L$ENV{ANDROID_CPP}/libs/x86_64/ -nostdlib++ -lc++_static -lc++abi -lm -lc")
add_definitions(-D__ANDROID_API__=21 -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target x86_64-none-linux-android -march=x86-64 -mtune=atom)
include_directories("$ENV{ANDROID_CPP}/include/" "$ENV{ANDROID_CPP}/../llvm-libc++abi/include/" "$ENV{ANDROID_NDK}/sources/android/support/include/" "$ENV{ANDROID_CPP}/libs/x86_64/include/" "$ENV{ANDROID_NDK}/sysroot/usr/include/" "$ENV{ANDROID_NDK}/sysroot/usr/include/x86_64-linux-android/" "$ENV{ANDROID_ROOT}/usr/include/")
add_definitions(-D__ANDROID_API__=$ENV{ANDROID_VERSION} -DANDROID -fPIC -ffunction-sections -funwind-tables -fstack-protector-strong -target x86_64-none-linux-android)

View File

@ -17,8 +17,8 @@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>org.deeplearning4j</groupId>
@ -75,6 +75,7 @@
<libnd4j.classifier>${libnd4j.platform}</libnd4j.classifier>
<libnd4j.buildthreads></libnd4j.buildthreads>
<libnd4j.helper></libnd4j.helper>
<libnd4j.buildprogram>bash</libnd4j.buildprogram>
</properties>
<build>
@ -138,7 +139,7 @@
<id>javacpp-cppbuild-validate</id>
<phase>validate</phase>
<goals>
<goal>build</goal>
<goal>build</goal>
</goals>
</execution>
<execution>
@ -150,8 +151,8 @@
<configuration>
<skip>${libnd4j.cpu.compile.skip}</skip>
<buildCommand>
<program>bash</program>
<argument>${project.basedir}/buildnativeoperations.sh</argument>
<program>${libnd4j.buildprogram}</program>
<argument>buildnativeoperations.sh</argument>
<argument>--build-type</argument>
<argument>${libnd4j.build}</argument>
<argument>--chip</argument>
@ -183,7 +184,7 @@
<skip>${libnd4j.test.skip}</skip>
<workingDirectory>${basedir}/tests_cpu</workingDirectory>
<buildCommand>
<program>bash</program>
<program>sh</program>
<argument>run_tests.sh</argument>
<argument>--chip</argument>
<argument>${libnd4j.chip}</argument>
@ -233,9 +234,35 @@
</build>
<profiles>
<!-- Build on windows can use sh rather than bash due to WSL clashing with msys2 -->
<profile>
<id>build-windows</id>
<activation>
<os>
<family>Windows</family>
</os>
</activation>
<properties>
<libnd4j.buildprogram>sh</libnd4j.buildprogram>
</properties>
</profile>
<!-- Default build program should be bash on non windows platforms -->
<profile>
<id>build-unix</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<libnd4j.buildprogram>bash</libnd4j.buildprogram>
</properties>
</profile>
<!-- Use -Dlibnd4j.singlethread to use single threaded build (multi-threaded by default) -->
<profile>
<id>libnd4-single-thread</id>
<id>libnd4j-single-thread</id>
<activation>
<property>
<name>libnd4j.singlethread</name>
@ -310,8 +337,8 @@
<configuration>
<skip>${libnd4j.cuda.compile.skip}</skip>
<buildCommand>
<program>bash</program>
<argument>${project.basedir}/buildnativeoperations.sh
<program>${libnd4j.buildprogram}</program>
<argument>buildnativeoperations.sh
</argument>
<argument>--build-type</argument>
<argument>${libnd4j.build}</argument>
@ -389,6 +416,9 @@
</plugins>
</build>
</profile>
<!-- Profiles to set the default libnd4j.helper property, example: mkdnn -->
<profile>
<id>libnd4j-helper-avx2</id>

1
nd4j/compile-android.sh Normal file
View File

@ -0,0 +1 @@
mvn clean install -Djavacpp.platform=android-arm64 -Dmaven.test.skip=true -Djavacpp.platform.compiler=$ANDROID_NDK/toolchains/llvm/prebuilt/windows-x86_64/bin/clang++

View File

@ -30,11 +30,6 @@
<dependencies>
<!--dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-buffer</artifactId>
<version>${project.version}</version>
</dependency-->
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-api</artifactId>

View File

@ -29,7 +29,7 @@
<!-- CUDA version is linked with the artifact name so cannot move to parent pom.xml -->
<cuda.version>10.2</cuda.version>
<cudnn.version>7.6</cudnn.version>
<javacpp-presets.cuda.version>1.5.2</javacpp-presets.cuda.version>
<javacpp-presets.cuda.version>${javacpp-presets.version}</javacpp-presets.cuda.version>
</properties>
<build>

View File

@ -51,16 +51,6 @@
<classifier>${dependency.platform}</classifier>
</dependency>
<!--
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>libnd4j</artifactId>
<version>${project.version}</version>
<type>zip</type>
<classifier>${javacpp.platform}${javacpp.platform.extension}</classifier>
<scope>provided</scope>
</dependency>
-->
<dependency>
<groupId>org.nd4j</groupId>
<artifactId>nd4j-native-api</artifactId>
@ -165,8 +155,8 @@
<linkResources>
<linkResource>/${javacpp.platform.library.path}/</linkResource>
<linkResource>/${javacpp.platform.library.path}/lib/</linkResource>
<linkResource>/org/bytedeco/openblas/${javacpp.platform}/</linkResource>
<linkResource>/org/bytedeco/openblas/${javacpp.platform}/lib/</linkResource>
<!-- <linkResource>/org/bytedeco/openblas/${javacpp.platform}/</linkResource>
<linkResource>/org/bytedeco/openblas/${javacpp.platform}/lib/</linkResource>-->
</linkResources>
</configuration>
<executions>
@ -174,7 +164,7 @@
<id>javacpp-validate</id>
<phase>validate</phase>
<goals>
<goal>build</goal>
<goal>build</goal>
</goals>
</execution>
<execution>
@ -297,23 +287,6 @@
<javacpp.platform.extension>-avx512</javacpp.platform.extension>
</properties>
</profile>
<profile>
<id>mingw</id>
<activation>
<os><family>windows</family></os>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.bytedeco</groupId>
<artifactId>javacpp</artifactId>
<configuration>
<properties>${javacpp.platform}-mingw</properties>
</configuration>
</plugin>
</plugins>
</build>
</profile>
<profile>
<id>libnd4j-assembly</id>

View File

@ -56,9 +56,7 @@
<build>
<!--
<testSourceDirectory>../nd4j-tests/src/test/java</testSourceDirectory>
-->
<plugins>
<!-- Skip execution of Javadoc since some versions run out of memory -->
<plugin>

View File

@ -440,6 +440,7 @@
</build>
<profiles>
<profile>
<id>doclint-java8-disable</id>
<activation>