Browse Source

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.
android-5
Fredrik Fornwall 9 years ago
parent
commit
150f95af27
  1. 5
      README.md
  2. 6
      build-package.sh
  3. 1
      packages/bison/build.sh
  4. 1
      packages/cboard/build.sh
  5. 1
      packages/flex/build.sh
  6. 1
      packages/gnuchess/build.sh
  7. 2
      packages/gnushogi/build.sh
  8. 2
      packages/gtypist/build.sh
  9. 1
      packages/pick/build.sh
  10. 2
      packages/procps/build.sh
  11. 1
      packages/psmisc/build.sh
  12. 1
      packages/sshpass/build.sh
  13. 2
      packages/teseq/build.sh
  14. 1
      packages/wcalc/build.sh
  15. 2
      packages/xmlstarlet/build.sh

5
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

6
build-package.sh

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

1
packages/bison/build.sh

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

1
packages/cboard/build.sh

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

1
packages/flex/build.sh

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

1
packages/gnuchess/build.sh

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

2
packages/gnushogi/build.sh

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

2
packages/gtypist/build.sh

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

1
packages/pick/build.sh

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

2
packages/procps/build.sh

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

1
packages/psmisc/build.sh

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

1
packages/sshpass/build.sh

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

2
packages/teseq/build.sh

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

1
packages/wcalc/build.sh

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

2
packages/xmlstarlet/build.sh

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

Loading…
Cancel
Save