From b68951db6919496d88f1ee2c72f5ad98ce80f8e1 Mon Sep 17 00:00:00 2001 From: Frederik Carlier Date: Fri, 3 Mar 2017 22:16:55 +0100 Subject: [PATCH] Support local stack unwinding on Android (dotnet/coreclr#9940) Commit migrated from https://github.com/dotnet/coreclr/commit/39196d8665e44907ad2a01400940c75f5fde9a25 --- src/coreclr/cross/build-android-rootfs.sh | 13 +++++++++---- src/coreclr/src/pal/src/CMakeLists.txt | 21 +++++++++++++-------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/coreclr/cross/build-android-rootfs.sh b/src/coreclr/cross/build-android-rootfs.sh index 7627294..2e9cb0b 100755 --- a/src/coreclr/cross/build-android-rootfs.sh +++ b/src/coreclr/cross/build-android-rootfs.sh @@ -122,18 +122,23 @@ cp -R $__Android_Cross_Dir/tmp/$__AndroidArch/data/data/com.termux/files/usr/* $ # Prepare libunwind if [ ! -d $__libunwind_Dir ]; then - git clone https://android.googlesource.com/platform/external/libunwind/ $__libunwind_Dir +# Currently, we clone a fork of libunwind which adds support for Android; once this fork has been +# merged back in, this script can be updated to use the official libunwind repository. +# There's also an Android fork of libunwind which is currently not used. +# git clone https://android.googlesource.com/platform/external/libunwind/ $__libunwind_Dir +# git clone https://github.com/libunwind/libunwind/ $__libunwind_Dir + git clone https://github.com/qmfrederik/libunwind/ $__libunwind_Dir fi cd $__libunwind_Dir -git checkout android-6.0.0_r26 +git checkout features/android git checkout -- . git clean -xfd # libunwind is available on Android, but not included in the NDK. echo Building libunwind autoreconf --force -v --install 2> /dev/null -./configure CC=$__ToolchainDir/bin/$__AndroidArch-linux-android-clang --with-sysroot=$__ToolchainDir/sysroot --host=x86_64 --target=$__AndroidArch-eabi --disable-coredump --prefix=$__ToolchainDir/sysroot/usr 2> /dev/null +./configure CC=$__ToolchainDir/bin/$__AndroidArch-linux-android-clang --with-sysroot=$__ToolchainDir/sysroot --host=$__AndroidArch-eabi --target=$__AndroidArch-eabi --disable-tests --disable-coredump --prefix=$__ToolchainDir/sysroot/usr 2> /dev/null make > /dev/null make install > /dev/null @@ -141,5 +146,5 @@ make install > /dev/null cp include/libunwind.h $__ToolchainDir/sysroot/usr/include/ echo Now run: -echo CONFIG_DIR=\`realpath cross/android/arm64\` ROOTFS_DIR=\`realpath $__ToolchainDir/sysroot\` ./build.sh cross arm64 skipgenerateversion skipmscorlib cmakeargs -DENABLE_LLDBPLUGIN=0 +echo CONFIG_DIR=\`realpath cross/android/arm64\` ROOTFS_DIR=\`realpath $__ToolchainDir/sysroot\` ./build.sh cross arm64 skipgenerateversion skipnuget cmakeargs -DENABLE_LLDBPLUGIN=0 diff --git a/src/coreclr/src/pal/src/CMakeLists.txt b/src/coreclr/src/pal/src/CMakeLists.txt index 192c8c0..3ff2fa8 100644 --- a/src/coreclr/src/pal/src/CMakeLists.txt +++ b/src/coreclr/src/pal/src/CMakeLists.txt @@ -291,21 +291,26 @@ if(CMAKE_SYSTEM_NAME STREQUAL Linux) endif() if(CLR_CMAKE_PLATFORM_ANDROID) + find_library(LZMA NAMES lzma) + + if(LZMA STREQUAL LZMA-NOTFOUND) + message(FATAL_ERROR "Cannot find liblzma.") + endif(LZMA STREQUAL LZMA-NOTFOUND) + target_link_libraries(coreclrpal gnustl_shared android-support - android-glob) + android-glob + ${LZMA}) endif() - if(NOT CLR_CMAKE_PLATFORM_ANDROID) - find_library(UNWIND NAMES unwind) + find_library(UNWIND NAMES unwind) - if(UNWIND STREQUAL UNWIND-NOTFOUND) - message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8-dev and libunwind8.") - endif(UNWIND STREQUAL UNWIND-NOTFOUND) + if(UNWIND STREQUAL UNWIND-NOTFOUND) + message(FATAL_ERROR "Cannot find libunwind. Try installing libunwind8-dev and libunwind8.") + endif(UNWIND STREQUAL UNWIND-NOTFOUND) - target_link_libraries(coreclrpal ${UNWIND}) - endif() + target_link_libraries(coreclrpal ${UNWIND}) if(CLR_MAKE_PLATFORM_ANDROID) find_library(ANDROID_SUPPORT NAMES android-support) -- 2.7.4