Fix rpl_malloc when cross compiling
authorFredrik Fornwall <fredrik@fornwall.net>
Sun, 15 Nov 2015 21:04:37 +0000 (16:04 -0500)
committerFredrik Fornwall <fredrik@fornwall.net>
Sun, 15 Nov 2015 21:04:37 +0000 (16:04 -0500)
Work around rpl_malloc being used, see
http://wiki.buici.com/xwiki/bin/view/Programing+C+and+C%2B%2B/Autoconf+and+RPL_MALLOC
for more information:

"The AC_FUNC_MALLOC macro makes sure that the malloc function when passed a zero
argument returns a valid memory block instead of a NULL pointer. This behaviour
conforms to the GNU C library.  Normally, this is a reasonable test that autoconf
makes at build-time. In the case of cross-compilation, however, autoconf cannot
execute a program to verify proper behavior.  It makes the conservative assumption
that the target library will produce non-conforming code.

Failure of this test causes autconf to replace malloc() calls with rpl_malloc()
calls. At link time, if there is no rpl_malloc() function, the linker will fail
with an error describing the missing symbol. The autoconf documentation recommends
adding this harmless code to the application to implement the function."

In Termux the rpl_malloc() usage is useless at best, and may also prevent building
some packages as well as giving runtime crashes for libgc-using packages or others
expecting to intercept malloc.

Previously some packages specified worked around this themselves, but the configure
arguments are now moved into build-package.sh.

15 files changed:
README.md
build-package.sh
packages/bison/build.sh
packages/cboard/build.sh
packages/flex/build.sh
packages/gnuchess/build.sh
packages/gnushogi/build.sh
packages/gtypist/build.sh
packages/pick/build.sh
packages/procps/build.sh
packages/psmisc/build.sh
packages/sshpass/build.sh
packages/teseq/build.sh
packages/wcalc/build.sh
packages/xmlstarlet/build.sh

index 0db62fd..e3c7a10 100644 (file)
--- a/README.md
+++ b/README.md
@@ -109,11 +109,6 @@ contains these and may be used by all packages.
 
 * glob(3) system function (glob.h) - not in bionic, but use the `libandroid-glob` package
 
-* undefined reference to 'rpl_malloc' and/or 'rpl_realloc': These functions are added by some autoconf setups
-  when it fails to detect 0-safe malloc and realloc during cross-compilating. Avoided by defining
-  "ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes".
-  See http://wiki.buici.com/xwiki/bin/view/Programing+C+and+C%2B%2B/Autoconf+and+RPL_MALLOC
-
 * cmake and cross compiling: http://www.cmake.org/Wiki/CMake_Cross_Compiling
   CMAKE_FIND_ROOT_PATH=$TERMUX_PREFIX to search there.
   CMAKE_FIND_ROOT_PATH_MODE_LIBRARY=ONLY and
index a862244..eb04618 100755 (executable)
@@ -339,11 +339,17 @@ termux_step_configure () {
        set -e -o pipefail
        export PATH=$TERMUX_PKG_TMPDIR/config-scripts:$PATH
 
+       # See http://wiki.buici.com/xwiki/bin/view/Programing+C+and+C%2B%2B/Autoconf+and+RPL_MALLOC
+       # about this problem which may cause linker errors in test scripts not undef:ing malloc and
+       # also cause problems with e.g. malloc interceptors such as libgc:
+       local AVOID_AUTOCONF_WRAPPERS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
+
        $TERMUX_PKG_SRCDIR/configure \
                --disable-dependency-tracking \
                --prefix=$TERMUX_PREFIX \
                 --disable-rpath --disable-rpath-hack \
                $HOST_FLAG \
+               $AVOID_AUTOCONF_WRAPPERS \
                $TERMUX_PKG_EXTRA_CONFIGURE_ARGS \
                $DISABLE_NLS \
                $ENABLE_SHARED \
index 9dd47fe..5a6c50c 100644 (file)
@@ -3,5 +3,4 @@ TERMUX_PKG_DESCRIPTION="General-purpose parser generator"
 TERMUX_PKG_VERSION=3.0.4
 TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/bison/bison-${TERMUX_PKG_VERSION}.tar.xz
 TERMUX_PKG_BUILD_IN_SRC=yes
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
 TERMUX_PKG_HOSTBUILD=true
index b80ec7a..9f354fb 100644 (file)
@@ -3,7 +3,6 @@ TERMUX_PKG_DESCRIPTION="PGN browser, editor and chess engine frontend"
 TERMUX_PKG_VERSION=0.7.3
 TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/project/c-board/${TERMUX_PKG_VERSION}/cboard-${TERMUX_PKG_VERSION}.tar.bz2
 TERMUX_PKG_DEPENDS="libandroid-support,libandroid-glob,gnuchess, ncurses, ncurses-ui-libs"
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
 
 CFLAGS+=" -DLINE_MAX=_POSIX2_LINE_MAX"
 LDFLAGS+=" -landroid-glob"
index 3a25749..19a5bce 100644 (file)
@@ -2,4 +2,3 @@ TERMUX_PKG_HOMEPAGE=http://flex.sourceforge.net/
 TERMUX_PKG_DESCRIPTION="Fast lexical analyser generator"
 TERMUX_PKG_VERSION=2.5.39
 TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/project/flex/flex-${TERMUX_PKG_VERSION}.tar.xz
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
index abedfed..05492b6 100644 (file)
@@ -3,5 +3,4 @@ TERMUX_PKG_DESCRIPTION="Chess-playing program"
 TERMUX_PKG_VERSION=6.2.2
 TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/chess/gnuchess-${TERMUX_PKG_VERSION}.tar.gz
 TERMUX_PKG_DEPENDS="ncurses, readline"
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
 TERMUX_PKG_RM_AFTER_INSTALL="bin/gnuchessu bin/gnuchessx"
index 3320a56..9145f2a 100644 (file)
@@ -2,7 +2,7 @@ TERMUX_PKG_HOMEPAGE=http://www.gnu.org/software/gnushogi/
 TERMUX_PKG_DESCRIPTION="Program that plays the game of Shogi, also known as Japanese Chess"
 TERMUX_PKG_VERSION=1.4.2
 TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/gnushogi/gnushogi-${TERMUX_PKG_VERSION}.tar.gz
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes ac_cv_lib_curses_clrtoeol=yes --with-curses"
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_lib_curses_clrtoeol=yes --with-curses"
 TERMUX_PKG_RM_AFTER_INSTALL="info/gnushogi.info"
 TERMUX_PKG_DEPENDS="ncurses"
 TERMUX_PKG_HOSTBUILD=yes
index d17674e..4726c1d 100644 (file)
@@ -3,5 +3,5 @@ TERMUX_PKG_DESCRIPTION="Universal typing tutor"
 TERMUX_PKG_VERSION=2.9.5
 TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/gtypist/gtypist-${TERMUX_PKG_VERSION}.tar.xz
 TERMUX_PKG_DEPENDS="libandroid-support, ncurses"
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_header_ncursesw_ncurses_h=yes ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes --enable-nls=no ac_cv_header_libintl_h=no"
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_header_ncursesw_ncurses_h=yes --enable-nls=no ac_cv_header_libintl_h=no"
 TERMUX_PKG_RM_AFTER_INSTALL="share/emacs/site-lisp bin/typefortune share/man/man1/typefortune.1"
index 776209c..00a0bc5 100644 (file)
@@ -2,5 +2,4 @@ TERMUX_PKG_HOMEPAGE=https://github.com/thoughtbot/pick
 TERMUX_PKG_DESCRIPTION="Utility to choose one option from a set of choices with fuzzy search functionality"
 TERMUX_PKG_VERSION=1.2.1
 TERMUX_PKG_SRCURL=https://github.com/thoughtbot/pick/releases/download/v${TERMUX_PKG_VERSION}/pick-${TERMUX_PKG_VERSION}.tar.gz
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
 TERMUX_PKG_DEPENDS="ncurses"
index f9af9f8..7f3d612 100644 (file)
@@ -5,7 +5,7 @@ TERMUX_PKG_BUILD_REVISION=1
 TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/project/procps-ng/Production/procps-ng-${TERMUX_PKG_VERSION}.tar.xz
 TERMUX_PKG_BUILD_IN_SRC=yes
 TERMUX_PKG_FOLDERNAME=procps-ng-${TERMUX_PKG_VERSION}
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes ac_cv_search_dlopen= --enable-sigwinch"
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_search_dlopen= --enable-sigwinch"
 TERMUX_PKG_DEPENDS="ncurses"
 # https://bugs.launchpad.net/ubuntu/+source/coreutils/+bug/141168:
 # "For compatibility between distributions, can we have /bin/kill made available from coreutils?"
index 1f00960..aa099a6 100644 (file)
@@ -3,7 +3,6 @@ TERMUX_PKG_DESCRIPTION="Some small useful utilities that use the proc filesystem
 TERMUX_PKG_DEPENDS="ncurses"
 TERMUX_PKG_VERSION=22.21
 TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/project/psmisc/psmisc/psmisc-${TERMUX_PKG_VERSION}.tar.gz
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
 TERMUX_PKG_RM_AFTER_INSTALL="bin/pstree.x11"
 
 CFLAGS+=" -DTERMUX_EXPOSE_MEMPCPY=1"
index f4fbc77..66bf6a6 100644 (file)
@@ -2,4 +2,3 @@ TERMUX_PKG_HOMEPAGE=http://sourceforge.net/projects/sshpass/
 TERMUX_PKG_DESCRIPTION="Noninteractive ssh password provider"
 TERMUX_PKG_VERSION=1.05
 TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/project/sshpass/sshpass/${TERMUX_PKG_VERSION}/sshpass-${TERMUX_PKG_VERSION}.tar.gz
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes".
index ab7e0b4..9dcf580 100644 (file)
@@ -2,4 +2,4 @@ TERMUX_PKG_HOMEPAGE=http://www.gnu.org/software/teseq/
 TERMUX_PKG_DESCRIPTION="Tool for analyzing control characters and terminal control sequences"
 TERMUX_PKG_VERSION=1.1.1
 TERMUX_PKG_SRCURL=http://ftp.gnu.org/gnu/teseq/teseq-${TERMUX_PKG_VERSION}.tar.xz
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="teseq_cv_vsnprintf_works=yes ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS="teseq_cv_vsnprintf_works=yes"
index 3a93120..9798ea5 100644 (file)
@@ -4,4 +4,3 @@ TERMUX_PKG_VERSION=2.5
 TERMUX_PKG_BUILD_REVISION=1
 TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/w-calc/wcalc-${TERMUX_PKG_VERSION}.tar.bz2
 TERMUX_PKG_DEPENDS="flex,libmpfr,libgmp,readline"
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
index 6ec161a..7c10496 100644 (file)
@@ -3,5 +3,5 @@ TERMUX_PKG_DESCRIPTION="Command line XML toolkit"
 TERMUX_PKG_VERSION=1.6.1
 TERMUX_PKG_SRCURL=http://downloads.sourceforge.net/project/xmlstar/xmlstarlet/${TERMUX_PKG_VERSION}/xmlstarlet-${TERMUX_PKG_VERSION}.tar.gz
 TERMUX_PKG_DEPENDS="libxslt"
-TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-libxml-include-prefix=${TERMUX_PREFIX}/include/libxml2 ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes"
+TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--with-libxml-include-prefix=${TERMUX_PREFIX}/include/libxml2"
 TERMUX_PKG_BUILD_IN_SRC=yes