chiark / gitweb /
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 0db62fd8757500969b56016f5f7500e34eb61c4d..e3c7a10586b86ffdae7623b80d1f198b6aeb9355 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 a862244195e740a2ae0bfe431f65b94f7f24c28f..eb0461820da54f6471ac097a7c782653b7c5e179 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 9dd47fe9868e0860d0da0d8027ba04177645a9fe..5a6c50c7f6f8736b07b816175ccca1961d26f7e3 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 b80ec7a1362cd09a1b007597f9d9e3f0e0a234d3..9f354fb0bdba8fb20254a657aedbaa3bc6673338 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 3a257495adceb97083b26e597be13c03f4883d09..19a5bcec05650aec5de26c3a51b5347ccc818e13 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 abedfed044892da63832f57144f6d935a0d0ea56..05492b6ef081b20104d2805160164e9a559e10ed 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 3320a56595bbec2ac9df988b863cc7c691a1ff33..9145f2a1deada521d3697d10255359ca69bd608b 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 d17674e5b428e6dc466659a460f32abf9cad6560..4726c1dc618ded4ef1680e7333b88fdbf1d9b7ac 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 776209c56f1685333be279e7a4540bfcecf7da30..00a0bc52de6eb9b38ed544feb6f91d01e04dcc08 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 f9af9f8822f1d4d9b67525ea2e70f34951421bc9..7f3d6126acf60d00fc02a5c1548282f15b214944 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 1f009602417dfbbf4446834db53c6f1cc2e53bdf..aa099a61f8eb05fea68595e4f21b900fa8617b03 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 f4fbc77004fd0c291bc7312c6f400b94465830ef..66bf6a60d2757e5c6d157b5020bff66a0bfc21cd 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 ab7e0b4fe235d53d0487be322a1806a59ed96ced..9dcf580e2acc200d7f12af1c8f5479fe4ce3f384 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 3a93120ec79a839a162fa886e672716d0c7dc6e7..9798ea533348fe6ee0e46c5fd571183e5e491c31 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 6ec161a2b2e38d3f721c57d83a925cb97bf5519b..7c1049645c0ef02e2a4eb9d2082613384fc53d5a 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