From d1f566f799e909c77879e7840922a8de49a0919c Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Thu, 27 Jul 2017 02:06:37 +0200 Subject: [PATCH] Attach arm issues with C++ exception unwinding See https://github.com/android-ndk/ndk/issues/379 Fixes #1163 Fixes issues with gdb segfaulting on arm on an unrecognized command. --- build-package.sh | 27 ++++++++++++++++++++++++--- packages/gdb/build.sh | 1 + packages/libprotobuf/build.sh | 2 +- packages/mosh/build.sh | 1 + 4 files changed, 27 insertions(+), 4 deletions(-) diff --git a/build-package.sh b/build-package.sh index 8b84f0e4..e502b178 100755 --- a/build-package.sh +++ b/build-package.sh @@ -562,6 +562,22 @@ termux_step_setup_toolchain() { $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld fi + if [ "$TERMUX_ARCH" = "arm" ]; then + # Linker wrapper script to add '--exclude-libs libgcc.a', see + # https://github.com/android-ndk/ndk/issues/379 + # https://android-review.googlesource.com/#/c/389852/ + local linker + for linker in ld ld.bfd ld.gold; do + local wrap_linker=$_TERMUX_TOOLCHAIN_TMPDIR/$TERMUX_HOST_PLATFORM/bin/$linker + local real_linker=$_TERMUX_TOOLCHAIN_TMPDIR/$TERMUX_HOST_PLATFORM/bin/$linker.real + cp $wrap_linker $real_linker + echo '#!/bin/bash' > $wrap_linker + echo -n '`dirname $0`/' >> $wrap_linker + echo -n $linker.real >> $wrap_linker + echo ' --exclude-libs libgcc.a "$@"' >> $wrap_linker + done + fi + cd $_TERMUX_TOOLCHAIN_TMPDIR/sysroot for f in $TERMUX_SCRIPTDIR/ndk-patches/*.patch; do @@ -598,8 +614,8 @@ termux_step_setup_toolchain() { fi local _STL_LIBFILE_NAME=libc++_shared.so - if [ ! -f $TERMUX_PREFIX/lib/libstdc++.so ] || [ `readlink $TERMUX_PREFIX/lib/libstdc++.so` != $_STL_LIBFILE_NAME ]; then - # Setup libgnustl_shared.so in $PREFIX/lib and libstdc++.so as a symlink to it, + if [ ! -f $TERMUX_PREFIX/lib/libstdc++.so ]; then + # Setup libgnustl_shared.so in $PREFIX/lib and libstdc++.so as a link to it, # so that other C++ using packages links to it instead of the default android # C++ library which does not support exceptions or STL: # https://developer.android.com/ndk/guides/cpp-support.html @@ -622,7 +638,12 @@ termux_step_setup_toolchain() { cp "$_STL_LIBFILE" . $STRIP --strip-unneeded $_STL_LIBFILE_NAME $TERMUX_ELF_CLEANER $_STL_LIBFILE_NAME - ln -f -s $_STL_LIBFILE_NAME libstdc++.so + if [ $TERMUX_ARCH = "arm" ]; then + # Use a linker script to get libunwind.a. + echo 'INPUT(-lunwind -lc++_shared)' > libstdc++.so + else + ln -f $_STL_LIBFILE_NAME libstdc++.so + fi fi export PKG_CONFIG_LIBDIR="$TERMUX_PKG_CONFIG_LIBDIR" diff --git a/packages/gdb/build.sh b/packages/gdb/build.sh index 12155c89..d96cc59f 100755 --- a/packages/gdb/build.sh +++ b/packages/gdb/build.sh @@ -2,6 +2,7 @@ TERMUX_PKG_HOMEPAGE=https://www.gnu.org/software/gdb/ TERMUX_PKG_DESCRIPTION="The standard GNU Debugger that runs on many Unix-like systems and works for many programming languages" TERMUX_PKG_DEPENDS="liblzma, libexpat, readline" TERMUX_PKG_VERSION=8.0 +TERMUX_PKG_REVISION=1 TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/gdb/gdb-${TERMUX_PKG_VERSION}.tar.xz TERMUX_PKG_SHA256=f6a24ffe4917e67014ef9273eb8b547cb96a13e5ca74895b06d683b391f3f4ee # gdb can not build with our normal --disable-static: https://sourceware.org/bugzilla/show_bug.cgi?id=15916 diff --git a/packages/libprotobuf/build.sh b/packages/libprotobuf/build.sh index caa6b91b..df885f15 100755 --- a/packages/libprotobuf/build.sh +++ b/packages/libprotobuf/build.sh @@ -1,7 +1,7 @@ TERMUX_PKG_HOMEPAGE=https://github.com/google/protobuf TERMUX_PKG_DESCRIPTION="Protocol buffers C++ library" TERMUX_PKG_VERSION=3.3.2 -TERMUX_PKG_REVISION=1 +TERMUX_PKG_REVISION=2 TERMUX_PKG_SRCURL=https://github.com/google/protobuf/archive/v${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_SHA256=8b8e442becbeff637f160c1ef4a3a56769c50ba7c9ff939ccc94086530ff00e4 TERMUX_PKG_FOLDERNAME=protobuf-$TERMUX_PKG_VERSION diff --git a/packages/mosh/build.sh b/packages/mosh/build.sh index 52d5fd9f..ee165c68 100644 --- a/packages/mosh/build.sh +++ b/packages/mosh/build.sh @@ -1,6 +1,7 @@ TERMUX_PKG_HOMEPAGE=https://mosh.org TERMUX_PKG_DESCRIPTION="Mobile shell that supports roaming and intelligent local echo" TERMUX_PKG_VERSION=1.3.2 +TERMUX_PKG_REVISION=1 TERMUX_PKG_SHA256=da600573dfa827d88ce114e0fed30210689381bbdcff543c931e4d6a2e851216 TERMUX_PKG_SRCURL=https://github.com/mobile-shell/mosh/releases/download/mosh-${TERMUX_PKG_VERSION}/mosh-${TERMUX_PKG_VERSION}.tar.gz TERMUX_PKG_FOLDERNAME=mosh-$TERMUX_PKG_VERSION -- 2.11.0