From 150f95af271c7e32d66d94adbc7db6a8298d1693 Mon Sep 17 00:00:00 2001 From: Fredrik Fornwall Date: Sun, 15 Nov 2015 16:04:37 -0500 Subject: [PATCH] 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. --- README.md | 5 ----- build-package.sh | 6 ++++++ packages/bison/build.sh | 1 - packages/cboard/build.sh | 1 - packages/flex/build.sh | 1 - packages/gnuchess/build.sh | 1 - packages/gnushogi/build.sh | 2 +- packages/gtypist/build.sh | 2 +- packages/pick/build.sh | 1 - packages/procps/build.sh | 2 +- packages/psmisc/build.sh | 1 - packages/sshpass/build.sh | 1 - packages/teseq/build.sh | 2 +- packages/wcalc/build.sh | 1 - packages/xmlstarlet/build.sh | 2 +- 15 files changed, 11 insertions(+), 18 deletions(-) diff --git a/README.md b/README.md index 0db62fd8..e3c7a105 100644 --- 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 diff --git a/build-package.sh b/build-package.sh index a8622441..eb046182 100755 --- a/build-package.sh +++ b/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 \ diff --git a/packages/bison/build.sh b/packages/bison/build.sh index 9dd47fe9..5a6c50c7 100644 --- a/packages/bison/build.sh +++ b/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 diff --git a/packages/cboard/build.sh b/packages/cboard/build.sh index b80ec7a1..9f354fb0 100644 --- a/packages/cboard/build.sh +++ b/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" diff --git a/packages/flex/build.sh b/packages/flex/build.sh index 3a257495..19a5bcec 100644 --- a/packages/flex/build.sh +++ b/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" diff --git a/packages/gnuchess/build.sh b/packages/gnuchess/build.sh index abedfed0..05492b6e 100644 --- a/packages/gnuchess/build.sh +++ b/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" diff --git a/packages/gnushogi/build.sh b/packages/gnushogi/build.sh index 3320a565..9145f2a1 100644 --- a/packages/gnushogi/build.sh +++ b/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 diff --git a/packages/gtypist/build.sh b/packages/gtypist/build.sh index d17674e5..4726c1dc 100644 --- a/packages/gtypist/build.sh +++ b/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" diff --git a/packages/pick/build.sh b/packages/pick/build.sh index 776209c5..00a0bc52 100644 --- a/packages/pick/build.sh +++ b/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" diff --git a/packages/procps/build.sh b/packages/procps/build.sh index f9af9f88..7f3d6126 100644 --- a/packages/procps/build.sh +++ b/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?" diff --git a/packages/psmisc/build.sh b/packages/psmisc/build.sh index 1f009602..aa099a61 100644 --- a/packages/psmisc/build.sh +++ b/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" diff --git a/packages/sshpass/build.sh b/packages/sshpass/build.sh index f4fbc770..66bf6a60 100644 --- a/packages/sshpass/build.sh +++ b/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". diff --git a/packages/teseq/build.sh b/packages/teseq/build.sh index ab7e0b4f..9dcf580e 100644 --- a/packages/teseq/build.sh +++ b/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" diff --git a/packages/wcalc/build.sh b/packages/wcalc/build.sh index 3a93120e..9798ea53 100644 --- a/packages/wcalc/build.sh +++ b/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" diff --git a/packages/xmlstarlet/build.sh b/packages/xmlstarlet/build.sh index 6ec161a2..7c104964 100644 --- a/packages/xmlstarlet/build.sh +++ b/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 -- 2.11.0