From owner-freebsd-current@FreeBSD.ORG Tue Oct 11 18:52:27 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 6543C1065670; Tue, 11 Oct 2011 18:52:27 +0000 (UTC) (envelope-from lacombar@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id A48838FC30; Tue, 11 Oct 2011 18:52:26 +0000 (UTC) Received: by wwe3 with SMTP id 3so10563197wwe.31 for ; Tue, 11 Oct 2011 11:52:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=oi/a2JQ6HcdPGcrAlpnLYfx/+CO++5kMRemY8UoWKJ4=; b=x9IPmHGJbbunOeFMKPZX3+qOdUzbueQFDDRvoa9s5SXndEDJKLm6LSsaOExK+PwPxL 39ZjDwwKVxkxoGBMZsvZlOiqmfNQtwWpKPOcgN7n4/Mu2s36yoMHxCiILN3ex3E7IC+F jFByKIQ4kXDdauXF30cnDO6HHRP9T3jqVR8rU= MIME-Version: 1.0 Received: by 10.227.29.161 with SMTP id q33mr6318541wbc.49.1318359145572; Tue, 11 Oct 2011 11:52:25 -0700 (PDT) Received: by 10.180.103.33 with HTTP; Tue, 11 Oct 2011 11:52:17 -0700 (PDT) In-Reply-To: <4E948D59.5020006@lerctr.org> References: <4E942FF1.9000805@FreeBSD.org> <4E948D59.5020006@lerctr.org> Date: Tue, 11 Oct 2011 14:52:17 -0400 Message-ID: From: Arnaud Lacombe To: Larry Rosenman Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: =?ISO-8859-1?Q?Ren=E9_Ladan?= , freebsd-current@freebsd.org, Dimitry Andric 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 18:52:27 -0000 Hi, On Tue, Oct 11, 2011 at 2:39 PM, Larry Rosenman wrote: > On 10/11/2011 1:36 PM, Arnaud Lacombe wrote: >> >> Hi, >> >> On Tue, Oct 11, 2011 at 8:00 AM, Dimitry Andric =A0wrot= e: >>> >>> On 2011-10-09 19:32, Larry Rosenman wrote: >>>> >>>> I had gotten a PR about sysutils/lsof not compiling with clang. =A0I h= ad >>>> 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 cla= ng >>>> compilable? >>> >>> The problem isn't that clang can't compile the system headers, but >>> normally these don't get included from userspace. =A0And they certainly >>> won't work as expected when you define _KERNEL in userspace, as the lso= f >>> port foolishly does. =A0It probably can't be avoided in such a tool, >>> though. >>> >> #ifdef _KERNEL/#endif protected part of system headers shall NEVER be >> accessed by userland. It is a fault to have them present in >> /usr/include. Linux got it right there, all those part are removed >> upon headers' installation. >> >> =A0- Arnaud > > Then lsof would NOT be compilable / usable at all, as it delves into > /dev/kmem to get information. > AFAIK, Linux is capable of supporting lsof in a backward compatible manner, without exposing its internal guts. FWIW, KVM is a bad kernel/userland interface, as it does not guarantee backward compatibility. > And it **NEEDS** to know what the structures are. > No, not kernel-only structure. Now, if these structure are not meant to be kernel only, move them out of _KERNEL area, but beware of backward compatibility issue in the future. > That is unless someone(tm) writes the Kernel interfaces to get the info. > Yes, this is the core of the problem and a classical chicken/eggs problem solves the very wrongest way. At some point, I thought to modify the build system to pass kernel's headers through unifdef(1), but I quickly forgot about that: % git grep 'define _KERNEL' * | grep -v '^sys' | wc -l 27 - Arnaud