diff --git a/README.md b/README.md index 26ebe288b..4cc228a7f 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Boost for Android Boost for android is a set of tools to compile the main part of the [Boost C++ Libraries](http://www.boost.org/) for the Android platform. -Currently supported boost versions are 1.45.0, 1.48.0, 1.49.0, 1.53.0, 1.54.0, 1.55.0, 1.65.1, 1.66.0 and 1.67.0. +Currently supported boost versions are 1.45.0, 1.48.0, 1.49.0, 1.53.0, 1.54.0, 1.55.0, 1.65.1, 1.66.0, 1.67.0 and 1.68.0. x86, mips, and 64-bit architectures are built with Boost 1.65.1 and NDK r16-beta2, this version uses clang toolchain with llvm libc++ STL library. @@ -9,20 +9,21 @@ Other versions of Boost are built only for arm architecture, they are using gcc To compile Boost for Android you may use one of the following NDKs: -| NDK / boost | 1.45 | 1.48 | 1.49 | 1.53 | 1.65 | 1.66 | 1.67 | -| ----------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | -| r4 customized by [Dmitry Moskalchuk aka CrystaX](http://www.crystax.net/android/ndk.php). | x | | | | | | | -| r5 from the [official android repository](http://developer.android.com). | x | | | | | | | -| r5 customized by [CrystaX](http://www.crystax.net/android/ndk.php). | x | | | | | | | -| r7 customized by [CrystaX](http://www.crystax.net/android/ndk.php). | x | x | x | | | | | -| r8 from the [official android repository](http://developer.android.com). | x | x | x | | | | | -| r8b from the [official android repository](http://developer.android.com). | | x | x | | | | | -| r8c from the [official android repository](http://developer.android.com). | | | x | | | | | -| r8d from the [official android repository](http://developer.android.com). | | | x | x | | | | -| r8e from the [official android repository](http://developer.android.com). | | | x | x | | | | -| r10 from the [official android repository](http://developer.android.com). | | | x | x | | | | -| r16 from the [official android repository](http://developer.android.com). | | | | | x | x | x | -| r17b from the [official android repository](http://developer.android.com). | | | | | | | x | +| NDK / boost | 1.45 | 1.48 | 1.49 | 1.53 | 1.65 | 1.66 | 1.67 | 1.68 | +| ----------- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | +| r4 customized by [Dmitry Moskalchuk aka CrystaX](http://www.crystax.net/android/ndk.php). | x | | | | | | | | +| r5 from the [official android repository](http://developer.android.com). | x | | | | | | | | +| r5 customized by [CrystaX](http://www.crystax.net/android/ndk.php). | x | | | | | | | | +| r7 customized by [CrystaX](http://www.crystax.net/android/ndk.php). | x | x | x | | | | | | +| r8 from the [official android repository](http://developer.android.com). | x | x | x | | | | | | +| r8b from the [official android repository](http://developer.android.com). | | x | x | | | | | | +| r8c from the [official android repository](http://developer.android.com). | | | x | | | | | | +| r8d from the [official android repository](http://developer.android.com). | | | x | x | | | | | +| r8e from the [official android repository](http://developer.android.com). | | | x | x | | | | | +| r10 from the [official android repository](http://developer.android.com). | | | x | x | | | | | +| r16 from the [official android repository](http://developer.android.com). | | | | | x | x | x | x | +| r17b from the [official android repository](http://developer.android.com). | | | | | | | x | x | +| r18 from the [official android repository](http://developer.android.com). | | | | | | | | x | # Quick Start diff --git a/build-android.sh b/build-android.sh index a7bbdaf22..6e50feb8e 100755 --- a/build-android.sh +++ b/build-android.sh @@ -28,12 +28,16 @@ # ----------------------- BOOST_VER1=1 -BOOST_VER2=67 +BOOST_VER2=68 BOOST_VER3=0 -register_option "--boost=" boost_version "Boost version to be used, one of {1.67.0, 1.66.0, 1.65.1, 1.55.0, 1.54.0, 1.53.0, 1.49.0, 1.48.0, 1.45.0}, default is 1.67.0." +register_option "--boost=" boost_version "Boost version to be used, one of {1.68.0, 1.67.0, 1.66.0, 1.65.1, 1.55.0, 1.54.0, 1.53.0, 1.49.0, 1.48.0, 1.45.0}, default is 1.68.0." boost_version() { - if [ "$1" = "1.67.0" ]; then + if [ "$1" = "1.68.0" ]; then + BOOST_VER1=1 + BOOST_VER2=68 + BOOST_VER3=0 + elif [ "$1" = "1.67.0" ]; then BOOST_VER1=1 BOOST_VER2=67 BOOST_VER3=0 @@ -290,16 +294,11 @@ case "$NDK_RN" in CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/arm-linux-androideabi-g++ TOOLSET=gcc-androidR8e ;; - 16.*) + "16.0"|"16.1"|"17.1"|"17.2"|"18.0") TOOLCHAIN=${TOOLCHAIN:-llvm} CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++ TOOLSET=clang ;; - 17.*) - TOOLCHAIN=${TOOLCHAIN:-llvm} - CXXPATH=$AndroidNDKRoot/toolchains/${TOOLCHAIN}/prebuilt/${PlatformOS}-x86_64/bin/clang++ - TOOLSET=clang - ;; *) echo "Undefined or not supported Android NDK version: $NDK_RN" exit 1 @@ -314,8 +313,8 @@ if [ -z "${ARCHLIST}" ]; then if [ "$TOOLSET" = "clang" ]; then case "$NDK_RN" in - # NDK 17: Support for ARMv5 (armeabi), MIPS, and MIPS64 has been removed. - 17.*) + # NDK 17+: Support for ARMv5 (armeabi), MIPS, and MIPS64 has been removed. + "17.1"|"17.2"|"18.0") ARCHLIST="arm64-v8a armeabi-v7a x86 x86_64" ;; *) diff --git a/configs/user-config-boost-1_68_0-arm64-v8a.jam b/configs/user-config-boost-1_68_0-arm64-v8a.jam new file mode 100644 index 000000000..c770f4494 --- /dev/null +++ b/configs/user-config-boost-1_68_0-arm64-v8a.jam @@ -0,0 +1,10 @@ +-gcc-toolchain +$(AndroidNDKRoot)/toolchains/aarch64-linux-android-4.9/prebuilt/${PlatformOS}-x86_64 +-target +aarch64-none-linux-android +-fpic +--sysroot +$(AndroidNDKRoot)/sysroot +-isystem +$(AndroidNDKRoot)/sysroot/usr/include/aarch64-linux-android +-D__ANDROID_API__=21 diff --git a/configs/user-config-boost-1_68_0-armeabi-v7a.jam b/configs/user-config-boost-1_68_0-armeabi-v7a.jam new file mode 100644 index 000000000..284c21b6c --- /dev/null +++ b/configs/user-config-boost-1_68_0-armeabi-v7a.jam @@ -0,0 +1,15 @@ +-gcc-toolchain +$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/${PlatformOS}-x86_64 +-target +armv7-none-linux-androideabi15 +-march=armv7-a +-mfloat-abi=softfp +-mfpu=vfpv3-d16 +-mthumb +-fpic +-fno-integrated-as +--sysroot +$(AndroidNDKRoot)/sysroot +-isystem +$(AndroidNDKRoot)/sysroot/usr/include/arm-linux-androideabi +-D__ANDROID_API__=15 diff --git a/configs/user-config-boost-1_68_0-armeabi.jam b/configs/user-config-boost-1_68_0-armeabi.jam new file mode 100644 index 000000000..f119d2a9b --- /dev/null +++ b/configs/user-config-boost-1_68_0-armeabi.jam @@ -0,0 +1,15 @@ +-gcc-toolchain +$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/${PlatformOS}-x86_64 +-target +armv5te-none-linux-androideabi15 +-march=armv5te +-mtune=xscale +-msoft-float +-mthumb +-fpic +-fno-integrated-as +--sysroot +$(AndroidNDKRoot)/sysroot +-isystem +$(AndroidNDKRoot)/sysroot/usr/include/arm-linux-androideabi +-D__ANDROID_API__=15 diff --git a/configs/user-config-boost-1_68_0-common.jam b/configs/user-config-boost-1_68_0-common.jam new file mode 100644 index 000000000..9bb70c1f0 --- /dev/null +++ b/configs/user-config-boost-1_68_0-common.jam @@ -0,0 +1,26 @@ + +# -------------------------------------------------------------------- + +using clang : %ARCH% +: +$(AndroidBinariesPath)/clang++ +: +$(AndroidBinariesPath)/llvm-ar +-fexceptions +-frtti +-ffunction-sections +-funwind-tables +-fstack-protector-strong +-Wno-invalid-command-line-argument +-Wno-unused-command-line-argument +-no-canonical-prefixes +-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++/include +-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include +-I$(AndroidNDKRoot)/sources/android/support/include +-DANDROID +-Wa,--noexecstack +-Wformat +-Werror=format-security +-DNDEBUG +-O2 +-g diff --git a/configs/user-config-boost-1_68_0-mips.jam b/configs/user-config-boost-1_68_0-mips.jam new file mode 100644 index 000000000..8a373cf1f --- /dev/null +++ b/configs/user-config-boost-1_68_0-mips.jam @@ -0,0 +1,11 @@ +-gcc-toolchain +$(AndroidNDKRoot)/toolchains/mips64el-linux-android-4.9/prebuilt/${PlatformOS}-x86_64 +-target +mipsel-none-linux-android +-mips32 +-fpic +--sysroot +$(AndroidNDKRoot)/sysroot +-isystem +$(AndroidNDKRoot)/sysroot/usr/include/mipsel-linux-android +-D__ANDROID_API__=15 diff --git a/configs/user-config-boost-1_68_0-mips64.jam b/configs/user-config-boost-1_68_0-mips64.jam new file mode 100644 index 000000000..52eddb971 --- /dev/null +++ b/configs/user-config-boost-1_68_0-mips64.jam @@ -0,0 +1,11 @@ +-gcc-toolchain +$(AndroidNDKRoot)/toolchains/mips64el-linux-android-4.9/prebuilt/${PlatformOS}-x86_64 +-target +mips64el-none-linux-android +-fpic +-fintegrated-as +--sysroot +$(AndroidNDKRoot)/sysroot +-isystem +$(AndroidNDKRoot)/sysroot/usr/include/mips64el-linux-android +-D__ANDROID_API__=21 diff --git a/configs/user-config-boost-1_68_0-x86.jam b/configs/user-config-boost-1_68_0-x86.jam new file mode 100644 index 000000000..77ae94165 --- /dev/null +++ b/configs/user-config-boost-1_68_0-x86.jam @@ -0,0 +1,11 @@ +-gcc-toolchain +$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/${PlatformOS}-x86_64 +-target +i686-none-linux-android +-fPIC +-mstackrealign +--sysroot +$(AndroidNDKRoot)/sysroot +-isystem +$(AndroidNDKRoot)/sysroot/usr/include/i686-linux-android +-D__ANDROID_API__=15 diff --git a/configs/user-config-boost-1_68_0-x86_64.jam b/configs/user-config-boost-1_68_0-x86_64.jam new file mode 100644 index 000000000..f100eb6ee --- /dev/null +++ b/configs/user-config-boost-1_68_0-x86_64.jam @@ -0,0 +1,10 @@ +-gcc-toolchain +$(AndroidNDKRoot)/toolchains/x86_64-4.9/prebuilt/${PlatformOS}-x86_64 +-target +x86_64-none-linux-android +-fPIC +--sysroot +$(AndroidNDKRoot)/sysroot +-isystem +$(AndroidNDKRoot)/sysroot/usr/include/x86_64-linux-android +-D__ANDROID_API__=21 diff --git a/configs/user-config-boost-1_68_0.jam b/configs/user-config-boost-1_68_0.jam new file mode 100644 index 000000000..0a159d93c --- /dev/null +++ b/configs/user-config-boost-1_68_0.jam @@ -0,0 +1,42 @@ +# Copyright 2003, 2005 Douglas Gregor +# Copyright 2004 John Maddock +# Copyright 2002, 2003, 2004, 2007 Vladimir Prus +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) + +# This file is used to configure your Boost.Build installation. You can modify +# this file in place, or you can place it in a permanent location so that it +# does not get overwritten should you get a new version of Boost.Build. See: +# +# http://www.boost.org/boost-build2/doc/html/bbv2/overview/configuration.html +# +# for documentation about possible permanent locations. + +# This file specifies which toolsets (C++ compilers), libraries, and other +# tools are available. Often, you should be able to just uncomment existing +# example lines and adjust them to taste. The complete list of supported tools, +# and configuration instructions can be found at: +# +# http://boost.org/boost-build2/doc/html/bbv2/reference/tools.html +# + +# This file uses Jam language syntax to describe available tools. Mostly, +# there are 'using' lines, that contain the name of the used tools, and +# parameters to pass to those tools -- where paremeters are separated by +# semicolons. Important syntax notes: +# +# - Both ':' and ';' must be separated from other tokens by whitespace +# - The '\' symbol is a quote character, so when specifying Windows paths you +# should use '/' or '\\' instead. +# +# More details about the syntax can be found at: +# +# http://boost.org/boost-build2/doc/html/bbv2/advanced.html#bbv2.advanced.jam_language +# +# ------------------ +# Android configurations. +# ------------------ + +import os ; +local AndroidNDKRoot = [ os.environ AndroidNDKRoot ] ; +local AndroidBinariesPath = [ os.environ AndroidBinariesPath ] ; diff --git a/patches/boost-1_68_0/boost-1_68_0.patch b/patches/boost-1_68_0/boost-1_68_0.patch new file mode 100644 index 000000000..54134800a --- /dev/null +++ b/patches/boost-1_68_0/boost-1_68_0.patch @@ -0,0 +1,68 @@ +diff -u -r boost_1_68_0.orig/boost/config/user.hpp boost_1_68_0/boost/config/user.hpp +--- boost_1_68_0.orig/boost/config/user.hpp 2018-08-01 22:50:46.000000000 +0200 ++++ boost_1_68_0/boost/config/user.hpp 2018-08-27 15:43:38.000000000 +0200 +@@ -13,6 +13,12 @@ + // configuration policy: + // + ++// Android defines ++// There is problem with std::atomic on android (and some other platforms). ++// See this link for more info: ++// https://code.google.com/p/android/issues/detail?id=42735#makechanges ++#define BOOST_ASIO_DISABLE_STD_ATOMIC 1 ++ + // define this to locate a compiler config file: + // #define BOOST_COMPILER_CONFIG + +diff -u -r boost_1_68_0.orig/boost/asio/detail/config.hpp boost_1_68_0/boost/asio/detail/config.hpp +--- boost_1_68_0.orig/boost/asio/detail/config.hpp 2018-08-01 22:50:46.000000000 +0200 ++++ boost_1_68_0/boost/asio/detail/config.hpp 2018-09-19 12:39:56.000000000 +0200 +@@ -804,7 +804,11 @@ + # if defined(__clang__) + # if (__cplusplus >= 201402) + # if __has_include() +-# define BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1 ++# if __clang_major__ >= 7 ++# undef BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW ++# else ++# define BOOST_ASIO_HAS_STD_EXPERIMENTAL_STRING_VIEW 1 ++# endif // __clang_major__ >= 7 + # endif // __has_include() + # endif // (__cplusplus >= 201402) + # endif // defined(__clang__) +diff -u -r boost_1_68_0.orig/boost/system/error_code.hpp boost_1_68_0/boost/system/error_code.hpp +--- boost_1_68_0.orig/boost/system/error_code.hpp 2018-08-01 22:50:53.000000000 +0200 ++++ boost_1_68_0/boost/system/error_code.hpp 2018-08-27 15:44:29.000000000 +0200 +@@ -17,6 +17,7 @@ + #include + #include + #include ++#include + #include + #include + #include +diff -u -r boost_1_68_0.orig/libs/filesystem/src/operations.cpp boost_1_68_0/libs/filesystem/src/operations.cpp +--- boost_1_68_0.orig/libs/filesystem/src/operations.cpp 2018-08-01 22:50:47.000000000 +0200 ++++ boost_1_68_0/libs/filesystem/src/operations.cpp 2018-08-27 15:47:15.000000000 +0200 +@@ -232,6 +232,21 @@ + + # if defined(BOOST_POSIX_API) + ++# if defined(__ANDROID__) ++# define truncate libboost_truncate_wrapper ++// truncate() is present in Android libc only starting from ABI 21, so here's a simple wrapper ++static int libboost_truncate_wrapper(const char *path, off_t length) ++{ ++ int fd = open(path, O_WRONLY); ++ if (fd == -1) { ++ return -1; ++ } ++ int status = ftruncate(fd, length); ++ close(fd); ++ return status; ++} ++# endif ++ + typedef int err_t; + + // POSIX uses a 0 return to indicate success