Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 28099 - fix /usr/include/{asm,linux} to properly support different kernel versions
Summary: fix /usr/include/{asm,linux} to properly support different kernel versions
Status: RESOLVED WORKSFORME
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: Highest critical (vote)
Assignee: Martin Schlemmer (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-06 23:27 UTC by mlmoser
Modified: 2003-11-29 14:55 UTC (History)
4 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description mlmoser 2003-09-06 23:27:14 UTC
Did you know that if the /usr/include/linux and /usr/include/asm directories
contain headers from a different kernel, the kernel may compile bad?  In some
cases depmod -ae -F System.map may see everything as looking fine, but just
depmod -ae will spit out tons of 'unresolved symbol' errors in all modules, and
modprobe/insmod won't be able to load modules.  This is especially true for
patched kernels (like gentoo-sources or openMosix).

Unfortunately, if you don't use the kernel-headers originally installed to
/usr/include, the system won't compile everything right.  For instance, try
symlinking the headers from 2.4.20-gentoo-r6 into those directories, and then
emerge gnomemeeting.  It can't compile libopenh323 at all, for example.

So in different instances, different things must exist there.  Sound painful? 
GCC seems to currently depend on the 2.4.19 headers being there for the most part.

Please note this in the install guide.  Also, please begin installing the
headers to /usr/include/linux-real and /usr/include/asm-real , and symlink
/usr/src/linux/include/linux to /usr/include/linux-kern and
/usr/src/linux/include/asm-[platform] to /usr/include/asm-kern .  Please also
supply a script to change these links:

set-kheaders:
#!/bin/sh
if [ "$1" = "kernel" ]; then
  echo "Symlinking Linux kernel headers to /usr/include . . ."
  rm -f /usr/include/linux /usr/include/asm
  ln -s linux-kern /usr/include/linux
  ln -s asm-kern /usr/include/asm
  echo "done."
  exit
fi
if [ "$1" = "real" ]; then
  echo "Symlinking real installed headers to /usr/include . . ."
  rm -f /usr/include/linux /usr/include/asm
  ln -s linux-real /usr/include/linux
  ln -s asm-real /usr/include/asm
  echo "done."
  exit
fi

echo "Please specify kernel or real"
Comment 1 SpanKY gentoo-dev 2003-09-06 23:32:41 UTC
yes we know and we've been working on a solution ...

there's a few threads on LKML you might want to read
Comment 2 Sven Vermeulen (RETIRED) gentoo-dev 2003-09-07 02:45:47 UTC
If you want to be perfectly straight with what is in the Documentation of the kernel sources, you shouldn't even have the sources inside /usr/src/linux :/

I've had a similar discussion some time ago with lolo. I've asked him this:

"""
> In Gentoo Linux, the kernel sourcecode is installed in /usr/src/linux-version
> and /usr/linux is a symlink to that directory.
>
> However, the Linux kernel README clearly states:
>
> [...]
>    Do NOT use the /usr/src/linux area! This area has a (usually
>    incomplete) set of kernel headers that are used by the library header
>    files.  They should match the library, and not get messed up by
>    whatever the kernel-du-jour happens to be.
> [...]
>
> I've found the following document concerning this problem:
> http://www.linuxgazette.com/issue62/tag/4.html
>
> This is a discussion with a person familiar with kernel developing.
>
> Can you shed any lights on this, and if Gentoo's "breaking" this with unknown
> consequences, can you fix this?
"""

I've had the following reply:

Actually we solve this concern in a very different way.  Most linux
distributions use a symlink to /usr/src/linux/include/asm and
/usr/src/linux/include/linux for the linux kernel headers for the C library.  We
do not.  We physically install headers during system installation directly to
/usr/src/include/linux and /usr/src/include/asm so it is then perfectly
acceptable to use /usr/src/linux for whatever kernel the system happens to be
running.

Just letting you know :)
Comment 3 Martin Schlemmer (RETIRED) gentoo-dev 2003-09-07 03:29:41 UTC
> Actually we solve this concern in a very different way.  Most linux
> distributions use a symlink to /usr/src/linux/include/asm and
> /usr/src/linux/include/linux for the linux kernel headers for the C library.
> We do not.  We physically install headers during system installation
> directly to /usr/src/include/linux and /usr/src/include/asm so it is then
> perfectly acceptable to use /usr/src/linux for whatever kernel the system
> happens to be running.

This is how we have been handling it from day one.  The only places where I know
of breakage is if you user symlink his live kernel to /usr/include/{asm,linux},
or if he does not maintain his /usr/src/linux symlink (but this is more for
things like svgalib, etc that needs the live kernel headers).

Isn't this documented anymore ?  It used to be in big red (ok, not that bad ;):

  Do not remove /usr/include/{asm,linux} or replace them with a diff version!

If not, we should get the docs fixed, and not try to 'fix' it with a fix that
will complicate everything.  We might even have portage check the
/usr/include/{asm,linux} to be directories, and not symlinks, and also if
/usr/src/linux symlink is valid .. Nick?
Comment 4 mlmoser 2003-09-07 08:28:21 UTC
Alright, so if you all have the kernel headers installed to /usr/src/linux and /usr/src/asm, why is it that I don't see these directories, and that the linux-headers ebuild installs files to /usr/include/linux and /usr/include/asm ?

The problem is that the kernel breaks unless /usr/include/{linux|asm} are symlinked into the current kernel tree; but if they are, many compiles will break because the library doesn't like those headers.  This means that under your current scheme, you need to have these directories have different contents at different times, depending on what you are doing.

I can't believe I'm the only one that has compiled a kernel and had depmod -ae spit out every symbol in every module as being unresolved.  Try a 2.4.22-openMosix or otherwise heavily patched kernel with /usr/include/{linux|asm} containing the 2.4.19 vanilla's.  The depmod -ae -F System.map that gets run on make modules_install is fine, but if you don't give it the System.map, it doesn't work.  modprobe doesn't work either.

It seems this problem is somewhat an enigma.  The kernel build system really is supposed to use the headers in ${TOPDIR}/include, NOT /usr/include, but for some reason it doesn't seem to work that way.  Those of us using older versions of the kernel for various reasons (available patches, broken h/w, etc) can't really rely on a new, fixed build system either.  Looks like you've all painted eachother into your corners.  Who's got a mop?
Comment 5 Martin Schlemmer (RETIRED) gentoo-dev 2003-09-07 08:49:29 UTC
I think you are a bit confused.  Default apps, etc should use /usr/include/..
for 'kernel' headers.  Things like nvidia-kernel, etc in *Gentoo* by default
is (or should be) fixed to use headers in /usr/src/linux/include, which should
point to your current, or new kernel that you want to use (meaning it is
possible to compile a new kernel, then merge nvidia-kernel, and then reboot
having nvidia.o ready to be loaded with the new kernel).

The kernel should by default use like you said, the headers in $TOPDIR/include,
and in newer kernels '-nostdinc -iwithprefix include' is added to CFLAGS to make
sure of this (have a look at bug #8132).

If it breaks for 2.4.20 and later, it might be a kernel/gcc problem.  It might
also be as in #8132 a wrapper (such as those from gcc-config, ccache or distcc)
that could cause breakage.  Have you tried another kernel than 2.4.22-openmosix?

Lastly be nice =)
Comment 6 mlmoser 2003-09-07 16:02:15 UTC
The om prepatch for .22 was the last I tried.  I've had problems with various.  I still do the movement by hand based on situation.  I don't use a wrapper though . . . just `make menuconfig clean dep bzImage modules && rm -rf /lib/modules/{kernver} && make modules_install && cp arch/i386/boot/bzImage /boot/bzImage-{kernver}`.  And I AM being nice, so shut up :-p
Comment 7 Martin Schlemmer (RETIRED) gentoo-dev 2003-09-07 18:32:16 UTC
Could you try the fix in:

   http://bugs.gentoo.org/show_bug.cgi?id=8132#c21

and see if that fixes.  If so, we know it is similar issues ...
Comment 8 Martin Schlemmer (RETIRED) gentoo-dev 2003-09-14 07:27:06 UTC
Works this side.  Please reopen if you have more to add.