2005-01-09 09:21:14

by Michal Feix

[permalink] [raw]
Subject: Conflicts in kernel 2.6 headers and {glibc,Xorg}

Hello evereyone!

First, I'm not on kernel mailing list so please CC any replies to me.
Thank you.

Yesterday I was recompiling my Linux from Scratch distribution for the
first time with Linux kernel 2.6.10 headers as a base for glibc. I've
found, that glibc (and XOrg later on too) won't compile, as there is a
conflict in certain functions or macros that glibc and Kernel headers
both define.

One was in asm/bitops.h (strictly speaking, asm-i386/bitops.h) named
__ffs, which is defined with unsigned long (both for return type and
parameter) in linux kernel, but as int in glibc sources. Others were in
asm/system.h. Macro mb() and nop() which conflicts with Xorg sources and
with one part of KDE as well (mb() macro and kdepim sources).

Now I am a bit confused. To force my glibc, Xorg and KDE to compile
cleanly, I had to rename these in kernel headers in my /usr/include/asm
directory, so they are no longer conflicting (which of course breaks the
rest of kernel header files, that use these macros), but since I was
changing only files in /usr/include/asm, it's probably a "no harm done"
change, as my Kernel has it's own copy of these files.

My question is: is this a bug in glibc and Xorg sources that they
declare macros and functions with the same name as kernel headers? I
believe not, as it worked cleanly with kernel 2.4 headers and glibc was
first to use these names. :)

Or is it a bug in kernel 2.6 headers, which should be fixed by including
these functions and macros into __KERNEL__ block, so they will not
collide with userspace sources?

Thanks for reading this to the end... :)

--
Michal Feix
[email protected]


2005-01-09 11:06:43

by Chris Lingard

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

On Sunday 09 January 2005 09:20, you wrote:

> Yesterday I was recompiling my Linux from Scratch distribution for the
> first time with Linux kernel 2.6.10 headers as a base for glibc.

Linux from Scratch uses sanitized headers; if you want to use raw
headers, you should be able to solve your own problems.

http://www.lfs-matrix.de/lfs/view/stable/chapter05/linux-libc-headers.html

Chris Lingard

2005-01-09 11:06:21

by Tomasz Torcz

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

On Sun, Jan 09, 2005 at 10:20:45AM +0100, Michal Feix wrote:
> Hello evereyone!
>
> First, I'm not on kernel mailing list so please CC any replies to me.
> Thank you.
>
> Yesterday I was recompiling my Linux from Scratch distribution for the
> first time with Linux kernel 2.6.10 headers as a base for glibc. I've
> found, that glibc (and XOrg later on too) won't compile, as there is a
> conflict in certain functions or macros that glibc and Kernel headers
> both define.

Are you using proper kernel headers - from
http://ep09.pld-linux.org/~mmazur/linux-libc-headers/ ?

--
Tomasz Torcz "God, root, what's the difference?"
[email protected] "God is more forgiving."

2005-01-09 11:36:17

by Michal Feix

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

>>First, I'm not on kernel mailing list so please CC any replies to me.
>>Thank you.
>>
>>Yesterday I was recompiling my Linux from Scratch distribution for the
>>first time with Linux kernel 2.6.10 headers as a base for glibc. I've
>>found, that glibc (and XOrg later on too) won't compile, as there is a
>>conflict in certain functions or macros that glibc and Kernel headers
>>both define.
>
>
> Are you using proper kernel headers - from
> http://ep09.pld-linux.org/~mmazur/linux-libc-headers/ ?

No, I am not, because I wasn't told to do so. For meny years I always
used vanilla sources from kernel.org for my /usr/include/... I wasn't
told, that it is wrong and I still believe, that Linux kernel headers
should be fixed by including these conflicting macros and functions into
__KERNEL__ block instead. Or am I missing something?

--
Michal

2005-01-09 11:54:06

by Tomasz Torcz

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

On Sun, Jan 09, 2005 at 12:35:41PM +0100, Michal Feix wrote:
> > Are you using proper kernel headers - from
> >http://ep09.pld-linux.org/~mmazur/linux-libc-headers/ ?
>
> No, I am not, because I wasn't told to do so. For meny years I always
> used vanilla sources from kernel.org for my /usr/include/... I wasn't
> told, that it is wrong and I still believe, that Linux kernel headers
> should be fixed by including these conflicting macros and functions into
> __KERNEL__ block instead. Or am I missing something?

According to Linus, using straight kernel headers for /usr/include
is obsolete for 10 (ten) years now. I do not agree, but kernel
developers do.
There was few discussion on this topic. Here's one Linus post:
http://www.ussg.iu.edu/hypermail/linux/kernel/0007.3/0587.html
Here you can find latest thread about fixing this issue:
http://lkml.org/lkml/2004/11/26/106

Mainstream distributions use ,,sanitized'' version o kernel
headers - Fedora has own set, Debian has another, LFS too. For rest and
for us, casual users, there are headers made as byproduct of PLD
Linux, which are used since december 2003 (before kernel 2.6 was
even released).

Cheers,
--
Tomasz Torcz Only gods can safely risk perfection,
[email protected] it's a dangerous thing for a man. -- Alia

2005-01-09 12:25:32

by DervishD

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

Hi All :)

* Tomasz Torcz <[email protected]> dixit:
> Mainstream distributions use ,,sanitized'' version o kernel
> headers - Fedora has own set, Debian has another, LFS too. For rest
> and for us, casual users, there are headers made as byproduct of
> PLD Linux, which are used since december 2003 (before kernel 2.6
> was even released).

But the set of sanitized kernel headers, if you build your own
software and you're not using a distro, is only available for 2.6.x
kernels, not for 2.4.x kernels. What should be done for 2.4 kernels?
I currently use a set of headers from the 2.4 kernel I used to build
my libc, not the headers from the current kernel I'm running, but I
would like to know anyway.

Ra?l N??ez de Arenas Coronado

--
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...

2005-01-09 12:31:54

by Arjan van de Ven

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

On Sun, 2005-01-09 at 13:25 +0100, DervishD wrote:
> Hi All :)
>
> * Tomasz Torcz <[email protected]> dixit:
> > Mainstream distributions use ,,sanitized'' version o kernel
> > headers - Fedora has own set, Debian has another, LFS too. For rest
> > and for us, casual users, there are headers made as byproduct of
> > PLD Linux, which are used since december 2003 (before kernel 2.6
> > was even released).
>
> But the set of sanitized kernel headers, if you build your own
> software and you're not using a distro, is only available for 2.6.x
> kernels, not for 2.4.x kernels.

The headers RH ships work for both...
>
> What should be done for 2.4 kernels?
> I currently use a set of headers from the 2.4 kernel I used to build
> my libc, not the headers from the current kernel I'm running, but I
> would like to know anyway.

.... and you can use 2.6 headers to build a glibc that works excellent
for 2.4 kernels too. The kernel API/ABI *does not change on this level*
between kernel versions. Things may get added, but they do not change.


2005-01-09 12:47:45

by Jesper Juhl

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

On Sun, 9 Jan 2005, Michal Feix wrote:

> > > First, I'm not on kernel mailing list so please CC any replies to me.
> > > Thank you.
> > >
> > > Yesterday I was recompiling my Linux from Scratch distribution for the
> > > first time with Linux kernel 2.6.10 headers as a base for glibc. I've
> > > found, that glibc (and XOrg later on too) won't compile, as there is a
> > > conflict in certain functions or macros that glibc and Kernel headers both
> > > define.
> >
> >
> > Are you using proper kernel headers - from
> > http://ep09.pld-linux.org/~mmazur/linux-libc-headers/ ?
>
> No, I am not, because I wasn't told to do so. For meny years I always used
> vanilla sources from kernel.org for my /usr/include/... I wasn't told, that it
> is wrong and I still believe, that Linux kernel headers should be fixed by
> including these conflicting macros and functions into __KERNEL__ block
> instead. Or am I missing something?
>
I think you'll find these links informative :

http://www.kernelnewbies.org/faq/
- read the section entitled "What's going on with the kernel headers ?"

http://uwsg.iu.edu/hypermail/linux/kernel/0007.3/0587.html
- that's Linus' own explanation of the header issue.

http://groups-beta.google.com/group/linux.kernel/msg/9c467432e123860a?q=kernel+headers+user+space+group:linux.kernel&rnum=2
- a bit more from Linus


--
Jesper Juhl

2005-01-09 15:01:41

by DervishD

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

Hi Arjan :)

* Arjan van de Ven <[email protected]> dixit:
> > But the set of sanitized kernel headers, if you build your own
> > software and you're not using a distro, is only available for 2.6.x
> > kernels, not for 2.4.x kernels.
> The headers RH ships work for both...

Did not know...

> > What should be done for 2.4 kernels?
> > I currently use a set of headers from the 2.4 kernel I used to build
> > my libc, not the headers from the current kernel I'm running, but I
> > would like to know anyway.
> .... and you can use 2.6 headers to build a glibc that works excellent
> for 2.4 kernels too. The kernel API/ABI *does not change on this level*
> between kernel versions. Things may get added, but they do not change.

That's perfect then :))) No problem about the headers then. When
I recompile my glibc I'll pick the latest libc-kernel-headers
available. Thanks a lot for the information, Arjan :))

Ra?l N??ez de Arenas Coronado

--
Linux Registered User 88736
http://www.dervishd.net & http://www.pleyades.net/
It's my PC and I'll cry if I want to...

2005-01-09 16:06:58

by George Georgalis

[permalink] [raw]
Subject: Re: Conflicts in kernel 2.6 headers and {glibc,Xorg}

On Sun, 9 Jan 2005 12:08:05 +0100, Tomasz Torcz <[email protected]> wrote:
> On Sun, Jan 09, 2005 at 10:20:45AM +0100, Michal Feix wrote:
> > Hello evereyone!
> >
> > First, I'm not on kernel mailing list so please CC any replies to me.
> > Thank you.
> >
> > Yesterday I was recompiling my Linux from Scratch distribution for the
> > first time with Linux kernel 2.6.10 headers as a base for glibc. I've
> > found, that glibc (and XOrg later on too) won't compile, as there is a
> > conflict in certain functions or macros that glibc and Kernel headers
> > both define.
>
> Are you using proper kernel headers - from
> http://ep09.pld-linux.org/~mmazur/linux-libc-headers/ ?


I with 2.6.10 a problem came up that had me looking into this too.

Using gcc 3.3.3, my xfree86 is built from cvs release xf-4_4-branch.
When I tried 2.6.10, it built with no problems.

To the best of my knolege, xfree86 is not including any kernel
headers, my source is not where any package would know to look and
there don't seem to be any distro (woody) kernel header packages
installed. I could be wrong, but I don't know where they might be
found, or that I ever needed them for this xfree86 build.

The problem is running X, my display is littered with flashing bits,
as if the card is rendering some cpu register or bus in 2% of the
display.

02:00.0 VGA compatible controller: nVidia Corporation: Unknown device
01f0 (rev a3) (prog-if 00 [VGA])
Flags: bus master, 66Mhz, medium devsel, latency 32, IRQ 16
Memory at ea000000 (32-bit, non-prefetchable) [size=16M]
Memory at e0000000 (32-bit, prefetchable) [size=64M]
Memory at e4000000 (32-bit, prefetchable) [size=512K]
Expansion ROM at <unassigned> [disabled] [size=128K]
Capabilities: [60] Power Management version 2
Capabilities: [44] AGP version 2.0

Is this due to namespace collision? Do I have to take extra
precautions with 2.6.10?

// George

--
George Georgalis, systems architect, administrator Linux BSD IXOYE
http://galis.org/george/ cell:646-331-2027 mailto:[email protected]