Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Oct 2011 15:37:14 -0400
From:      Arnaud Lacombe <lacombar@gmail.com>
To:        Larry Rosenman <ler@lerctr.org>
Cc:        =?ISO-8859-1?Q?Ren=E9_Ladan?= <rene@freebsd.org>, freebsd-current@freebsd.org, Dimitry Andric <dim@freebsd.org>
Subject:   Re: System headers with clang?
Message-ID:  <CACqU3MW7A5VSLvp4_xsm2=42mazp%2BTF%2BgUPe9FjTo7vLDFh1NA@mail.gmail.com>
In-Reply-To: <4E949351.5040904@lerctr.org>
References:  <alpine.BSF.2.00.1110091229550.43656@lrosenman.dyndns.org> <4E942FF1.9000805@FreeBSD.org> <CACqU3MV9vP%2BVUR%2B2Qpzc4mCS1w3R17yvMGNPT%2BxnsGUiYr8VFQ@mail.gmail.com> <4E948D59.5020006@lerctr.org> <CACqU3MVETLMRuYuVpZ0aehdr7rX4KqZGFG17pKdFeSut7jOCCw@mail.gmail.com> <4E949351.5040904@lerctr.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On Tue, Oct 11, 2011 at 3:04 PM, Larry Rosenman <ler@lerctr.org> wrote:
> On 10/11/2011 1:52 PM, Arnaud Lacombe wrote:
>>
>> Hi,
>>
>> On Tue, Oct 11, 2011 at 2:39 PM, Larry Rosenman<ler@lerctr.org> =A0wrote=
:
>>>
>>> On 10/11/2011 1:36 PM, Arnaud Lacombe wrote:
>>>>
>>>> Hi,
>>>>
>>>> On Tue, Oct 11, 2011 at 8:00 AM, Dimitry Andric<dim@freebsd.org>
>>>> =A0wrote:
>>>>>
>>>>> On 2011-10-09 19:32, Larry Rosenman wrote:
>>>>>>
>>>>>> I had gotten a PR about sysutils/lsof not compiling with clang. =A0I=
 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. =A0And they certain=
ly
>>>>> won't work as expected when you define _KERNEL in userspace, as the
>>>>> lsof
>>>>> 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.
>
> Therein lies the rub. =A0In order to do it's job, it DOES need to grovel
> around in kernel only structures.
>
>
>>
>>> 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
>> =A0 =A0 =A0 27
>>
>> =A0- Arnaud
>
> This is not going to fix things until/unless someone(tm) takes the bull b=
y
> the horns, and writes
> a userland<->kernel interface to get ALL the data that lsof currently
> gathers from groveling around
> in /dev/kmem.
>
> I don't have the skills nor time to do that.
>
What are those interfaces exactly ? How is it done in Linux ?

Thanks,
 - Arnaud



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CACqU3MW7A5VSLvp4_xsm2=42mazp%2BTF%2BgUPe9FjTo7vLDFh1NA>