Fix rpl_malloc when cross compiling

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.
This commit is contained in:
Fredrik Fornwall 2015-11-15 16:04:37 -05:00
parent fc28d8f4d1
commit 150f95af27
15 changed files with 11 additions and 18 deletions

View File

@ -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

View File

@ -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 \

View 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

View 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"

View 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"

View 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"

View 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

View 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"

View 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"

View 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?"

View 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"

View 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".

View 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"

View 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"

View 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