On 2011-10-09 19:32, Larry Rosenman wrote:
I had gotten a PR about sysutils/lsof not compiling with clang. I had
Vic Abell check it out, and the problem is NOT with lsof per se, but
with the system headers.
Is there a project afoot to update the system headers to make them clang
compilable?
The problem isn't that clang can't compile the system headers, but
normally these don't get included from userspace. And they certainly
won't work as expected when you define _KERNEL in userspace, as the lsof
port foolishly does. It probably can't be avoided in such a tool, though.
...
In file included from ckkv.c:43:
In file included from ./../lsof.h:195:
In file included from ./../dlsof.h:190:
In file included from /usr/src/sys/ufs/ufs/ufsmount.h:36:
/usr/src/sys/sys/buf.h:388:2: warning: implicit declaration of function
'KASSERT' is invalid in C99
[-Wimplicit-function-declaration]
KASSERT(bp->b_bufobj != NULL, ("bwrite: no bufobj bp=%p", bp));
^
/usr/src/sys/sys/buf.h:388:33: warning: expression result unused
[-Wunused-value]
KASSERT(bp->b_bufobj != NULL, ("bwrite: no bufobj bp=%p", bp));
^~~~~~~~~~~~~~~~~~~~~~~~~
These are more or less harmless warnings, as long as nobody calls a
function that uses KASSERT. They occur because lsof's headers don't
include <sys/param.h> and <sys/systm.h> before <sys/ufs/ufs/ufsmount.h>.
...
In file included from ckkv.c:43:
In file included from ./../lsof.h:195:
In file included from ./../dlsof.h:432:
In file included from /usr/include/string.h:45:
/usr/include/strings.h:47:6: error: conflicting types for '__builtin_ffs'
int ffs(int) __pure2;
^
/usr/include/machine/cpufunc.h:140:24: note: expanded from:
#define ffs(x) __builtin_ffs(x)
^
/usr/include/strings.h:47:6: note: '__builtin_ffs' is a builtin with type 'int
(unsigned int)'
This is because the amd64 system headers redefine ffs to __builtin_ffs,
after which it conflicts with the declaration in /usr/include/strings.h.
On i386, ffs is not redefined, but I have no idea why.
In any case, gcc does not complain about the incompatible redeclaration,
which may be a bug, or just stupid luck, depending on your POV. :)
I've attached a fix for the lsof port, which also makes it build on
10.0-CURRENT (this was easy to fix here, as lsof uses its own
hand-rolled configuration script). Let me know if it works for you.
Index: sysutils/lsof/files/patch-Configure
===================================================================
RCS file: sysutils/lsof/files/patch-Configure
diff -N sysutils/lsof/files/patch-Configure
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysutils/lsof/files/patch-Configure 11 Oct 2011 11:44:44 -0000
@@ -0,0 +1,72 @@
+--- Configure.orig 2011-08-15 18:15:56.000000000 +0200
++++ Configure 2011-10-11 13:30:37.000000000 +0200
+@@ -1428,7 +1428,7 @@
+ 3.5*)
+ LSOF_VERS=3050
+ ;;
+- 3*)
++ 3.*)
+ LSOF_VERS=3050
+ echo "!!!WARNING!!! Unsupported FreeBSD version: $LSOF_VSTR"
+ echo "!!!WARNING!!! Configuring for FreeBSD 3.5"
+@@ -1481,7 +1481,7 @@
+ LSOF_TSTBIGF=" "
+ LSOF_VERS=4110
+ ;;
+- 4*)
++ 4.*)
+ LSOF_VERS=4100
+ echo "!!!WARNING!!! Unsupported FreeBSD version: $LSOF_VSTR"
+ echo "!!!WARNING!!! Configuring for FreeBSD 4.10"
+@@ -1510,7 +1510,7 @@
+ LSOF_TSTBIGF=" "
+ LSOF_VERS=5050
+ ;;
+- 5*)
++ 5.*)
+ LSOF_VERS=5050
+ echo "!!!WARNING!!! Unsupported FreeBSD version: $LSOF_VSTR"
+ echo "!!!WARNING!!! Configuring for FreeBSD 5.5"
+@@ -1535,7 +1535,7 @@
+ LSOF_TSTBIGF=" "
+ LSOF_VERS=6040
+ ;;
+- 6*)
++ 6.*)
+ LSOF_VERS=6000
+ echo "!!!WARNING!!! Unsupported FreeBSD version: $LSOF_VSTR"
+ echo "!!!WARNING!!! Configuring for FreeBSD 6.0"
+@@ -1560,7 +1560,7 @@
+ LSOF_TSTBIGF=" "
+ LSOF_VERS=7040
+ ;;
+- 7*)
++ 7.*)
+ LSOF_VERS=7000
+ echo "!!!WARNING!!! Unsupported FreeBSD version: $LSOF_VSTR"
+ echo "!!!WARNING!!! Configuring for FreeBSD 7.0"
+@@ -1577,10 +1577,14 @@
+ LSOF_TSTBIGF=" "
+ LSOF_VERS=8020
+ ;;
+- 9*)
++ 9.*)
+ LSOF_TSTBIGF=" "
+ LSOF_VERS=9000
+ ;;
++ 10.*)
++ LSOF_TSTBIGF=" "
++ LSOF_VERS=10000
++ ;;
+ *)
+ echo Unknown FreeBSD release: `uname -r`
+ echo Assuming FreeBSD 2.x
+@@ -1684,7 +1688,7 @@
+ LSOF_CFGF="$LSOF_CFGF -DHASVMLOCKH"
+ fi # }
+ ;;
+-
4000|4010|4020|4030|4040|4050|4060|4070|4080|4090|4100|4110|5000|5010|5020|5030|5040|5050|6000|6010|6020|6030|6040|7000|7010|7020|7030|7040|8000|8010|8020|9000)
++
4000|4010|4020|4030|4040|4050|4060|4070|4080|4090|4100|4110|5000|5010|5020|5030|5040|5050|6000|6010|6020|6030|6040|7000|7010|7020|7030|7040|8000|8010|8020|9000|10000)
+ if test -r ${LSOF_INCLUDE}/nfs/rpcv2.h # {
+ then
+ LSOF_CFGF="$LSOF_CFGF -DHASRPCV2H"
Index: sysutils/lsof/files/patch-dialects-freebsd-dlsof.h
===================================================================
RCS file: sysutils/lsof/files/patch-dialects-freebsd-dlsof.h
diff -N sysutils/lsof/files/patch-dialects-freebsd-dlsof.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ sysutils/lsof/files/patch-dialects-freebsd-dlsof.h 11 Oct 2011 11:44:44
-0000
@@ -0,0 +1,12 @@
+--- dialects/freebsd/dlsof.h.orig 2011-08-15 18:15:57.000000000 +0200
++++ dialects/freebsd/dlsof.h 2011-10-11 13:34:59.000000000 +0200
+@@ -88,6 +88,9 @@
+ # endif /* defined(NEEDS_BOOLEAN_T) */
+
+ #include <sys/conf.h>
++#ifdef ffs
++#undef ffs
++#endif
+
+ # if defined(HAS_VM_MEMATTR_T)
+ #undef vm_memattr_t
_______________________________________________
freebsd-current@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-current
To unsubscribe, send any mail to "freebsd-current-unsubscr...@freebsd.org"