Subject: bug#27320: 'Segmentation fault' when compiling Guile 2.2.2 under Termux (Android)

From: Phil Bewig <[email-masked]>
Date: Sat, 10 Jun 2017 18:06:26 -0500

I have a Lenovo TAB 2 A10-70F tablet computer running Android 5.0.1 on an
ARM Cortex A53 Quad-Core processor with 2B RAMexit clocked at 1.7 GHz. I am
running Termux 0.49, available from the Google Play Store, which provides a
unix-like environment on the tablet, but without rooting it, and Termux:API
0.15, also available from the Google Play Store, which gives Termux access
to the tablet hardware.

Termux is strange, probably because it must behave as an Android app since
it does not root the device. Running 'uname -a' reports 'Linux localhost
3.10.61 #2 SMP PREEMPT Mon Oct 17 17:46:54 CST 2016 aarch64 Android' and
'whoami' reports 'u0_a111'; there is only a single user, who has superuser
permissions. The Termux file tree is rooted at /data/data/com/termux/files;
I have exported environment variable $TERMUX with that value, and Termux
itself exports $PREFIX to point to what I call $TERMUX/usr. Under $TERMUX
are home and usr. Under usr are directories bin, etc, include, lib,
libexec, share, src, tmp and var. There are lots of libraries (.so) in lib,
lots of headers (.h) in include, and even more headers in include/linux.
The environment sets several variables of interest, including
BASH=$TERMUX/usr/bin/bash, HOSTTYPE=aarch64,
LD_LIBRARY_PATH=$TERMUX/usr/lib, MACHTYPE=aarch64-unknown-linux-android,
OSTYPE=linux-android, PATH=$TERMUX/usr/bin:$TERMUX/usr/bin/applets,
SHELL=$TERMUX/usr/bin/bash, and TMPDIR=$TERMUX/usr/tmp, where I have
written $TERMUX for convenience (the environment has the entire path
written out in every case). I have installed gawk and m4 for my own use
(and probably a few other things too, though I don't remember them at the
moment).

I am trying to install the Guile Scheme interpreter. I performed the
following steps:

    cd /data/data/com.termux/files/usr/src
    wget ftp://ftp.gnu.org/gnu/guile/guile-2.0.14.tar.gz
    tar -zxvf guile-2.0.14.tar.gz
    cd guile-2.0.14
    apt install libtool libunistring libunistring-dev \
        libgc libgc-dev libgmp-dev pkg-config libffi-dev
    termux-fix-shebang configure build-aux/config.sub \
        build-aux/install-sh libguile/guile-snarf* \
        meta/build-env*
    ./configure SHELL='/data/data/com.termux/files/usr/bin/sh' \
        CPPFLAGS='-I/data/data/com.termux/files/usr/bin/include:
            /data/data/com.termux/files/usr/bin/include/linux' \
        LDFLAGS='-L/data/data/com.termux/files/usr/lib
    make

At this point I get an error about being unable to find guild, so I fix the
shebang on file meta/guild, which is built early in the make process, and
continue:

    termux-fix-shebang meta/guild
    make

The make command ends with an error. After entering directory
'/data/data/com.termux/files/usr/src/guile-2.0.14/libguile' and executing
'GEN guile-procedures.texi' I get an error message 'CANNOT LINK EXECUTABLE:
could not load library "libguile-2.0.so.22" needed by
"/data/data/com.termux/files/usr/src/guile-2.0.14/libguile/.libs/lt-guile";
cause by library "libguile-2.0.so.22 not found'. I note that file
libguile-2.0.so.22 exists in directory
/data/data/com.termux/files/usr/src/guile-2.0.14/libguile/.libs. I fix the
error by linking libguile-2.0.so.22, then continue:

    ln libguile/.libs/libguile-2.0.so.22
/data/data/com.termux/files/usr/lib/libguile-2.0.so.22
    make

The I get another error: "Segmentation fault". The error occurs when make
is trying to execute guild snarf-check-and-output-texi; I note there is a
Scheme script snarf-check-and-output-texi.scm under module/scripts.

Exactly the same problem occurs with Guile 2.2.2. I actually started with
Guile 2.2.2, but switched to Guile 2.0.14 because it is the legacy branch
of the program and I was worried there might be something odd in the newer
version.

How can I fix this problem?