Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add r18 support for Boost Android #2

Merged
merged 7 commits into from
Oct 2, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,29 @@
# 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.

Other versions of Boost are built only for arm architecture, they are using gcc toolchain and gnustl library.

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

Expand Down
21 changes: 10 additions & 11 deletions build-android.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,16 @@
# -----------------------

BOOST_VER1=1
BOOST_VER2=67
BOOST_VER2=68
BOOST_VER3=0
register_option "--boost=<version>" 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=<version>" 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
Expand Down Expand Up @@ -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
Expand All @@ -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"
;;
*)
Expand Down
10 changes: 10 additions & 0 deletions configs/user-config-boost-1_68_0-arm64-v8a.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/aarch64-linux-android-4.9/prebuilt/${PlatformOS}-x86_64
<compileflags>-target
<compileflags>aarch64-none-linux-android
<compileflags>-fpic
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/aarch64-linux-android
<compileflags>-D__ANDROID_API__=21
15 changes: 15 additions & 0 deletions configs/user-config-boost-1_68_0-armeabi-v7a.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/${PlatformOS}-x86_64
<compileflags>-target
<compileflags>armv7-none-linux-androideabi15
<compileflags>-march=armv7-a
<compileflags>-mfloat-abi=softfp
<compileflags>-mfpu=vfpv3-d16
<compileflags>-mthumb
<compileflags>-fpic
<compileflags>-fno-integrated-as
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/arm-linux-androideabi
<compileflags>-D__ANDROID_API__=15
15 changes: 15 additions & 0 deletions configs/user-config-boost-1_68_0-armeabi.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/arm-linux-androideabi-4.9/prebuilt/${PlatformOS}-x86_64
<compileflags>-target
<compileflags>armv5te-none-linux-androideabi15
<compileflags>-march=armv5te
<compileflags>-mtune=xscale
<compileflags>-msoft-float
<compileflags>-mthumb
<compileflags>-fpic
<compileflags>-fno-integrated-as
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/arm-linux-androideabi
<compileflags>-D__ANDROID_API__=15
26 changes: 26 additions & 0 deletions configs/user-config-boost-1_68_0-common.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

# --------------------------------------------------------------------

using clang : %ARCH%
:
$(AndroidBinariesPath)/clang++
:
<archiver>$(AndroidBinariesPath)/llvm-ar
<compileflags>-fexceptions
<compileflags>-frtti
<compileflags>-ffunction-sections
<compileflags>-funwind-tables
<compileflags>-fstack-protector-strong
<compileflags>-Wno-invalid-command-line-argument
<compileflags>-Wno-unused-command-line-argument
<compileflags>-no-canonical-prefixes
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++/include
<compileflags>-I$(AndroidNDKRoot)/sources/cxx-stl/llvm-libc++abi/include
<compileflags>-I$(AndroidNDKRoot)/sources/android/support/include
<compileflags>-DANDROID
<compileflags>-Wa,--noexecstack
<compileflags>-Wformat
<compileflags>-Werror=format-security
<compileflags>-DNDEBUG
<compileflags>-O2
<compileflags>-g
11 changes: 11 additions & 0 deletions configs/user-config-boost-1_68_0-mips.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/mips64el-linux-android-4.9/prebuilt/${PlatformOS}-x86_64
<compileflags>-target
<compileflags>mipsel-none-linux-android
<compileflags>-mips32
<compileflags>-fpic
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/mipsel-linux-android
<compileflags>-D__ANDROID_API__=15
11 changes: 11 additions & 0 deletions configs/user-config-boost-1_68_0-mips64.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/mips64el-linux-android-4.9/prebuilt/${PlatformOS}-x86_64
<compileflags>-target
<compileflags>mips64el-none-linux-android
<compileflags>-fpic
<compileflags>-fintegrated-as
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/mips64el-linux-android
<compileflags>-D__ANDROID_API__=21
11 changes: 11 additions & 0 deletions configs/user-config-boost-1_68_0-x86.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/x86-4.9/prebuilt/${PlatformOS}-x86_64
<compileflags>-target
<compileflags>i686-none-linux-android
<compileflags>-fPIC
<compileflags>-mstackrealign
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/i686-linux-android
<compileflags>-D__ANDROID_API__=15
10 changes: 10 additions & 0 deletions configs/user-config-boost-1_68_0-x86_64.jam
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<compileflags>-gcc-toolchain
<compileflags>$(AndroidNDKRoot)/toolchains/x86_64-4.9/prebuilt/${PlatformOS}-x86_64
<compileflags>-target
<compileflags>x86_64-none-linux-android
<compileflags>-fPIC
<compileflags>--sysroot
<compileflags>$(AndroidNDKRoot)/sysroot
<compileflags>-isystem
<compileflags>$(AndroidNDKRoot)/sysroot/usr/include/x86_64-linux-android
<compileflags>-D__ANDROID_API__=21
42 changes: 42 additions & 0 deletions configs/user-config-boost-1_68_0.jam
Original file line number Diff line number Diff line change
@@ -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 ] ;
68 changes: 68 additions & 0 deletions patches/boost-1_68_0/boost-1_68_0.patch
Original file line number Diff line number Diff line change
@@ -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 <myheader>

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(<experimental/string_view>)
-# 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(<experimental/string_view>)
# 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 <boost/assert.hpp>
#include <boost/noncopyable.hpp>
#include <boost/utility/enable_if.hpp>
+#include <stdio.h>
#include <ostream>
#include <string>
#include <stdexcept>
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