Subject: pkg/36778: sysutils/strace fails to build on linux
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: Yakovetsky Vladimir <yx@x.ua>
List: pkgsrc-bugs
Date: 08/14/2007 10:05:00
>Number:         36778
>Category:       pkg
>Synopsis:       sysutils/strace fails to build on linux
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Aug 14 10:05:00 +0000 2007
>Originator:     Yakovetsky Vladimir
>Release:        
>Environment:
System: Linux bres 2.6.21.5 #1 SMP Fri Jul 6 09:48:19 GMT 2007 i686 GNU/Linux
Architecture: i686

>Description:
	sysutils/strace fails to build on linux

>How-To-Repeat:
% uname -srm
Linux 2.6.21.5 i686
% cd /usr/pkgsrc/sysutils/strace

| 1st failure:
% bmake
...
if gcc -DHAVE_CONFIG_H -I. -I. -I. -Ilinux/i386 -I./linux/i386 -Ilinux -I./linux    -Wall -O2 -march=pentium3 -mfpmath=sse -msse -finline-functions -fomit-frame-pointer -ffast-math -MT strace.o -MD -MP -MF ".deps/strace.Tpo" -c -o strace.o strace.c;  then mv -f ".deps/strace.Tpo" ".deps/strace.Po"; else rm -f ".deps/strace.Tpo"; exit 1; fi
strace.c: In function 'trace':
strace.c:2263: error: 'PT_CR_IPSR' undeclared (first use in this function)
strace.c:2263: error: (Each undeclared identifier is reported only once
strace.c:2263: error: for each function it appears in.)
strace.c:2263: warning: pointer targets in passing argument 3 of 'upeek' differ in signedness
strace.c:2264: error: 'PT_CR_IIP' undeclared (first use in this function)
strace.c:2264: warning: pointer targets in passing argument 3 of 'upeek' differ in signedness
strace.c:2266: warning: right shift count >= width of type
*** Error code 1


| 1st fix (from debian patch):
:r sysutils/strace/patches/patch-bc
--- strace.c.~1~
+++ strace.c
@@ -2255,7 +2255,7 @@
 			if (!cflag
 			    && (qual_flags[WSTOPSIG(status)] & QUAL_SIGNAL)) {
 				unsigned long addr = 0, pc = 0;
-#ifdef PT_GETSIGINFO
+#if defined(PT_GETSIGINFO) && defined(PT_CR_IPSR) && defined(PT_CR_IIP)
 #				define PSR_RI	41
 				struct siginfo si;
 				unsigned long psr;


| 2nd failure:
% bmake
...
checking for linux/if_packet.h... no
...
if gcc -DHAVE_CONFIG_H -I. -I. -I. -Ilinux/i386 -I./linux/i386 -Ilinux -I./linux    -Wall -O2 -march=pentium3 -mfpmath=sse -msse -finline-functions -fomit-frame-pointer -ffast-math -MT net.o -MD -MP -MF ".deps/net.Tpo" -c -o net.o net.c;  then mv -f ".deps/net.Tpo" ".deps/net.Po"; else rm -f ".deps/net.Tpo"; exit 1; fi
net.c:810: error: 'PACKET_ADD_MEMBERSHIP' undeclared here (not in a function)
net.c:811: error: 'PACKET_DROP_MEMBERSHIP' undeclared here (not in a function)
net.c: In function 'printsock':
net.c:961: error: field 'll' has incomplete type
net.c:964: error: field 'nl' has incomplete type
net.c:1055: error: request for member 'sll_protocol' in something not a structure or union
net.c:1055: warning: initialization makes integer from pointer without a cast
net.c:1056: error: request for member 'sll_ifindex' in something not a structure or union
net.c:1056: warning: format '%d' expects type 'int', but argument 3 has type 'const struct xlat *'
net.c:1057: error: request for member 'sll_pkttype' in something not a structure or union
net.c:1057: warning: passing argument 2 of 'printxval' makes integer from pointer without a cast
net.c:1059: error: request for member 'sll_halen' in something not a structure or union
net.c:1060: error: request for member 'sll_hatype' in something not a structure or union
net.c:1060: warning: format '%d' expects type 'int', but argument 2 has type 'const struct xlat *'
net.c:1060: warning: format '%d' expects type 'int', but argument 3 has type 'const struct xlat *'
net.c:1061: error: request for member 'sll_halen' in something not a structure or union
net.c:1061: warning: comparison between pointer and integer
net.c:1062: error: request for member 'sll_addr' in something not a structure or union
net.c:1062: warning: format '%02x' expects type 'unsigned int', but argument 2 has type 'struct xlat'
net.c:1069: error: request for member 'nl_pid' in something not a structure or union
net.c:1069: error: request for member 'nl_groups' in something not a structure or union
net.c:1069: warning: format '%d' expects type 'int', but argument 2 has type 'const struct xlat *'
net.c:1069: warning: format '%08x' expects type 'unsigned int', but argument 3 has type 'const struct xlat *'
*** Error code 1


| 2nd fix, part1:
:r sysutils/strace/patches/patch-bd
--- configure.ac.~1~
+++ configure.ac
@@ -202,7 +202,8 @@
 AC_CHECK_FUNCS(sigaction strerror strsignal pread sys_siglist _sys_siglist getdents mctl prctl sendmsg inet_ntop if_indextoname)
 AC_CHECK_HEADERS([sys/reg.h sys/filio.h sys/acl.h sys/asynch.h sys/door.h stropts.h sys/conf.h sys/stream.h sys/tihdr.h sys/tiuser.h sys/sysconfig.h ioctls.h sys/ioctl.h sys/ptrace.h termio.h linux/ptrace.h asm/reg.h sys/uio.h sys/aio.h  poll.h sys/poll.h sys/vfs.h asm/sysmips.h linux/utsname.h sys/nscsys.h mqueue.h sys/epoll.h libaio.h], [], [])
 AC_CHECK_HEADERS([linux/icmp.h linux/in6.h linux/netlink.h linux/if_packet.h],
-                 [], [], [#include <linux/socket.h>])
+                 [], [], [#include <stddef.h>
+#include <linux/socket.h>])
 AC_CHECK_HEADERS([asm/sigcontext.h], [], [], [#include <signal.h>])
 AC_CHECK_HEADERS([netinet/tcp.h netinet/udp.h],,, [#include <netinet/in.h>])
 

| 2nd fix, part2:
--- sysutils/strace/Makefile.orig
+++ sysutils/strace/Makefile
@@ -20,6 +20,12 @@
 
 GNU_CONFIGURE=		yes
 
+AUTOCONF_REQD=		2.57
+USE_TOOLS+=		autoconf
+
+pre-configure:
+	cd ${WRKSRC} && autoconf
+
 REPLACE_PERL=		strace-graph
 
 .include "../../mk/bsd.pkg.mk"


| 3rd failure:
% bmake
...
if gcc -DHAVE_CONFIG_H -I. -I. -I. -Ilinux/i386 -I./linux/i386 -Ilinux -I./linux    -Wall -O2 -march=pentium3 -mfpmath=sse -msse -finline-functions -fomit-frame-pointer -ffast-math -MT process.o -MD -MP -MF ".deps/process.Tpo" -c -o process.o process.c;  then mv -f ".deps/process.Tpo" ".deps/process.Po"; else rm -f ".deps/process.Tpo"; exit 1; fi
process.c: In function 'sys_ptrace':
process.c:3012: error: duplicate case value
process.c:3011: error: previously used here
process.c:3028: error: duplicate case value
process.c:3027: error: previously used here
*** Error code 1


| 3rd fix:
:r sysutils/strace/patches/patch-be
--- defs.h.~1~
+++ defs.h
@@ -267,6 +267,7 @@
 #define PR_FAULTED      S_CORE
 #endif
 
+#ifndef LINUX
 #if !defined(PTRACE_ATTACH) && defined(PT_ATTACH)
 #define PTRACE_ATTACH PT_ATTACH
 #endif
@@ -297,6 +298,7 @@
 #if !defined(PTRACE_SETREGS) && defined(PT_SETREGS)
 #define PTRACE_SETREGS PT_SETREGS
 #endif
+#endif
 
 /* Trace Control Block */
 struct tcb {


| 4th failure:
% bmake
...
if gcc -DHAVE_CONFIG_H -I. -I. -I. -Ilinux/i386 -I./linux/i386 -Ilinux -I./linux    -Wall -O2 -march=pentium3 -mfpmath=sse -msse -finline-functions -fomit-frame-pointer -ffast-math -MT system.o -MD -MP -MF ".deps/system.Tpo" -c -o system.o system.c;  then mv -f ".deps/system.Tpo" ".deps/system.Po"; else rm -f ".deps/system.Tpo"; exit 1; fi
system.c:1581: error: 'CTL_PROC' undeclared here (not in a function)
*** Error code 1


| 4th fix (from debian patch):
:r sysutils/strace/patches/patch-bf
--- system.c.~1~
+++ system.c
@@ -78,6 +78,7 @@
 #endif
 
 #include <linux/sysctl.h>
+#include <linux/version.h>
 
 static const struct xlat mount_flags[] = {
 	{ MS_MGC_VAL,	"MS_MGC_VAL"	},
@@ -1578,7 +1579,9 @@
 	{ CTL_KERN, "CTL_KERN" },
 	{ CTL_VM, "CTL_VM" },
 	{ CTL_NET, "CTL_NET" },
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
 	{ CTL_PROC, "CTL_PROC" },
+#endif
 	{ CTL_FS, "CTL_FS" },
 	{ CTL_DEBUG, "CTL_DEBUG" },
 	{ CTL_DEV, "CTL_DEV" },



>Fix:
	Makefile.diff + patches/patch-b[cdef]
	Summary:

--- sysutils/strace/Makefile.orig
+++ sysutils/strace/Makefile
@@ -20,6 +20,12 @@
 
 GNU_CONFIGURE=		yes
 
+AUTOCONF_REQD=		2.57
+USE_TOOLS+=		autoconf
+
+pre-configure:
+	cd ${WRKSRC} && autoconf
+
 REPLACE_PERL=		strace-graph
 
 .include "../../mk/bsd.pkg.mk"


:r sysutils/strace/patches/patch-bc
--- strace.c.~1~
+++ strace.c
@@ -2255,7 +2255,7 @@
 			if (!cflag
 			    && (qual_flags[WSTOPSIG(status)] & QUAL_SIGNAL)) {
 				unsigned long addr = 0, pc = 0;
-#ifdef PT_GETSIGINFO
+#if defined(PT_GETSIGINFO) && defined(PT_CR_IPSR) && defined(PT_CR_IIP)
 #				define PSR_RI	41
 				struct siginfo si;
 				unsigned long psr;

:r sysutils/strace/patches/patch-bd
--- configure.ac.~1~
+++ configure.ac
@@ -202,7 +202,8 @@
 AC_CHECK_FUNCS(sigaction strerror strsignal pread sys_siglist _sys_siglist getdents mctl prctl sendmsg inet_ntop if_indextoname)
 AC_CHECK_HEADERS([sys/reg.h sys/filio.h sys/acl.h sys/asynch.h sys/door.h stropts.h sys/conf.h sys/stream.h sys/tihdr.h sys/tiuser.h sys/sysconfig.h ioctls.h sys/ioctl.h sys/ptrace.h termio.h linux/ptrace.h asm/reg.h sys/uio.h sys/aio.h  poll.h sys/poll.h sys/vfs.h asm/sysmips.h linux/utsname.h sys/nscsys.h mqueue.h sys/epoll.h libaio.h], [], [])
 AC_CHECK_HEADERS([linux/icmp.h linux/in6.h linux/netlink.h linux/if_packet.h],
-                 [], [], [#include <linux/socket.h>])
+                 [], [], [#include <stddef.h>
+#include <linux/socket.h>])
 AC_CHECK_HEADERS([asm/sigcontext.h], [], [], [#include <signal.h>])
 AC_CHECK_HEADERS([netinet/tcp.h netinet/udp.h],,, [#include <netinet/in.h>])


:r sysutils/strace/patches/patch-be
--- defs.h.~1~
+++ defs.h
@@ -267,6 +267,7 @@
 #define PR_FAULTED      S_CORE
 #endif
 
+#ifndef LINUX
 #if !defined(PTRACE_ATTACH) && defined(PT_ATTACH)
 #define PTRACE_ATTACH PT_ATTACH
 #endif
@@ -297,6 +298,7 @@
 #if !defined(PTRACE_SETREGS) && defined(PT_SETREGS)
 #define PTRACE_SETREGS PT_SETREGS
 #endif
+#endif
 
 /* Trace Control Block */
 struct tcb {

:r sysutils/strace/patches/patch-bf
--- system.c.~1~
+++ system.c
@@ -78,6 +78,7 @@
 #endif
 
 #include <linux/sysctl.h>
+#include <linux/version.h>
 
 static const struct xlat mount_flags[] = {
 	{ MS_MGC_VAL,	"MS_MGC_VAL"	},
@@ -1578,7 +1579,9 @@
 	{ CTL_KERN, "CTL_KERN" },
 	{ CTL_VM, "CTL_VM" },
 	{ CTL_NET, "CTL_NET" },
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18)
 	{ CTL_PROC, "CTL_PROC" },
+#endif
 	{ CTL_FS, "CTL_FS" },
 	{ CTL_DEBUG, "CTL_DEBUG" },
 	{ CTL_DEV, "CTL_DEV" },