diff options
author | Fred Hornsey <hornseyf@objectcomputing.com> | 2020-12-05 18:12:33 -0600 |
---|---|---|
committer | Fred Hornsey <hornseyf@objectcomputing.com> | 2020-12-05 18:16:47 -0600 |
commit | 463b4d81cc3882a30b60fe6b062f0f85de999b26 (patch) | |
tree | 2acf0535a150a5330b6ffa227c2c953428a57dd5 /ACE | |
parent | b02baa8bf80c71bdee79a9e0e94284125317de03 (diff) | |
download | ATCD-463b4d81cc3882a30b60fe6b062f0f85de999b26.tar.gz |
Remove Support for Android NDKs before r18
To get rid of the hacky GCC support in platform_macros.GNU, ensure that
all the NDKs we support have >=C++11 by default, and to be able to
default to using lld as recommended by Google.
Also:
- Removed `ANDROID_ARCH` make variable.
- Replaced `ANDROID_ABI` with `android_abi` make variables to match
other make variables, but keep `ANDROID_ABI` as an alias of
`android_abi` for compatibility.
- Will no longer default to 32-bit ARM. `android_abi` or `ANDROID_ABI`
are now required.
- Update ACE-INSTALL.html for all the changes so far
Diffstat (limited to 'ACE')
-rw-r--r-- | ACE/ACE-INSTALL.html | 139 | ||||
-rw-r--r-- | ACE/NEWS | 30 | ||||
-rw-r--r-- | ACE/ace/config-android.h | 21 | ||||
-rw-r--r-- | ACE/include/makeinclude/platform_android.GNU | 106 |
4 files changed, 100 insertions, 196 deletions
diff --git a/ACE/ACE-INSTALL.html b/ACE/ACE-INSTALL.html index 13bcad42f95..779b16a2df4 100644 --- a/ACE/ACE-INSTALL.html +++ b/ACE/ACE-INSTALL.html @@ -1626,8 +1626,8 @@ symbols are necessary when you want to debug your code.</p> <h2><a name="android">Building and Installing ACE on Android</a></h2> <ul> - <li><a href="#android-toolchain">Generating a Toolchain</a></li> - <li><a href="#android-oldndks">Using Older NDKs</a></li> + <li><a href="#android-target">Choosing the Target</a></li> + <li><a href="#android-toolchain">Generating a Toolchain (Optional)</a></li> <li><a href="#android-building">Building</a></li> <li><a href="#android-install">Installing ACE on Android</a></li> <li><a href="#android-logging">Logging</a></li> @@ -1637,13 +1637,16 @@ symbols are necessary when you want to debug your code.</p> <p>ACE can be built for Android by using the <a href="https://developer.android.com/ndk/">Android Native Development Kit (NDK)</a>. This is different than the standard way of writing Android -applications in Java which run the on Android Runtime or the older Dalvik -Virtual Machine. Applications built using the NDK are native Linux applications -written in C or C++ specifically compiled to run on Android systems. In -addition, applications built using the NDK have access to Android-specific APIs -much like the ones available to Java-based Android applications. +applications in Java which run the on the Android Runtime or the older Dalvik +Virtual Machine. Applications and libraries built using the NDK are native +Linux applications written in C or C++ specifically compiled to run on Android +systems and libraries can be included in normal Android apps. In addition, +applications and libraries built using the NDK have access to Android-specific +APIs much like the ones available to Java-based Android applications. </p> +<p><b>NOTE: ACE requires NDK r18 or later</b></p> + <div class="boxed"> <p><b>Windows Users:</b> These instructions are written for a Unix based platform like Linux, but can also be used on Windows. If you are using an @@ -1658,11 +1661,17 @@ addition to the Windows version of the Android NDK, you will also need <a href="https://www.msys2.org">MSYS2 for Unix utilities that ACE needs</a>. </div> -<h3><a name="android-toolchain">Generating a Toolchain</a></h3> +After downloading the NDK, you will have to decide on what target you want to +build for, which is covered in the next section, then decide if you want to +build directly using the NDK or using +<a href="#android-toolchain">a generated standalone toolchain</a>. Generating a +toolchain is optional and only really makes sense if you're building for just +one architecture/API level pair and don't need to keep the entire NDK around. + +<h3><a name="android-toolchain">Choosing the Target</a></h3> -<p>To build ACE for Android you need to download the NDK and generate a -toolchain for the specific Android target you want. The specific target is -defined by two things:</p> +<p>To build ACE for Android you need to know the specific Android target you +want. The specific target is defined by two things:</p> <dl class="indent"> <dt>- The minimal API level to target.</dt> @@ -1677,14 +1686,14 @@ defined by two things:</p> although support for MIPS has been dropped from the NDK. <a href="https://developer.android.com/ndk/guides/abis">This is the official documentation on the ABIs</a>. These are the ABIs that ACE supports at the - time of writing and must be passed to ACE as <code>ANDROID_ABI</code>: + time of writing and must be passed to ACE as <code>android_abi</code>: <!-- Check to see if any architectures have been added or removed. If so update this list and the table below as well--> - <dl> + <dl id="android_abis"> <dt><code>armeabi-v7a</code></dt> - <dd>32-bit ARM, The default ABI for both the NDK and ACE.</dd> - <dt><code>armeabi-v7a-with-neon</code></dt> - <dd><code>armeabi-v7a</code> with NEON extensions enabled.</dd> + <dd>32-bit ARM. Builds with NEON extensions enabled by default. Include + <code>android_neon := 0</code> in your <code>platform_macros.GNU</code> + if you want to support processors without NEON support.</dd> <dt><code>arm64-v8a</code></dt> <dd>64-bit ARM, Sometimes referred to as <code>aarch64</code>.</dd> <dt><code>x86</code></dt> @@ -1695,15 +1704,16 @@ defined by two things:</p> <p><b> It should be noted that starting in August 2019, the Google Play Store will require new apps to have 64-bit libraries if they have native - libraries. 32-bit native libraries will still be supported but they must also - have 64-bit libraries. Look up any restrictions that may affect - apps you want to publish on the Play Store, including minimum API - level. + libraries. 32-bit native libraries will still be supported but apps must + also have 64-bit libraries. Look up any restrictions that may affect apps + you want to publish on the Play Store, including targeted API level + requirements. </b></p> </dd> </li> </dl> +<h3><a name="android-toolchain">Generating a Toolchain (Optional)</a></h3> <p>To generate a toolchain, one use must use <code>build/tools/make_standalone_toolchain.py</code> in the NDK. A destination must be @@ -1715,10 +1725,11 @@ toolchain targeting 32-bit ARM Android 7.0 "Nougat" (API Level 24) and later: </ <p><code>$TOOLCHAIN/bin</code> must be in your <code>$PATH</code> when building ACE and applications using ACE.</p> -<p>This table shows how the <code>ANDROID_ABI</code> variable and the <code>--arch</code> argument correlate:</p> -<table class="indent"> +<p>This table shows how the <code>android_abi</code> variable and the +<code>--arch</code> argument correlate:</p> +<table class="indent" id="android_abi_toolchain_table"> <tr> - <th><code>ANDROID_ABI</code></th> + <th><code>android_abi</code></th> <th><code>--arch</code></th> </tr> <tr> @@ -1726,10 +1737,6 @@ applications using ACE.</p> <td><code>arm</code></td> </tr> <tr> - <td><code>armeabi-v7a-with-neon</code></td> - <td><code>arm</code></td> - </tr> - <tr> <td><code>arm64-v8a</code></td> <td><code>arm64</code></td> </tr> @@ -1763,64 +1770,6 @@ utilities must be in <code>%PATH%</code> when cross compiling ACE. The default location for these would be <code>C:\msys64\usr\bin</code>. </div> -<!-- Remove this section if these NDKs can be considered not supported anymore --> -<h3><a name="android-oldndks">Using Older NDKs</a></h3> - -<p><b>Skip this section if using NDK r18 or later.</b></p> - -<p> -It is <b>highly recommended</b> to use the latest NDK available assuming -that it works with ACE. It is possible to use NDKs older than r18, but these -have caveats: -</p> -<ul> - <li> - In NDK r16, a file called <code>ndk-version.h</code> was added that - contains the version of the NDK. If using an earlier NDK, you <b>must</b> - define the macros <code>__NDK_MAJOR__</code> and <code>__NDK_MINOR__</code> - in <code>ace/config.h</code> before - <code>#include "ace/config-android.h"</code>. - The scheme works like this: - <table class="indent" style="margin-top: .5em; margin-bottom: .5em;"> - <tr> - <th>Revision</th> - <th><code>__NDK_MAJOR__</code></th> - <th><code>__NDK_MINOR__</code></th> - </tr> - <tr> - <td>r16</td> - <td>16</td> - <td>0</td> - </tr> - <tr> - <td>r16a</td> - <td>16</td> - <td>1</td> - </tr> - <tr> - <td>r16b</td> - <td>16</td> - <td>2</td> - </tr> - </table> - </li> - <li> - As of NDK r18, the only compiler that comes with the NDK is clang and by - default the build system assumes that clang is available and will use it. - However there was a transitional period between r12 and r17 where GCC and - clang both exist in the NDK. In some cases GCC should be used if linking - errors occur with these NDKs (For example missing references to - <code>stderr</code>). To let the build system decide between them, set - <code>android_force_clang:=0</code> in - <code>include/makeinclude/platform_macros.GNU</code> before including - <code>platform_android.GNU</code>. <b>This should be set for NDKs before r15.</b> - </li> - <li> - There are probably unknown conflicts, especially in the minor revisions - before the last minor revision of a NDK revision. - </li> -</ul> - <h3><a name="android-building">Building</a></h3> <ul> @@ -1837,14 +1786,19 @@ have caveats: </div> </li> <li>Setup the Android build<ul> - <li>Create <code>ace/config.h</code>: <code>#include "ace/config-android.h"</code></li> + <li>Create <code>ace/config.h</code>: <code>#include "config-android.h"</code></li> <li>Create <code>include/makeinclude/platform_macros.GNU</code>: <ul> <li> - Set <code>ANDROID_ABI</code> to one of the options above. This - must match the toolchain <code>--arch</code> argument used according - to the table above. + Set <code>android_abi</code> to one of + <a href="#android_abis">the options above</a>. + If using a standalone toolchain this must match the + <code>--arch</code> argument used according + to <a href="#android_abi_toolchain_table">the table above</a>. </li> + <li>If using the NDK directly, set <code>android_ndk</code> to the + location of the extracted NDK and <code>android_api</code> to the API + level desired.</li> <li>Set options for debug and optimization options as desired.</li> <li>If you want to compile static, add <code>static_libs_only:=1</code></li> <li>Must include <code>include $(ACE_ROOT)/include/makeinclude/platform_android.GNU</code>.</li> @@ -1857,10 +1811,11 @@ have caveats: </li> </li> <li>Generate makefiles (if necessary).</li> - <li>Build with GNU make. Make sure you have <code>$TOOLCHAIN/bin</code> in - your <code>$PATH</code>. + <li>Build with GNU make. If using a standalone toolchain, make sure you + have <code>$TOOLCHAIN/bin</code> in your <code>$PATH</code>. <div class="boxed indent"><p> - <b>Windows Users:</b> Make sure you have <code>%TOOLCHAIN%\bin</code> + <b>Windows Users:</b> If using a standalone toolchain, + Make sure you have <code>%TOOLCHAIN%\bin</code> and MSYS2's <code>bin</code> in your <code>%PATH%</code> when building. If you are cross compiling TAO you will also need a preprocessor for <code>tao_idl</code> available (See Windows note above).</p> @@ -13,14 +13,30 @@ USER VISIBLE CHANGES BETWEEN ACE-6.5.12 and ACE-7.0.0 . Android Support: - . Support for building with the Android NDK directly instead of having to use - the generated standalone toolchain. See ACE-INSTALL.html for how to. - - . Made it eaiser to use gnuace built libraries in Android Studio native - projects. + . `gnuace` no longer supports Android NDKs before r18. This means only clang + is now supported when building for Android. - . Building with neon support is now the default when ANDROID_ABI is - armeabi-v7a. + . Support for building with the Android NDK directly instead of having to use + a generated standalone toolchain. See `ACE-INSTALL.html` for details. Using + a standalone toolchain is still supported. + + . Made it easier to use `gnuace`-built libraries in as imported libraries in + CMake-based Android Studio native projects. + + . Removed support for old `ANDROID_ARCH` make variable. Replaced + `ANDROID_ABI` with `android_abi`, but kept the former as an alias of the + later for compatibility. Also will no longer default to 32-bit ARM, so + `android_abi` or `ANDROID_ABI` must be defined. + + . As recommend by Google, building with neon support is now the default when + `android_abi` is `armeabi-v7a`. If support for these processors without + NEON extensions is needed, put `androind_neon := 0` in + `platform_macros.GNU`. + + . As recommend by Google, `gnuace` will start using LLD, the LLVM linker, + instead of the default GNU linkers. If the NDK being used doesn't default + to LLD and you want to use the GNU linkers, put `androind_set_lld := 0` in + `platform_macros.GNU`. USER VISIBLE CHANGES BETWEEN ACE-6.5.11 and ACE-6.5.12 ====================================================== diff --git a/ACE/ace/config-android.h b/ACE/ace/config-android.h index 6c975cb942d..7d9e0f4370d 100644 --- a/ACE/ace/config-android.h +++ b/ACE/ace/config-android.h @@ -10,14 +10,13 @@ // There is a large number of combinations of these two that can lead to // problems. -#if !defined (__ANDROID_API__) -# include <android/api-level.h> -#endif +#include <android/ndk-version.h> +#include <android/api-level.h> #define ACE_ANDROID #define ACE_PLATFORM_CONFIG config-android.h -#include "ace/config-linux-common.h" +#include "config-linux-common.h" /* * Android NDK Revision Macros @@ -49,20 +48,6 @@ #define ACE_ANDROID_NDK_LESS_THAN(MAJ, MIN, BET) \ !ACE_ANDROID_NDK_AT_LEAST((MAJ), (MIN), (BET)) -#ifndef ACE_ANDROID_NDK_MISSING_NDK_VERSION_H -# include <android/ndk-version.h> -#else -# ifndef __NDK_MAJOR__ -# error ndk-version.h is missing, __NDK_MAJOR__ for Android NDK must be defined! -# endif -# ifndef __NDK_MINOR__ -# error ndk-version.h is missing, __NDK_MINOR__ for Android NDK must be defined! -# endif -# ifndef __NDK_BETA__ -# define __NDK_BETA__ 0 -# endif -#endif - // ucontext.h and clock_settime() were added in r10c #if ACE_ANDROID_NDK_AT_LEAST(10, 2, 0) # define ACE_HAS_UCONTEXT_T diff --git a/ACE/include/makeinclude/platform_android.GNU b/ACE/include/makeinclude/platform_android.GNU index 92b894d5118..98e75ee178c 100644 --- a/ACE/include/makeinclude/platform_android.GNU +++ b/ACE/include/makeinclude/platform_android.GNU @@ -2,7 +2,7 @@ # This file allows ACE and applications using ACE GNU Makefiles to be built for # Android by cross compiling on Linux. - +# # See here for latest documentation on how to invoke the NDK: # https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md @@ -29,36 +29,29 @@ rwho = 0 # path from the host computer. versioned_so = 3 -# Only try to use clang, unless this is set to 0, then try to use g++ -android_force_clang ?= 1 - # This section deals with selecting the architecture/compiler # As of writing information on ABIs can be found at https://developer.android.com/ndk/guides/abis -ifndef ANDROID_ABI - ifdef ANDROID_ARCH # Handle possibility of ANDROID_ARCH being passed - ifeq ($(ANDROID_ARCH),arm) - ANDROID_ABI := armeabi-v7a - else - ANDROID_ABI := $(ANDROID_ARCH) - endif - else # Else default to ARMv7 - ANDROID_ABI := armeabi-v7a +ifndef android_abi + ifdef ANDROID_ABI + android_abi := $(ANDROID_ABI) + else + $(error android_abi or ANDROID_ABI must be defined) endif endif # Alias neon -ifeq ($(ANDROID_ABI), neon) - ANDROID_ABI := armeabi-v7a-with-neon +ifeq ($(android_abi), neon) + android_abi := armeabi-v7a-with-neon endif android_neon ?= 1 -ifeq ($(ANDROID_ABI),armeabi-v7a-with-neon) - ANDROID_ABI := armeabi-v7a +ifeq ($(android_abi),armeabi-v7a-with-neon) + android_abi := armeabi-v7a android_neon := 1 endif -ifeq ($(ANDROID_ABI),armeabi-v7a) +ifeq ($(android_abi),armeabi-v7a) CROSS_COMPILE := armv7a-linux-androideabi ifeq ($(android_neon),1) FLAGS_C_CC += -mfpu=neon @@ -68,26 +61,22 @@ ifeq ($(ANDROID_ABI),armeabi-v7a) # NDK says -Wl,--fix-cortex-a8 is required for working around a CPU bug # in some Cortex-A8 implementations LDFLAGS += -Wl,--fix-cortex-a8 -endif -ifeq ($(ANDROID_ABI),arm64-v8a) +else ifeq ($(android_abi),arm64-v8a) CROSS_COMPILE := aarch64-linux-android -endif -ifeq ($(ANDROID_ABI),x86) +else ifeq ($(android_abi),x86) CROSS_COMPILE := i686-linux-android -endif -ifeq ($(ANDROID_ABI),x86_64) +else ifeq ($(android_abi),x86_64) CROSS_COMPILE := x86_64-linux-android endif ifndef CROSS_COMPILE - $(error ANDROID_ABI $(ANDROID_ABI) is not valid) + $(error android_abi $(android_abi) is not valid) endif ifdef android_ndk - # If we are given the Android NDK path, use that instead of PATH. ifndef android_api $(error android_ndk also requires defining android_api) endif @@ -99,7 +88,7 @@ ifdef android_ndk # We dont want this being used again except to signal that this is a # cross-compile build. If it is this command (probably) wont exist. - CROSS_COMPILE := fake + CROSS_COMPILE := THIS_VALUE_SHOULD_NOT_BE_USED override_cross_compile = 1 CC = $(android_ndk_tools)/$(android_ndk_tool_prefix)clang @@ -113,29 +102,11 @@ else export CROSS_COMPILE endif -ifeq ($(android_force_clang),0) - ifdef android_api - $(error Must use a standalone toolchain to use GCC) - endif - - # Determine if the g++ compiler is GCC or Clang. - # There are at least 3 assumptions being made here: - # - There is a g++ command to get the version from - # - Clang will have "clang" in the version string - # - If g++ is actually clang, then we can replace that with clang++ - gplusplus_version = $(shell $(CROSS_COMPILE)g++$(CROSS_COMPILE_SUFFIX) --version) - actually_is_clang := $(strip $(findstring clang,$(gplusplus_version))) -else ifeq ($(android_force_clang),1) - actually_is_clang := 1 -else - $(error Invalid value for android_force_clang: $(android_force_clang)) -endif - FLAGS_C_CC += -W -Wall -Wpointer-arith ifeq ($(threads),1) - CPPFLAGS += -D_REENTRANT + CPPFLAGS += -D_REENTRANT ifdef PLATFORM_AIO_SUPPORT - CPPFLAGS += $(PLATFORM_AIO_SUPPORT) + CPPFLAGS += $(PLATFORM_AIO_SUPPORT) endif endif # threads @@ -151,22 +122,19 @@ LD_RPATH_FLAGS += -Wl,--enable-new-dtags # for you): _SVID_SOURCE _BSD_SOURCE _POSIX_SOURCE _POSIX_C_SOURCE=199506L, ... CPPFLAGS += -D_GNU_SOURCE +android_set_lld ?= 1 +ifeq ($(android_set_lld),1) + # Use the LLVM linker as recommended by Google + # The other two arguments are explained by + # https://android.googlesource.com/platform/ndk/+/master/docs/BuildSystemMaintainers.md#additional-required-arguments + LDFLAGS += -fuse-ld=lld -Wl,--build-id=sha1 -Wl,--no-rosegment +endif + DCFLAGS += -ggdb DCCFLAGS += -ggdb DLD = $(CXX) LD = $(CXX) $(PIE) -ifndef actually_is_clang - # make sure to add the required libs for RTTI and exceptions (libsupc++) - # and a shared STL lib (libgnustl_shared by default) - static_libs_only ?= - ANDROID_STL_DLL ?= gnustl_shared - LIBS += -ldl -lsupc++ - ifneq ($(static_libs_only),1) - LIBS += -l$(ANDROID_STL_DLL) - endif -endif - ifeq ($(optimize),1) SOFLAGS += -Wl,-O3 endif @@ -176,27 +144,7 @@ SOBUILD = $(COMPILE.cc) $(PIC) -o $(VSHDIR)$*.so $<; \ $(SOLINK.cc) -o $@ $(LDFLAGS) $(VSHDIR)$*.o PRELIB = @true -ifdef actually_is_clang - include $(ACE_ROOT)/include/makeinclude/platform_clang_common.GNU -else - include $(ACE_ROOT)/include/makeinclude/platform_g++_common.GNU -endif - -ifneq ($(shell echo '\#include <android/ndk-version.h>' | $(CXX) -E - > /dev/null 2>&1; echo $$?), 0) - CPPFLAGS += -DACE_ANDROID_NDK_MISSING_NDK_VERSION_H -endif - -ifdef __NDK_MAJOR__ - CPPFLAGS += -D__NDK_MAJOR__=$(__NDK_MAJOR__) -endif - -ifdef __NDK_MINOR__ - CPPFLAGS += -D__NDK_MINOR__=$(__NDK_MINOR__) -endif - -ifdef __NDK_BETA__ - CPPFLAGS += -D__NDK_BETA__=$(__NDK_BETA__) -endif +include $(ACE_ROOT)/include/makeinclude/platform_clang_common.GNU OCFLAGS ?= -O3 OCCFLAGS ?= -O3 |