Support local stack unwinding on Android (dotnet/coreclr#9940)
authorFrederik Carlier <frederik.carlier@quamotion.mobi>
Fri, 3 Mar 2017 21:16:55 +0000 (22:16 +0100)
committerJan Vorlicek <janvorli@microsoft.com>
Fri, 3 Mar 2017 21:16:55 +0000 (22:16 +0100)
Commit migrated from https://github.com/dotnet/coreclr/commit/39196d8665e44907ad2a01400940c75f5fde9a25

src/coreclr/cross/build-android-rootfs.sh
src/coreclr/src/pal/src/CMakeLists.txt

index 7627294..2e9cb0b 100755 (executable)
@@ -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
 
index 192c8c0..3ff2fa8 100644 (file)
@@ -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)