From owner-freebsd-current@FreeBSD.ORG Tue Oct 11 13:31:26 2011 Return-Path: Delivered-To: freebsd-current@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 209D91065670; Tue, 11 Oct 2011 13:31:26 +0000 (UTC) (envelope-from ler@lerctr.org) Received: from thebighonker.lerctr.org (lrosenman-1-pt.tunnel.tserv8.dal1.ipv6.he.net [IPv6:2001:470:1f0e:3ad::2]) by mx1.freebsd.org (Postfix) with ESMTP id DACD98FC0A; Tue, 11 Oct 2011 13:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lerctr.org; s=lerami; h=Content-Type:MIME-Version:References:Message-ID:In-Reply-To:Subject:cc:To:Sender:From:Date; bh=UxjmSVQ7qw3ujJphMVcHPgEMTxreq8TK20TWtY0y0b4=; b=G/zzVrUR0kELRBdN97arkmMf0Qh6F61F97XppUYNsiw6WlmkJpauzRnrWHWJiQiLmf9nNPkC980IX/Q4V7IHUJXIzkMorDGyERwH89YohHUpu9OSm49IM10HJqLSQ08Fpba6yBvNYVoZDnBWE/xDEbUOqpKqohSHO1hTVCUhK5c=; Received: from cpe-72-182-3-73.austin.res.rr.com ([72.182.3.73]:63444 helo=[192.168.200.4]) by thebighonker.lerctr.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.76 (FreeBSD)) (envelope-from ) id 1RDcQS-000EfS-U1; Tue, 11 Oct 2011 08:31:25 -0500 Date: Tue, 11 Oct 2011 08:31:18 -0500 (CDT) From: Larry Rosenman Sender: ler@lrosenman.dyndns.org To: Dimitry Andric In-Reply-To: <4E942FF1.9000805@FreeBSD.org> Message-ID: References: <4E942FF1.9000805@FreeBSD.org> User-Agent: Alpine 2.00 (BSF 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Spam-Score: -2.9 (--) X-LERCTR-Spam-Score: -2.9 (--) X-Spam-Report: SpamScore (-2.9/5.0) ALL_TRUSTED=-1,BAYES_00=-1.9 X-LERCTR-Spam-Report: SpamScore (-2.9/5.0) ALL_TRUSTED=-1,BAYES_00=-1.9 Cc: =?ISO-8859-15?Q?Ren=E9_Ladan?= , freebsd-current@FreeBSD.ORG Subject: Re: System headers with clang? X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 11 Oct 2011 13:31:26 -0000 On Tue, 11 Oct 2011, Dimitry Andric wrote: > 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 and before . > > ... >> 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. > Unless the headers are fixed, Vic Abell (lsof Author) will NOT support it. We need to get clang/system headers to allow warning free compilation just like GCC does. I will NOT accept the change. -- Larry Rosenman http://www.lerctr.org/~ler Phone: +1 512-248-2683 E-Mail: ler@lerctr.org US Mail: 430 Valona Loop, Round Rock, TX 78681-3893