Add fixes for debug builds (#2296)

* build-package.sh: add possibility for debug patches and TERMUX_PKG_HAS_DEBUG

Setting TERMUX_PKG_HAS_DEBUG=no disables attempt to build debug build of
package.
Useful for example if a debug build doesn't make sense, as for python-packages
and texlive.

* aapt: skip D_FORTIFY_SOURCE=2 for libandroid-cutils when doing debug build

* lftp: skip D_FORTIFY_SOURCE=2 for debug build

* libflac: don't use -g3 for debug build

Configure script removes it otherwise.

* nano: skip -D_FORTIFY_SOURCE=2 for debug build

* vifm: skip -D_FORTIFY_SOURCE=2 for debug build

* mc: skip -D_FORTIFY_SOURCE=2 for debug build

* dropbear: add __attribute__((overloadable)) to XMEMSET and XMEMCPY if debug

* gdb: add __attribute__((overloadable)) to strchr if debug

* gnuit: add __attribute__((overloadable)) to strchr and strcpy if debug

* gperf: add __attribute__((overloadable)) to strlen if debug

* inetutils: add __attribute__((overloadable)) to strrchr and strchr if debug

* readline: add __attribute__((overloadable)) to strchr if debug

* tsocks: add __attribute__((overloadable)) to poll if debug

* units: add __attribute__((overloadable)) to strchr if debug

* liblua: fix bug in loslib.c that emerged in debug build

Use strncpy instead of strcpy.
Original error message:
loslib.c:169:3: error: 'strcpy' called with string bigger than buffer
  lua_tmpnam(buff, err);
  ^
loslib.c:122:37: note: expanded from macro 'lua_tmpnam'
       strcpy(b, LUA_TMPNAMTEMPLATE); \
                                   ^

* alpine: include our getpass.h in imap's mtest.c to declare getpass

Debug build complained about the previous implicit declaration.

* nginx: use --with-debug instead of --debug

* cboard: skip -D_FORTIFY_SOURCE=2 for debug build

* gettext: add __attribute__((overloadable)) to getcwd if debug

* oathtool: skip -D_FORTIFY_SOURCE=2 for debug build

* php: add __attribute__((overloadable)) to strlcpy and strlcat if debug

* expect: add __attribute__((overloadable)) to strchr if debug

* texlive: set TERMUX_PKG_HAS_DEBUG=no

* asciinema: set TERMUX_PKG_HAS_DEBUG=no

* libllvm: set TERMUX_PKG_HAS_DEBUG=no

Debug build fails with:
home/builder/.termux-build/libllvm/src/lib/Support/Unix/Path.inc:740:19: error: no matching function for call to 'RetryAfterSignal'                                                                                                      if ((ResultFD = sys::RetryAfterSignal(-1, open, P.begin(), OpenFlags)) < 0)

* build-package.sh: set TERMUX_PKG_REPLACES=package if debug build

Hopefully allows us to install debug packages without breaking dependecies.

Should be looked over and be made more similar to how debian does this in any case

* Update build.sh
This commit is contained in:
Henrik Grimler 2018-06-13 02:12:36 +02:00 committed by Fredrik Fornwall
parent d2f1f9a62b
commit c1b82abd09
26 changed files with 291 additions and 4 deletions

View File

@ -328,6 +328,7 @@ termux_step_setup_variables() {
TERMUX_PKG_MAINTAINER="Fredrik Fornwall @fornwall"
TERMUX_PKG_CLANG=yes # does nothing for cmake based packages. clang is chosen by cmake
TERMUX_PKG_FORCE_CMAKE=no # if the package has autotools as well as cmake, then set this to prefer cmake
TERMUX_PKG_HAS_DEBUG=yes # set to no if debug build doesn't exist or doesn't work, for example for python based packages
unset CFLAGS CPPFLAGS LDFLAGS CXXFLAGS
}
@ -393,7 +394,12 @@ termux_step_start_build() {
fi
if [ "$TERMUX_DEBUG" == "true" ]; then
DEBUG="-dbg"
if [ "$TERMUX_PKG_HAS_DEBUG" == "yes" ]; then
DEBUG="-dbg"
else
echo "Skipping building debug build for $TERMUX_PKG_NAME"
exit 0
fi
else
DEBUG=""
fi
@ -405,6 +411,8 @@ termux_step_start_build() {
echo "$TERMUX_PKG_NAME@$TERMUX_PKG_FULLVERSION built - skipping (rm /data/data/.built-packages/$TERMUX_PKG_NAME to force rebuild)"
exit 0
fi
else
export TERMUX_PKG_REPLACES=${TERMUX_PKG_NAME}
fi
# Cleanup old state:
@ -758,9 +766,13 @@ termux_step_setup_toolchain() {
# Apply all *.patch files for the package. Not to be overridden by packages.
termux_step_patch_package() {
cd "$TERMUX_PKG_SRCDIR"
local DEBUG_PATCHES=""
if [ "$TERMUX_DEBUG" == "true" ] && [ -f $TERMUX_PKG_BUILDER_DIR/*.patch.debug ] ; then
DEBUG_PATCHES="$(ls $TERMUX_PKG_BUILDER_DIR/*.patch.debug)"
fi
# Suffix patch with ".patch32" or ".patch64" to only apply for these bitnesses:
shopt -s nullglob
for patch in $TERMUX_PKG_BUILDER_DIR/*.patch{$TERMUX_ARCH_BITS,}; do
for patch in $TERMUX_PKG_BUILDER_DIR/*.patch{$TERMUX_ARCH_BITS,} $DEBUG_PATCHES; do
test -f "$patch" && sed "s%\@TERMUX_PREFIX\@%${TERMUX_PREFIX}%g" "$patch" | \
sed "s%\@TERMUX_HOME\@%${TERMUX_ANDROID_HOME}%g" | \
patch --silent -p1

View File

@ -85,7 +85,17 @@ termux_step_make_install () {
socket_network_client_unix.c \
sockets_unix.o \
str_parms.c"
$CC $CFLAGS \
# -D_FORTIFY_SOURCE=2 makes debug build fail with:
# In file included from process_name.c:29:
# /data/data/com.termux/files/usr/include/aosp/cutils/properties.h:116:45: error: expected identifier
# __errordecl(__property_get_too_small_error, "property_get() called with too small of a buffer");
# ^
# /data/data/com.termux/files/usr/include/aosp/cutils/properties.h:119:5: error: static declaration of 'property_get' follows non-static declaration
# int property_get(const char *key, char *value, const char *default_value) {
# ^
# /data/data/com.termux/files/usr/include/aosp/cutils/properties.h:46:5: note: previous declaration is here
# int property_get(const char *key, char *value, const char *default_value);
$CC ${CFLAGS/-D_FORTIFY_SOURCE=2/} \
-Dchar16_t=uint16_t \
-std=c11 \
-isystem $AOSP_INCLUDE_DIR \

View File

@ -0,0 +1,10 @@
--- ./imap/src/mtest/mtest.c 2018-03-21 20:56:14.145999441 +0000
+++ ../mtest.c 2018-03-21 21:23:34.179966620 +0000
@@ -34,6 +34,7 @@
#include <signal.h>
#include "c-client.h"
#include "imap4r1.h"
+#include "../../include/getpass.h"
/* Excellent reasons to hate ifdefs, and why my real code never uses them */

View File

@ -5,6 +5,7 @@ TERMUX_PKG_SHA256=7087b247dae36d04821197bc14ebd4248049592b299c9878d8953c025ac802
TERMUX_PKG_SRCURL=https://github.com/asciinema/asciinema/archive/v${TERMUX_PKG_VERSION}.tar.gz
TERMUX_PKG_BUILD_IN_SRC=yes
TERMUX_PKG_PLATFORM_INDEPENDENT=yes
TERMUX_PKG_HAS_DEBUG=no
# ncurses-utils for tput which asciinema uses:
TERMUX_PKG_DEPENDS="python, ncurses-utils"

View File

@ -9,4 +9,10 @@ TERMUX_PKG_DEPENDS="libandroid-support,libandroid-glob,gnuchess, ncurses, ncurse
termux_step_pre_configure () {
CFLAGS+=" -DLINE_MAX=_POSIX2_LINE_MAX"
LDFLAGS+=" -landroid-glob"
if [ "$TERMUX_DEBUG" == "true" ]; then
# When doing debug build, -D_FORTIFY_SOURCE=2 gives this error:
# /home/builder/.termux-build/cboard/src/libchess/pgn.c:2235:33: error: 'umask' called with invalid mode
# mode = umask(600);
export CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
fi
}

View File

@ -0,0 +1,14 @@
--- ./libtomcrypt/src/headers/tomcrypt_cfg.h 2017-05-18 14:47:02.000000000 +0000
+++ ../tomcrypt_cfg.h 2018-03-17 08:49:37.958092137 +0000
@@ -35,9 +35,9 @@
LTC_EXPORT clock_t LTC_CALL XCLOCK(void);
/* various other functions */
-LTC_EXPORT void * LTC_CALL XMEMCPY(void *dest, const void *src, size_t n);
+LTC_EXPORT void * LTC_CALL __attribute__((overloadable)) XMEMCPY(void *dest, const void *src, size_t n);
LTC_EXPORT int LTC_CALL XMEMCMP(const void *s1, const void *s2, size_t n);
-LTC_EXPORT void * LTC_CALL XMEMSET(void *s, int c, size_t n);
+LTC_EXPORT void * LTC_CALL __attribute__((overloadable)) XMEMSET(void *s, int c, size_t n);
LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);

View File

@ -0,0 +1,11 @@
--- ./exp_strf.c 2000-01-06 23:22:05.000000000 +0000
+++ ../exp_strf.c 2018-03-22 19:58:34.428090961 +0000
@@ -99,7 +99,7 @@
#else
#ifndef strchr
-extern char *strchr(const char *str, int ch);
+extern char __attribute__((overloadable)) *strchr(const char *str, int ch);
#endif
extern char *getenv(const char *v);

View File

@ -0,0 +1,11 @@
--- ./readline/histlib.h 2017-06-04 15:51:27.000000000 +0000
+++ ../histlib.h 2018-03-21 15:09:37.286670845 +0000
@@ -52,7 +52,7 @@
#ifndef member
# ifndef strchr
-extern char *strchr ();
+extern char __attribute__((overloadable)) *strchr ();
# endif
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
#endif

View File

@ -0,0 +1,11 @@
--- ./gettext-runtime/intl/dcigettext.c 2016-05-19 06:49:42.000000000 +0000
+++ ../dcigettext.c 2018-03-22 06:18:22.714946338 +0000
@@ -144,7 +144,7 @@
# if VMS
# define getcwd(buf, max) (getcwd) (buf, max, 0)
# else
-char *getcwd ();
+char __attribute__((overloadable)) *getcwd ();
# endif
# endif
# ifndef HAVE_STPCPY

View File

@ -0,0 +1,31 @@
--- ./src/tilde.c 2009-02-18 02:31:26.000000000 +0000
+++ ../tilde.c 2018-03-17 21:38:36.637958669 +0000
@@ -47,7 +47,7 @@
#if !defined (savestring)
# ifndef strcpy
-extern char *strcpy ();
+extern char __attribute__((overloadable)) *strcpy ();
# endif
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif /* !savestring */
--- ./src/history.c 2009-02-18 02:31:26.000000000 +0000
+++ ../history.c 2018-03-17 21:38:21.789964199 +0000
@@ -61,7 +61,7 @@
#ifndef savestring
# ifndef strcpy
-extern char *strcpy ();
+extern char __attribute__((overloadable)) *strcpy ();
# endif
#define savestring(x) strcpy (xmalloc (1 + strlen (x)), (x))
#endif
@@ -80,7 +80,7 @@
#ifndef member
# ifndef strchr
-extern char *strchr ();
+extern char __attribute__((overloadable)) *strchr ();
# endif
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
#endif

View File

@ -0,0 +1,11 @@
--- ./lib/getopt.c 2017-01-02 11:35:39.000000000 +0000
+++ ../getopt.c 2018-03-01 10:44:56.641412033 +0000
@@ -210,7 +210,7 @@
}
extern int strcmp (const char *, const char *);
-extern size_t strlen (const char *);
+extern size_t __attribute__((overloadable)) strlen (const char *);
#endif /* not __GNU_LIBRARY__ */

View File

@ -0,0 +1,20 @@
--- ./telnet/commands.c 2015-03-31 15:40:50.000000000 +0000
+++ ../commands.c 2018-03-21 15:24:39.867877463 +0000
@@ -1584,7 +1584,7 @@
*/
register char *shellp, *shellname;
# ifndef strrchr
- extern char *strrchr (const char *, int);
+ extern char __attribute__((overloadable)) *strrchr (const char *, int);
# endif
shellp = getenv ("SHELL");
@@ -1881,7 +1881,7 @@
register char **epp, *cp;
register struct env_lst *ep;
#ifndef strchr
- extern char *strchr (const char *, int);
+ extern char __attribute__((overloadable)) *strchr (const char *, int);
#endif
for (epp = environ; *epp; epp++)

View File

@ -17,4 +17,9 @@ TERMUX_PKG_BUILD_DEPENDS="ncurses-dev"
termux_step_pre_configure () {
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-zlib=$TERMUX_STANDALONE_TOOLCHAIN/sysroot/usr"
if [ "$TERMUX_DEBUG" == "true" ]; then
# When doing debug build, -D_FORTIFY_SOURCE=2 gives this error:
# /home/builder/.termux-build/_lib/16-aarch64-21-v3/bin/../sysroot/usr/include/bits/fortify/string.h:79:26: error: use of undeclared identifier '__USE_FORTIFY_LEVEL'
export CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
fi
}

View File

@ -5,3 +5,13 @@ TERMUX_PKG_REVISION=3
TERMUX_PKG_SRCURL=http://downloads.xiph.org/releases/flac/flac-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=91cfc3ed61dc40f47f050a109b08610667d73477af6ef36dcad31c31a4a8d53f
TERMUX_PKG_DEPENDS="libogg"
termux_step_pre_configure () {
if [ "$TERMUX_DEBUG" == "true" ]; then
# libflac does removes the flag "-g" from CFLAGS in the configure script
# Not sure why this is done but lets assume there is a good reason for it.
# -g3 is normally passed for a debug build in termux, -g is then removed
# and only "3" is left which isn't a valid option to the compiler.
export CFLAGS="${CFLAGS/-g3/}"
fi
}

View File

@ -45,6 +45,7 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
"
TERMUX_PKG_FORCE_CMAKE=yes
TERMUX_PKG_KEEP_STATIC_LIBRARIES=true
TERMUX_PKG_HAS_DEBUG=no
termux_step_post_extract_package () {
local CLANG_SRC_TAR=cfe-${TERMUX_PKG_VERSION}.src.tar.xz

View File

@ -0,0 +1,22 @@
--- ./src/loslib.c 2017-11-18 15:51:35.425137997 +0000
+++ ../loslib.c 2017-11-18 16:20:36.202578294 +0000
@@ -118,8 +118,8 @@
#define LUA_TMPNAMTEMPLATE "/data/data/com.termux/files/usr/tmp/lua_XXXXXX"
#endif
-#define lua_tmpnam(b,e) { \
- strcpy(b, LUA_TMPNAMTEMPLATE); \
+#define lua_tmpnam(b,e,s) { \
+ strncpy(b, LUA_TMPNAMTEMPLATE, s); \
e = mkstemp(b); \
if (e != -1) close(e); \
e = (e == -1); }
@@ -166,7 +166,7 @@
static int os_tmpname (lua_State *L) {
char buff[LUA_TMPNAMBUFSIZE];
int err;
- lua_tmpnam(buff, err);
+ lua_tmpnam(buff, err, LUA_TMPNAMBUFSIZE - 1);
if (err)
return luaL_error(L, "unable to generate a unique filename");
lua_pushstring(L, buff);

View File

@ -14,3 +14,13 @@ ac_cv_path_RUBY=$TERMUX_PREFIX/bin/ruby
--with-ncurses-libs=$TERMUX_PREFIX/lib
--with-screen=ncurses
"
termux_step_pre_configure() {
if [ "$TERMUX_DEBUG" == "true" ]; then
# Debug build fails with:
# /home/builder/.termux-build/mc/src/src/filemanager/file.c:2019:37: error: 'umask' called with invalid mode
# src_mode = umask (-1);
# ^
export CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
fi
}

View File

@ -14,6 +14,11 @@ TERMUX_PKG_RM_AFTER_INSTALL="bin/rnano share/man/man1/rnano.1 share/nano/man-htm
termux_step_pre_configure() {
LDFLAGS+=" -landroid-glob"
if [ "$TERMUX_DEBUG" == "true" ]; then
# When doing debug build, -D_FORTIFY_SOURCE=2 gives this error:
# /home/builder/.termux-build/_lib/16-aarch64-21-v3/bin/../sysroot/usr/include/bits/fortify/string.h:79:26: error: use of undeclared identifier '__USE_FORTIFY_LEVEL'
export CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
fi
}
termux_step_post_make_install () {

View File

@ -19,7 +19,7 @@ termux_step_pre_configure () {
termux_step_configure () {
DEBUG_FLAG=""
test -n "$TERMUX_DEBUG" && DEBUG_FLAG="--debug"
test -n "$TERMUX_DEBUG" && DEBUG_FLAG="--with-debug"
./configure \
--prefix=$TERMUX_PREFIX \

View File

@ -5,3 +5,12 @@ TERMUX_PKG_SRCURL=http://download.savannah.nongnu.org/releases/oath-toolkit/oath
TERMUX_PKG_SHA256=b03446fa4b549af5ebe4d35d7aba51163442d255660558cd861ebce536824aa0
TERMUX_PKG_DEPENDS="xmlsec"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="--disable-pam"
termux_step_pre_configure () {
if [ "$TERMUX_DEBUG" == "true" ]; then
# When doing debug build, -D_FORTIFY_SOURCE=2 gives this error:
# /home/builder/.termux-build/oathtool/src/liboath/usersfile.c:482:46: error: 'umask' called with invalid mode
# old_umask = umask (~(S_IRUSR | S_IWUSR));
export CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
fi
}

View File

@ -0,0 +1,15 @@
--- ./ext/fileinfo/libmagic/file.h 2018-02-27 16:33:03.000000000 +0000
+++ ../file.h 2018-03-22 19:36:35.759933435 +0000
@@ -511,10 +511,10 @@
#endif
#ifndef strlcpy
-size_t strlcpy(char *, const char *, size_t);
+size_t __attribute__((overloadable)) strlcpy(char *, const char *, size_t);
#endif
#ifndef strlcat
-size_t strlcat(char *, const char *, size_t);
+size_t __attribute__((overloadable)) strlcat(char *, const char *, size_t);
#endif
#ifndef HAVE_STRCASESTR
char *strcasestr(const char *, const char *);

View File

@ -0,0 +1,11 @@
--- ./histlib.h 2016-04-22 15:03:20.000000000 +0000
+++ ../histlib.h 2018-03-18 19:50:23.834494092 +0000
@@ -52,7 +52,7 @@
#ifndef member
# ifndef strchr
-extern char *strchr ();
+extern char __attribute__((overloadable)) *strchr ();
# endif
#define member(c, s) ((c) ? ((char *)strchr ((s), (c)) != (char *)NULL) : 0)
#endif

View File

@ -11,6 +11,7 @@ TERMUX_PKG_CONFLICTS="texlive (<< 20170524-5), texlive-bin (<< 20180414)"
TERMUX_PKG_RECOMMENDS="texlive-tlmgr"
TERMUX_PKG_FOLDERNAME="texlive-$_MAJOR_VERSION-texmf"
TERMUX_PKG_PLATFORM_INDEPENDENT=yes
TERMUX_PKG_HAS_DEBUG=no
TL_FILE_LISTS="texlive-texmf.list"
TL_ROOT=$TERMUX_PREFIX/share/texlive

View File

@ -0,0 +1,33 @@
--- ./configure 2018-03-01 11:48:24.972390791 +0000
+++ ../configure 2018-03-01 12:17:17.702571991 +0000
@@ -2283,7 +2283,7 @@
#include "confdefs.h"
#include <sys/poll.h>
- int poll($testproto);
+ int __attribute__((overloadable)) poll($testproto);
int main() {
--- ./tsocks.c 2018-03-01 12:18:42.778500423 +0000
+++ ../tsocks.c 2018-03-01 12:19:31.726457927 +0000
@@ -72,7 +72,7 @@
void _init(void);
int connect(CONNECT_SIGNATURE);
int select(SELECT_SIGNATURE);
-int poll(POLL_SIGNATURE);
+int __attribute__((overloadable)) poll(POLL_SIGNATURE);
int close(CLOSE_SIGNATURE);
int getpeername(GETPEERNAME_SIGNATURE);
#ifdef USE_SOCKS_DNS
--- ./tsocks.c 2018-03-01 12:21:27.198354152 +0000
+++ ../tsocks.c 2018-03-01 12:21:59.098324662 +0000
@@ -538,7 +538,7 @@
return(nevents);
}
-int poll(POLL_SIGNATURE) {
+int __attribute__((overloadable)) poll(POLL_SIGNATURE) {
int nevents = 0;
int rc = 0, i;
int setevents = 0;

View File

@ -0,0 +1,11 @@
--- ./units.h 2017-02-09 21:43:12.000000000 +0000
+++ ../units.h 2018-03-21 20:22:04.544833906 +0000
@@ -54,7 +54,7 @@
# ifdef NO_STRCHR
# define strchr(a,b) index((a),(b))
# else
- char *strchr();
+ char __attribute__((overloadable)) *strchr();
# endif
#endif /* !strchr */

View File

@ -7,4 +7,10 @@ TERMUX_PKG_DEPENDS="ncurses, file"
termux_step_pre_configure() {
autoreconf -if
if [ "$TERMUX_DEBUG" == "true" ]; then
# Debug build fails with:
# /home/builder/.termux-build/vifm/src/src/fops_common.c:745:27: error: 'umask' called with invalid mode
# saved_umask = umask(~0600);
export CFLAGS=${CFLAGS/-D_FORTIFY_SOURCE=2/}
fi
}