[Lldb-commits] [lldb] r301306 - Remove the home-grown android toolchain file and all references to it

Pavel Labath via lldb-commits lldb-commits at lists.llvm.org
Tue Apr 25 05:58:50 PDT 2017


Author: labath
Date: Tue Apr 25 07:58:49 2017
New Revision: 301306

URL: http://llvm.org/viewvc/llvm-project?rev=301306&view=rev
Log:
Remove the home-grown android toolchain file and all references to it

Summary:
The toolchain file has been deprecated in favor of the "official"
toolchain file present in the Android NDK. Also update the web
build instructions to reflect this.

Reviewers: eugene

Subscribers: srhines, mgorny, dgross, tberghammer, lldb-commits

Differential Revision: https://reviews.llvm.org/D32441

Removed:
    lldb/trunk/cmake/platforms/Android.cmake
Modified:
    lldb/trunk/www/build.html

Removed: lldb/trunk/cmake/platforms/Android.cmake
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/cmake/platforms/Android.cmake?rev=301305&view=auto
==============================================================================
--- lldb/trunk/cmake/platforms/Android.cmake (original)
+++ lldb/trunk/cmake/platforms/Android.cmake (removed)
@@ -1,155 +0,0 @@
-# Toolchain config for Android standalone NDK.
-#
-# Usage:
-# build host llvm and clang first
-# cmake -DCMAKE_TOOLCHAIN_FILE=../lldb/cmake/platforms/Android.cmake \
-#       -DANDROID_TOOLCHAIN_DIR=<toolchain_dir> \
-#       -DANDROID_ABI=<target_abi> \
-#       -DCMAKE_CXX_COMPILER_VERSION=<gcc_version> \
-#       -DLLVM_TARGET_ARCH=<llvm_target_arch> \
-#       -DLLVM_TARGETS_TO_BUILD=<llvm_targets_to_build> \
-#       -DLLVM_TABLEGEN=<path_to_llvm-tblgen> \
-#       -DCLANG_TABLEGEN=<path_to_clang-tblgen>
-#
-# Current Support:
-#   ANDROID_ABI = x86, x86_64
-#   CMAKE_CXX_COMPILER_VERSION = 4.9
-#   LLVM_TARGET_ARCH = X86
-#   LLVM_TARGETS_TO_BUILD = X86
-#   LLVM_TABLEGEN = path to host llvm-tblgen
-#   CLANG_TABLEGEN = path to host clang-tblgen
-
-if( DEFINED CMAKE_CROSSCOMPILING )
- return()
-endif()
-
-get_property( IS_IN_TRY_COMPILE GLOBAL PROPERTY IN_TRY_COMPILE )
-if( IS_IN_TRY_COMPILE )
- # this seems necessary and works fine but I'm unsure if it breaks anything
- return()
-endif()
-
-set( CMAKE_SYSTEM_NAME Android )
-include( CMakeForceCompiler )
-
-# flags and definitions
-add_definitions( -DANDROID -DLLDB_DISABLE_LIBEDIT )
-set( ANDROID True )
-set( LLDB_DEFAULT_DISABLE_LIBEDIT True )
-
-# linking lldb-server statically for Android avoids the need to ship two
-# binaries (pie for API 21+ and non-pie for API 16-). It's possible to use
-# a non-pie shim on API 16-, but that requires lldb-server to dynamically export
-# its symbols, which significantly increases the binary size. Static linking, on
-# the other hand, has little to no effect on the binary size.
-if( NOT DEFINED LLVM_BUILD_STATIC )
- set( LLVM_BUILD_STATIC True  CACHE INTERNAL "" FORCE )
- set( LLVM_ENABLE_PIC   FALSE CACHE INTERNAL "" FORCE )
- set( BUILD_SHARED_LIBS FALSE CACHE INTERNAL "" FORCE )
-endif()
-
-set( ANDROID_ABI "${ANDROID_ABI}" CACHE INTERNAL "Android Abi" FORCE )
-if( ANDROID_ABI STREQUAL "x86" )
- set( CMAKE_SYSTEM_PROCESSOR "i686" )
- set( ANDROID_TOOLCHAIN_NAME "i686-linux-android" )
-elseif( ANDROID_ABI STREQUAL "x86_64" )
- set( CMAKE_SYSTEM_PROCESSOR "x86_64" )
- set( ANDROID_TOOLCHAIN_NAME "x86_64-linux-android" )
-elseif( ANDROID_ABI STREQUAL "armeabi" )
- set( CMAKE_SYSTEM_PROCESSOR "armv5te" )
- set( ANDROID_TOOLCHAIN_NAME "arm-linux-androideabi" )
-elseif( ANDROID_ABI STREQUAL "aarch64" )
- set( CMAKE_SYSTEM_PROCESSOR "aarch64" )
- set( ANDROID_TOOLCHAIN_NAME "aarch64-linux-android" )
-elseif( ANDROID_ABI STREQUAL "mips" )
- set( CMAKE_SYSTEM_PROCESSOR "mips" )
- set( ANDROID_TOOLCHAIN_NAME "mipsel-linux-android" )
-elseif( ANDROID_ABI STREQUAL "mips64" )
- set( CMAKE_SYSTEM_PROCESSOR "mips64" )
- set( ANDROID_TOOLCHAIN_NAME "mips64el-linux-android" )
-else()
- message( SEND_ERROR "Unknown ANDROID_ABI = \"${ANDROID_ABI}\"." )
-endif()
-
-set( ANDROID_TOOLCHAIN_DIR "${ANDROID_TOOLCHAIN_DIR}" CACHE PATH "Android standalone toolchain directory" )
-set( ANDROID_SYSROOT "${ANDROID_TOOLCHAIN_DIR}/sysroot" CACHE PATH "Android Sysroot" )
-
-# CMAKE_EXECUTABLE_SUFFIX is undefined in CMAKE_TOOLCHAIN_FILE
-if( WIN32 )
- set( EXECUTABLE_SUFFIX ".exe" )
-endif()
-
-set( PYTHON_EXECUTABLE "${ANDROID_TOOLCHAIN_DIR}/bin/python${EXECUTABLE_SUFFIX}" CACHE PATH "Python exec path" )
-
-if( NOT CMAKE_C_COMPILER )
- set( CMAKE_C_COMPILER   "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-gcc${EXECUTABLE_SUFFIX}"     CACHE PATH "C compiler" )
- set( CMAKE_CXX_COMPILER "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-g++${EXECUTABLE_SUFFIX}"     CACHE PATH "C++ compiler" )
- set( CMAKE_ASM_COMPILER "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-gcc${EXECUTABLE_SUFFIX}"     CACHE PATH "assembler" )
- set( CMAKE_STRIP        "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-strip${EXECUTABLE_SUFFIX}"   CACHE PATH "strip" )
- set( CMAKE_AR           "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-ar${EXECUTABLE_SUFFIX}"      CACHE PATH "archive" )
- set( CMAKE_LINKER       "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-ld${EXECUTABLE_SUFFIX}"      CACHE PATH "linker" )
- set( CMAKE_NM           "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-nm${EXECUTABLE_SUFFIX}"      CACHE PATH "nm" )
- set( CMAKE_OBJCOPY      "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-objcopy${EXECUTABLE_SUFFIX}" CACHE PATH "objcopy" )
- set( CMAKE_OBJDUMP      "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-objdump${EXECUTABLE_SUFFIX}" CACHE PATH "objdump" )
- set( CMAKE_RANLIB       "${ANDROID_TOOLCHAIN_DIR}/bin/${ANDROID_TOOLCHAIN_NAME}-ranlib${EXECUTABLE_SUFFIX}"  CACHE PATH "ranlib" )
-endif()
-
-set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT} -funwind-tables -fsigned-char -no-canonical-prefixes" )
-# TODO: different ARM abi have different flags such as neon, vfpv etc
-if( X86 )
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funswitch-loops -finline-limit=300" )
-elseif( ANDROID_ABI STREQUAL "armeabi" )
- # 64 bit atomic operations used in c++ libraries require armv7-a instructions
- # armv5te and armv6 were tried but do not work.
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv7-a -mthumb" )
-elseif( ANDROID_ABI STREQUAL "mips" )
- # http://b.android.com/182094
- list( FIND LLDB_SYSTEM_LIBS atomic index )
- if( index EQUAL -1 )
-  list( APPEND LLDB_SYSTEM_LIBS atomic )
-  set( LLDB_SYSTEM_LIBS ${LLDB_SYSTEM_LIBS} CACHE INTERNAL "" FORCE )
- endif()
-endif()
-
-# Use gold linker and enable safe ICF in case of x86, x86_64 and arm
-if ( ANDROID_ABI STREQUAL "x86"    OR
-     ANDROID_ABI STREQUAL "x86_64" OR
-     ANDROID_ABI STREQUAL "armeabi")
- set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold -Wl,--icf=safe" )
-endif()
-
-if( NOT LLVM_BUILD_STATIC )
- # PIE is required for API 21+ so we enable it if we're not statically linking
- # unfortunately, it is not supported before API 16 so we need to do something
- # else there see http://llvm.org/pr23457
- set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -pie -fPIE" )
-endif()
-
-# linker flags
-set( ANDROID_CXX_FLAGS    "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
-set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" )
-
-# cache flags
-set( CMAKE_CXX_FLAGS           ""                        CACHE STRING "c++ flags" )
-set( CMAKE_C_FLAGS             ""                        CACHE STRING "c flags" )
-set( CMAKE_EXE_LINKER_FLAGS    "-Wl,-z,nocopyreloc"      CACHE STRING "executable linker flags" )
-set( ANDROID_CXX_FLAGS         "${ANDROID_CXX_FLAGS}"    CACHE INTERNAL "Android c/c++ flags" )
-set( ANDROID_LINKER_FLAGS      "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Android c/c++ linker flags" )
-
-# final flags
-set( CMAKE_CXX_FLAGS           "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
-set( CMAKE_C_FLAGS             "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
-set( CMAKE_EXE_LINKER_FLAGS    "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
-
-# global includes and link directories
-set( ANDROID_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_DIR}/include/c++/${ANDROID_COMPILER_VERSION}" )
-list( APPEND ANDROID_INCLUDE_DIRS "${ANDROID_TOOLCHAIN_DIR}/include/python2.7" )
-include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_INCLUDE_DIRS} )
-
-# target environment
-set( CMAKE_FIND_ROOT_PATH "${ANDROID_TOOLCHAIN_DIR}/bin" "${ANDROID_TOOLCHAIN_DIR}/${ANDROID_TOOLCHAIN_NAME}" "${ANDROID_SYSROOT}" )
-
-# only search for libraries and includes in the ndk toolchain
-set( CMAKE_FIND_ROOT_PATH_MODE_PROGRAM ONLY )
-set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY )
-set( CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

Modified: lldb/trunk/www/build.html
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/www/build.html?rev=301306&r1=301305&r2=301306&view=diff
==============================================================================
--- lldb/trunk/www/build.html (original)
+++ lldb/trunk/www/build.html Tue Apr 25 07:58:49 2017
@@ -354,9 +354,8 @@
               the target architecture. Since you already have a checkout of clang and lldb, you
               can compile a host version of clang in a separate folder and use that.
               Alternatively you can use system clang or even cross-gcc if your distribution
-              provides such packages (e.g., <code>g++-aarch64-linux-gnu</code> on Ubuntu). On
-              Android, a working toolchain can be produced by downloading the Android NDK and
-              running the contained <code>make-standalone-toolchain.sh</code> script.
+              provides such packages (e.g., <code>g++-aarch64-linux-gnu</code>
+              on Ubuntu).
             </p>
 
             <p>
@@ -381,11 +380,6 @@
             </p>
 
             <p>
-              In the case of Android, all required headers and libraries are provided by the
-              aforementioned <code>make-standalone-toolchain.sh</code> script.
-            </p>
-
-            <p>
               Once all of the dependencies are in place, it's just a matter of configuring the
               build system with the locations and arguments of all the necessary tools. The most
               important cmake options here are:
@@ -472,38 +466,37 @@
             <h3>Example 2: Cross-compiling for Android on Linux</h3>
 
             <p>
-              All tools needed to build LLDB for android are available in the Android NDK. For
-              example, we can produce an x86 toolchain along with all the libraries and headers
-              by running
+              In the case of Android, the toolchain and all required headers and
+              libraries are available in the Android NDK.
             </p>
-            <code>
-              ./build/tools/make-standalone-toolchain.sh \<br/>
-              --platform=android-21 \<br/>
-              --toolchain=x86-4.9 \<br/>
-              --install-dir=$HOME/Toolchains/x86-android-toolchain
-            </code>
+
             <p>
-              from inside the unzipped NDK. Toolchains for other architectures can be produced in
-              a similar manner.
+              The NDK also contains a cmake toolchain file, which makes
+              configuring the build much simpler.  The compiler, include and
+              library paths will be configured by the toolchain file and all you
+              need to do is to select the architecture (ANDROID_ABI) and
+              platform level (ANDROID_PLATFORM, should be at least 21). You will
+              also need to set ANDROID_ALLOW_UNDEFINED_SYMBOLS=On, as the
+              toolchain file defaults to "no undefined symbols in shared
+              libraries", which is not compatible with some llvm libraries. The
+              first version of NDK which supports this approach is r14.
             </p>
-
             <p>
-              For Android we provide a Android.cmake script which sets a lot of the required
-              options automatically. A cmake build can therefore be prepared with the following parameters:
+              For example, the following arguments are sufficient to configure
+              an android arm64 build:
             </p>
             <code>
-              -DCMAKE_TOOLCHAIN_FILE=cmake/platforms/Android.cmake \<br/>
-              -DANDROID_TOOLCHAIN_DIR=$HOME/Toolchains/x86-android-toolchain \<br/>
-              -DANDROID_ABI=x86 \<br/>
-              -DLLVM_HOST_TRIPLE=i386-unknown-linux-android \<br/>
-              -DLLVM_TABLEGEN=<path-to-host>/bin/llvm-tblgen \<br/>
-              -DCLANG_TABLEGEN=<path-to-host>/bin/clang-tblgen
+              -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake \<br/>
+              -DANDROID_ABI=arm64-v8a \<br/>
+              -DANDROID_PLATFORM=android-21 \<br/>
+              -DANDROID_ALLOW_UNDEFINED_SYMBOLS=On \<br/>
+              -DLLVM_HOST_TRIPLE=aarch64-unknown-linux-android \<br/>
+              -DCROSS_TOOLCHAIN_FLAGS_NATIVE='-DCMAKE_C_COMPILER=cc;-DCMAKE_CXX_COMPILER=c++' <br/>
             </code>
 
             <p>
-              Note that the full LLVM build is not functional on android yet, so simply running
-              <code>ninja</code> will not work. You will need to manually specify the target you
-              want to build: <code>lldb</code>, <code>lldb-server</code>, etc.
+              Note that currently only lldb-server is functional on android. The
+              lldb client is not supported and unlikely to work.
             </p>
           </div>
           <div class="postfooter"></div>




More information about the lldb-commits mailing list