Bug 68360 - Valgrind does not compile against 2.6.0-testX kernels
Summary: Valgrind does not compile against 2.6.0-testX kernels
Status: RESOLVED FIXED
Alias: None
Product: valgrind
Classification: Developer tools
Component: general (show other bugs)
Version: unspecified
Platform: Compiled Sources Linux
: NOR normal
Target Milestone: ---
Assignee: Julian Seward
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-11-16 12:06 UTC by Ismail Donmez
Modified: 2003-11-19 23:36 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments
Patch/Hack to make it compile on 2.6.0-test9-mm2 kernel (542 bytes, patch)
2003-11-18 11:28 UTC, Ismail Donmez
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Ismail Donmez 2003-11-16 12:06:11 UTC
Version:            (using KDE Devel)
Installed from:    Compiled sources
Compiler:          gcc 3.3.2 
OS:          Linux

Here is the error :

make[3]: Entering directory `/usr/src/kde/valgrind/coregrind'
if gcc -DHAVE_CONFIG_H -I. -I. -I..  -I./demangle -I../include -DVG_LIBDIR="\"/opt/kde/lib"\"   -Winline -Wall -Wshadow -O -fno-omit-frame-pointer -mpreferred-stack-boundary=2 -g -fpic  -MT vg_syscalls.o -MD -MP -MF ".deps/vg_syscalls.Tpo" \
  -c -o vg_syscalls.o `test -f 'vg_syscalls.c' || echo './'`vg_syscalls.c; \
then mv -f ".deps/vg_syscalls.Tpo" ".deps/vg_syscalls.Po"; \
else rm -f ".deps/vg_syscalls.Tpo"; exit 1; \
fi
In file included from /usr/include/linux/timer.h:5,
                 from /usr/include/linux/isdn/fsm.h:15,
                 from /usr/include/linux/isdn.h:17,
                 from vg_unsafe.h:60,
                 from vg_syscalls.c:35:
/usr/include/linux/list.h:579:2: warning: #warning "don't include kernel headers in userspace"
In file included from /usr/include/linux/timer.h:6,
                 from /usr/include/linux/isdn/fsm.h:15,
                 from /usr/include/linux/isdn.h:17,
                 from vg_unsafe.h:60,
                 from vg_syscalls.c:35:
/usr/include/linux/spinlock.h: In function `bit_spin_lock':
/usr/include/linux/spinlock.h:571: error: invalid type argument of `->'
/usr/include/linux/spinlock.h: In function `bit_spin_trylock':
/usr/include/linux/spinlock.h:594: error: invalid type argument of `->'
/usr/include/linux/spinlock.h: In function `bit_spin_unlock':
/usr/include/linux/spinlock.h:609: error: invalid type argument of `->'
/usr/include/linux/spinlock.h:609: error: `TIF_NEED_RESCHED' undeclared (first use in this function)
/usr/include/linux/spinlock.h:609: error: (Each undeclared identifier is reported only once
/usr/include/linux/spinlock.h:609: error: for each function it appears in.)
/usr/include/linux/spinlock.h: In function `bit_spin_is_locked':
/usr/include/linux/spinlock.h:620: error: invalid type argument of `->'
In file included from /usr/include/linux/isdn/fsm.h:15,
                 from /usr/include/linux/isdn.h:17,
                 from vg_unsafe.h:60,
                 from vg_syscalls.c:35:
/usr/include/linux/timer.h: At top level:
/usr/include/linux/timer.h:11: error: field `entry' has incomplete type
make[3]: *** [vg_syscalls.o] Error 1
make[3]: Leaving directory `/usr/src/kde/valgrind/coregrind'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/usr/src/kde/valgrind/coregrind'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/usr/src/kde/valgrind'
make: *** [all] Error 2
Comment 1 Thiago Macieira 2003-11-16 15:19:36 UTC
Sorry cartman, it's actually your fault here. Don't upgrade the kernel headers when upgrading the kernel. You should have one set of stable kernel headers that are known to compile in userspace programs and you should not touch it.

/usr/include/linux/list.h:579:2: warning: #warning "don't include kernel headers in userspace"
Comment 2 Ismail Donmez 2003-11-16 16:08:53 UTC
Nope nope if I dont use 2.6 kernel headers glibc wont have epoll,sysenter support etc. 2.6 kernel will ship its own headers so valgrind better get fixed...
Comment 3 Thiago Macieira 2003-11-16 16:11:57 UTC
We need a set of working kernel headers that are supposed to work for userspace. The standard kernel headers aren't those. As the warning you've pasted shows (and I've pointed it out), you are not supposed to include those headers in userspace programs.
Comment 4 Ismail Donmez 2003-11-16 16:15:15 UTC
Ok lets keep this bug open until 2.6.0 out but if you look at recent LKML discussion abous how cdrecord fails to compile with recent headers , you will see that I am supposed to use 2.6 headers...
Comment 5 Dirk Mueller 2003-11-18 04:15:06 UTC
thiago, valgrind is not a normal KDE application, it has to include kernel
headers since it docks itself into a layer between the libc and the kernel. 

Comment 6 Dirk Mueller 2003-11-18 04:34:16 UTC
hmm, I can't actually reproduce the problem with my 2.6test9. 

whats in /usr/include/linux/spinlock.h:571 for you?

Comment 7 Ismail Donmez 2003-11-18 10:09:20 UTC
I got preempt_disable(); there. I got a small hack I think. I will post for review If I can get it to work.
Comment 8 Ismail Donmez 2003-11-18 10:14:51 UTC
No luck with my hack. Btw this is -mm2 but preempt_disable() is from Linus' tree.
Comment 9 Ismail Donmez 2003-11-18 11:28:42 UTC
Created attachment 3268 [details]
Patch/Hack to make it compile on 2.6.0-test9-mm2 kernel

The best way I found to fix this.
Comment 10 Ismail Donmez 2003-11-18 11:30:06 UTC
Note that the actual problem I suspect is we need a glibc abstraction of :

linux/list.h
linux/thread_info.h

Comment 11 Thiago Macieira 2003-11-18 14:56:46 UTC
A workaround that I've seen someone recommend is that programs such as valgrind ship their own kernel headers -- or version thereof. It's clear from what you've told me that glibc headers are a no-go. And it's hard as well to work with something that tells you "you shouldn't be including this".

Anyways, before the kernel headers cleanup project comes to life, that's the only way out I know of.

The ABI is supposed to be stable, therefore it doesn't matter whether you're using 2.4 or 2.6's headers to build valgrind (or kscd for that matter).
Comment 12 Dirk Mueller 2003-11-19 23:07:45 UTC
Subject: valgrind

CVS commit by mueller: 

this should fix compilation on weird kernel 2.6.x installations.
CCMAIL: 68360@bugs.kde.org


  M +4 -4      coregrind/vg_syscalls.c   1.59
  M +0 -1      coregrind/vg_unsafe.h   1.22
  M +13 -0     include/vg_kerneliface.h   1.8


--- valgrind/coregrind/vg_syscalls.c  #1.58:1.59
@@ -2488,5 +2488,5 @@ PRE(ioctl)
 #       endif
 
-   case IIOCGETCPS:
+   case VKI_IIOCGETCPS:
       /* In early 2.4 kernels, ISDN_MAX_CHANNELS was only defined
        * when KERNEL was. I never saw a larger value than 64 though */
@@ -2498,5 +2498,5 @@ PRE(ioctl)
                      * 2 * sizeof(unsigned long) );
       break;
-   case IIOCNETGPN:
+   case VKI_IIOCNETGPN:
       SYSCALL_TRACK( pre_mem_read, tid, "ioctl(IIOCNETGPN)",
                      (UInt)&((isdn_net_ioctl_phone *)arg3)->name,
@@ -2887,5 +2887,5 @@ POST(ioctl)
 #       endif
 
-   case IIOCGETCPS:
+   case VKI_IIOCGETCPS:
       /* In early 2.4 kernels, ISDN_MAX_CHANNELS was only defined
        * when KERNEL was. I never saw a larger value than 64 though */
@@ -2897,5 +2897,5 @@ POST(ioctl)
                    * 2 * sizeof(unsigned long) );
       break;
-   case IIOCNETGPN:
+   case VKI_IIOCNETGPN:
       if (res == 0)
          VG_TRACK( post_mem_write, arg3, sizeof(isdn_net_ioctl_phone) );

--- valgrind/coregrind/vg_unsafe.h  #1.21:1.22
@@ -58,5 +58,4 @@
 #include <linux/sem.h>    /* for struct sembuf */
 
-#include <linux/isdn.h>   /* for ISDN ioctls */
 #include <scsi/sg.h>      /* for the SG_* ioctls */
 #include <sched.h>        /* for struct sched_param */

--- valgrind/include/vg_kerneliface.h  #1.7:1.8
@@ -372,4 +372,17 @@ struct vki_ucontext {
 #define VKI_ERESTARTSYS     512     /* Restart the syscall */
 
+/* Copied from linux/isdn.h */
+
+#define VKI_IIOCGETCPS  _IO( 'I',21 )
+#define VKI_IIOCNETGPN  _IO( 'I',34 )
+
+#define ISDN_MSNLEN          32
+
+typedef struct {
+    char name[ 10 ];
+    char phone[ ISDN_MSNLEN ];
+    int  outgoing;
+} isdn_net_ioctl_phone;
+
 
 /* Gawd ... hack ... */


Comment 13 Ismail Donmez 2003-11-19 23:36:54 UTC
Dirk you beated me again! :)