debug/strace: fix strace 4.5.19 to properly build with latest Linux kernels
authorJoachim Nilsson <jocke@vmlinux.org>
Fri Jan 01 12:17:39 2010 +0100 (2010-01-01)
changeset 167108a5129e6eb0
parent 1670 08b0982e4da9
child 1672 636126117b8c
debug/strace: fix strace 4.5.19 to properly build with latest Linux kernels

Here's a couple of patches to get strace 4.5.19 to configure and build
properly with the latest kernel headers. Not pretty, but hopefully
enough while we wait for 4.5.20 to be released.

With the current strace-4.5.19 patches I failed to get the configure
script running even on my host environment. Also, when cross building
the configure script needs to look for the proper system headers to be
able to properly set HAVE_LINUX_NETLINK_H. Otherwise you get:

[EXTRA] Building strace
[ERROR] /home/jocke/x-tools/targets/src/strace-4.5.19/net.c:976:
error: field 'nl' has incomplete type
[ERROR] make[2]: *** [net.o] Error 1
[ERROR] make[1]: *** [all] Error 2

The fix was simple, backport a change set from the git[1] tree and run
autoreconf to update the configure script.

[1] - http://strace.git.sourceforge.net/git/gitweb.cgi?p=strace/strace;a=commit;h=f0df31e71a58c6e79ba77c1a9d84b2f38d44bec7
patches/strace/4.5.19/160-fix-check-for-linux-netlink.patch
patches/strace/4.5.19/170-update-configure.patch
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/patches/strace/4.5.19/160-fix-check-for-linux-netlink.patch	Fri Jan 01 12:17:39 2010 +0100
     1.3 @@ -0,0 +1,19 @@
     1.4 +Dmitry V. Levin [Tue, 3 Nov 2009 16:49:49 +0000]
     1.5 +
     1.6 +Fix check for linux/netlink.h on Linux 2.6.32-rc5+
     1.7 +
     1.8 +* configure.ac (AC_CHECK_HEADERS): In check for linux/netlink.h, include 
     1.9 +  sys/socket.h instead of linux/socket.h beforehand.
    1.10 +
    1.11 +diff --git a/configure.ac b/configure.ac
    1.12 +--- a/configure.ac
    1.13 ++++ b/configure.ac
    1.14 +@@ -258,7 +258,7 @@ AC_CHECK_HEADERS([ \
    1.15 + ], [], [])
    1.16 + AC_CHECK_HEADERS([linux/icmp.h linux/in6.h linux/netlink.h linux/if_packet.h],
    1.17 +                  [], [], [#include <stddef.h>
    1.18 +-#include <linux/socket.h>])
    1.19 ++#include <sys/socket.h>])
    1.20 + AC_CHECK_HEADERS([asm/sigcontext.h], [], [], [#include <signal.h>])
    1.21 + AC_CHECK_TYPES([struct sigcontext_struct,
    1.22 + 		struct sigcontext],,, [#include <signal.h>])
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/patches/strace/4.5.19/170-update-configure.patch	Fri Jan 01 12:17:39 2010 +0100
     2.3 @@ -0,0 +1,159 @@
     2.4 +diff -ruN strace-4.5.19.orig/config.h.in strace-4.5.19/config.h.in
     2.5 +--- strace-4.5.19.orig/config.h.in	2009-10-21 19:41:12.000000000 +0200
     2.6 ++++ strace-4.5.19/config.h.in	2010-01-01 10:39:36.000000000 +0100
     2.7 +@@ -161,6 +161,9 @@
     2.8 + /* Define if stat64 is available in asm/stat.h. */
     2.9 + #undef HAVE_STAT64
    2.10 + 
    2.11 ++/* Define if statfs64 is available in sys/statfs.h or sys/vfs.h. */
    2.12 ++#undef HAVE_STATFS64
    2.13 ++
    2.14 + /* Define to 1 if stdbool.h conforms to C99. */
    2.15 + #undef HAVE_STDBOOL_H
    2.16 + 
    2.17 +diff -ruN strace-4.5.19.orig/configure strace-4.5.19/configure
    2.18 +--- strace-4.5.19.orig/configure	2010-01-01 10:38:49.000000000 +0100
    2.19 ++++ strace-4.5.19/configure	2010-01-01 10:39:36.000000000 +0100
    2.20 +@@ -5374,6 +5374,44 @@
    2.21 + 
    2.22 + fi
    2.23 + 
    2.24 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for statfs64 in sys/(statfs|vfs).h" >&5
    2.25 ++$as_echo_n "checking for statfs64 in sys/(statfs|vfs).h... " >&6; }
    2.26 ++if test "${ac_cv_type_statfs64+set}" = set; then :
    2.27 ++  $as_echo_n "(cached) " >&6
    2.28 ++else
    2.29 ++  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    2.30 ++/* end confdefs.h.  */
    2.31 ++#ifdef LINUX
    2.32 ++#include <linux/types.h>
    2.33 ++#include <sys/statfs.h>
    2.34 ++#else
    2.35 ++#include <sys/vfs.h>
    2.36 ++#endif
    2.37 ++int
    2.38 ++main ()
    2.39 ++{
    2.40 ++struct statfs64 st;
    2.41 ++  ;
    2.42 ++  return 0;
    2.43 ++}
    2.44 ++_ACEOF
    2.45 ++if ac_fn_c_try_compile "$LINENO"; then :
    2.46 ++  ac_cv_type_statfs64=yes
    2.47 ++else
    2.48 ++  ac_cv_type_statfs64=no
    2.49 ++fi
    2.50 ++rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    2.51 ++fi
    2.52 ++
    2.53 ++{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_statfs64" >&5
    2.54 ++$as_echo "$ac_cv_type_statfs64" >&6; }
    2.55 ++if test "$ac_cv_type_statfs64" = yes
    2.56 ++then
    2.57 ++
    2.58 ++$as_echo "#define HAVE_STATFS64 1" >>confdefs.h
    2.59 ++
    2.60 ++fi
    2.61 ++
    2.62 + 
    2.63 + { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
    2.64 + $as_echo_n "checking return type of signal handlers... " >&6; }
    2.65 +@@ -5773,73 +5811,6 @@
    2.66 + cat confdefs.h - <<_ACEOF >conftest.$ac_ext
    2.67 + /* end confdefs.h.  */
    2.68 + 
    2.69 +-echo "$as_me:$LINENO: checking for statfs64 in sys/(statfs|vfs).h" >&5
    2.70 +-echo $ECHO_N "checking for statfs64 in sys/(statfs|vfs).h... $ECHO_C" >&6
    2.71 +-if test "${ac_cv_type_statfs64+set}" = set; then
    2.72 +-  echo $ECHO_N "(cached) $ECHO_C" >&6
    2.73 +-else
    2.74 +-  cat >conftest.$ac_ext <<_ACEOF
    2.75 +-/* confdefs.h.  */
    2.76 +-_ACEOF
    2.77 +-cat confdefs.h >>conftest.$ac_ext
    2.78 +-cat >>conftest.$ac_ext <<_ACEOF
    2.79 +-/* end confdefs.h.  */
    2.80 +-#ifdef LINUX
    2.81 +-#include <linux/types.h>
    2.82 +-#include <sys/statfs.h>
    2.83 +-#else
    2.84 +-#include <sys/vfs.h>
    2.85 +-#endif
    2.86 +-int
    2.87 +-main ()
    2.88 +-{
    2.89 +-struct statfs64 st;
    2.90 +-  ;
    2.91 +-  return 0;
    2.92 +-}
    2.93 +-_ACEOF
    2.94 +-rm -f conftest.$ac_objext
    2.95 +-if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
    2.96 +-  (eval $ac_compile) 2>conftest.er1
    2.97 +-  ac_status=$?
    2.98 +-  grep -v '^ *+' conftest.er1 >conftest.err
    2.99 +-  rm -f conftest.er1
   2.100 +-  cat conftest.err >&5
   2.101 +-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   2.102 +-  (exit $ac_status); } &&
   2.103 +-	 { ac_try='test -z "$ac_c_werror_flag"			 || test ! -s conftest.err'
   2.104 +-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   2.105 +-  (eval $ac_try) 2>&5
   2.106 +-  ac_status=$?
   2.107 +-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   2.108 +-  (exit $ac_status); }; } &&
   2.109 +-	 { ac_try='test -s conftest.$ac_objext'
   2.110 +-  { (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
   2.111 +-  (eval $ac_try) 2>&5
   2.112 +-  ac_status=$?
   2.113 +-  echo "$as_me:$LINENO: \$? = $ac_status" >&5
   2.114 +-  (exit $ac_status); }; }; then
   2.115 +-  ac_cv_type_statfs64=yes
   2.116 +-else
   2.117 +-  echo "$as_me: failed program was:" >&5
   2.118 +-sed 's/^/| /' conftest.$ac_ext >&5
   2.119 +-
   2.120 +-ac_cv_type_statfs64=no
   2.121 +-fi
   2.122 +-rm -f conftest.err conftest.$ac_objext conftest.$ac_ext
   2.123 +-fi
   2.124 +-
   2.125 +-echo "$as_me:$LINENO: result: $ac_cv_type_statfs64" >&5
   2.126 +-echo "${ECHO_T}$ac_cv_type_statfs64" >&6
   2.127 +-if test "$ac_cv_type_statfs64" = yes
   2.128 +-then
   2.129 +-
   2.130 +-cat >>confdefs.h <<\_ACEOF
   2.131 +-#define HAVE_STATFS64 1
   2.132 +-_ACEOF
   2.133 +-
   2.134 +-fi
   2.135 +-
   2.136 + 
   2.137 + int
   2.138 + main ()
   2.139 +@@ -5947,7 +5918,7 @@
   2.140 + do :
   2.141 +   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
   2.142 + ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#include <stddef.h>
   2.143 +-#include <linux/socket.h>
   2.144 ++#include <sys/socket.h>
   2.145 + "
   2.146 + eval as_val=\$$as_ac_Header
   2.147 +    if test "x$as_val" = x""yes; then :
   2.148 +diff -ruN strace-4.5.19.orig/Makefile.in strace-4.5.19/Makefile.in
   2.149 +--- strace-4.5.19.orig/Makefile.in	2009-10-21 19:41:14.000000000 +0200
   2.150 ++++ strace-4.5.19/Makefile.in	2010-01-01 10:39:36.000000000 +0100
   2.151 +@@ -42,8 +42,9 @@
   2.152 + subdir = .
   2.153 + DIST_COMMON = README $(am__configure_deps) $(noinst_HEADERS) \
   2.154 + 	$(srcdir)/Makefile.am $(srcdir)/Makefile.in \
   2.155 +-	$(srcdir)/config.h.in $(top_srcdir)/configure AUTHORS INSTALL \
   2.156 +-	NEWS TODO config.guess config.sub depcomp install-sh missing
   2.157 ++	$(srcdir)/config.h.in $(top_srcdir)/configure AUTHORS \
   2.158 ++	ChangeLog INSTALL NEWS TODO config.guess config.sub depcomp \
   2.159 ++	install-sh missing
   2.160 + ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
   2.161 + am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
   2.162 + 	$(top_srcdir)/configure.ac