Use -mthumb when building for arm
[termux-packages] / build-package.sh
index d67f72a..f0f1190 100755 (executable)
@@ -207,7 +207,7 @@ termux_step_setup_variables() {
        TERMUX_STANDALONE_TOOLCHAIN="$TERMUX_TOPDIR/_lib/toolchain-${TERMUX_ARCH}-ndk${TERMUX_NDK_VERSION}-api${TERMUX_API_LEVEL}"
        # Bump the below version if a change is made in toolchain setup to ensure
        # that everyone gets an updated toolchain:
-       TERMUX_STANDALONE_TOOLCHAIN+="-v8"
+       TERMUX_STANDALONE_TOOLCHAIN+="-v9"
 
        export TERMUX_TAR="tar"
        export TERMUX_TOUCH="touch"
@@ -462,10 +462,10 @@ termux_step_setup_toolchain() {
        # and no longer remove DT_RUNPATH in termux-elf-cleaner.
 
        if [ "$TERMUX_ARCH" = "arm" ]; then
-               CFLAGS+=" -march=armv7-a -mfpu=neon -mfloat-abi=softfp"
-               # "first flag instructs the linker to pick libgcc.a, libgcov.a, and
-               # crt*.o, which are tailored for armv7-a"
-               # - https://developer.android.com/ndk/guides/standalone_toolchain.html
+               # https://developer.android.com/ndk/guides/standalone_toolchain.html#abi_compatibility:
+               # "We recommend using the -mthumb compiler flag to force the generation of 16-bit Thumb-2 instructions".
+               # With r13 of the ndk ruby 2.4.0 segfaults when built on arm with clang without -mthumb.
+               CFLAGS+=" -march=armv7-a -mfpu=neon -mfloat-abi=softfp -mthumb"
                LDFLAGS+=" -march=armv7-a -Wl,--fix-cortex-a8"
        elif [ "$TERMUX_ARCH" = "i686" ]; then
                # From $NDK/docs/CPU-ARCH-ABIS.html:
@@ -537,6 +537,8 @@ termux_step_setup_toolchain() {
                        # Use gold by default to work around https://github.com/android-ndk/ndk/issues/148
                        cp $_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld.gold \
                           $_TERMUX_TOOLCHAIN_TMPDIR/bin/aarch64-linux-android-ld
+                       cp $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld.gold \
+                          $_TERMUX_TOOLCHAIN_TMPDIR/aarch64-linux-android/bin/ld
                fi
 
                cd $_TERMUX_TOOLCHAIN_TMPDIR/sysroot