[pkg-nvidia-devel] Bug#520706: nvidia-kernel-source: fails to build modules against 2.6.29 or later linux-headers packages

Paul TBBle Hampson Paul.Hampson at Pobox.com
Sun Mar 22 08:17:44 UTC 2009

Package: nvidia-kernel-source
Version: 180.29-1
Severity: important

As of revision 12910 in the debian-kernel SVN repository (right after
2.6.28-1 was released) the layout of the linux-headers-* packages has
changed slightly.

Formerly, linux-headers-*-{flavour} contained symlinks into
linux-headers-*-common for the common files.

Now, instead linux-headers-*-{flavour} provides a Makefile of its own
which chains into the linux-headers-*-common Makefile.

This works fine for kbuild invocations, but means that direct attempts
to build using CFLAGS=-I/lib/modules/*/build will fail on all but the
most trivial inclusion trees. (eg linux/version.h and linux/autoconf.h
should work)

When the nvidia-kernel-source module attempts to build conftest.h using
conftest.sh and for most other conftest.sh operations, it does not use
kbuild, but instead uses CFLAGS. This causes conftest.h to fail to
generate usefully, and so the module build fails.

I've modified conftest.sh to use kbuild, and attached it, but there's a
problem with it: When called directly, it's fine. When called during a
module build, the outer module build is somehow overriding conftest.sh's
kbuild invocation and attempting to build the nvidia module again. This
causes conftest.sh to be called again, and so it recurses infinitely.

The changes to conftest.sh are pretty simple. I added a
prepare_confmod_dir function to prepare a confmod directory for building
the module in, and set up a couple of variables, KBCMD and KBTARGET. Then I changed all
references to conftest$$ to $KBTARGET, to make things easier if KBTARGET
changes (ie make it a /tmp directory or use $$ somewhere in it) and all
references to CC to KBCMD.

One further change I had to make was the detection of presence or
absence of functions. The current conftest.sh relies on the behaviour
that calling an undeclared function doesn't fail to compile, while
calling a declared function with the wrong number of arguments will fail
to compile. However, kbuild (as of 2.6.18 or so) turns on
-Werror-implicit-function-declaration which cannot be overridden and
changes the behaviour. In those cases I simply added the declaration
that would otherwise be implicit, which makes the behaviour a
distinction between declaring a new function (which compiles) and
redeclaring an existing function with different arguments.

That last change could possibly be pushed upstream if nVidia are
willing/interested, as it's less likely to be tripped over by random
CFLAGS changes (eg -Werror would also break the old method)

HOSTCC invocations still use the CFLAGS=-I$SOURCES method, but all the
uses of that I saw in the file (get_uname and select_makefile) seem to
work fine in this instance.

I've only tested this on the 2.6.29-rc8 package from the debian-kernel
buildserver, because I hadn't actually gotten it working there yet, but
in theory the method should be sound (I think) for all Debian-supported
kernels and header packages.

I've marked this important as according to waldi on the #debian-kernel
IRC channel, not using kbuild is wrong. Feel free to downgrade if this
is not appropriate, given we're talking about a not-yet-in-Debian
version, and it might not be too late to browbeat the kernel team back
into building symlink farms...

Waldi also said that the correct solution would be to use #if
VERSION_CODE tests instead, which would be a pain to maintain without
upstream support. This one's quite easy to patch in, as it's just a
single new function and a search-replace, and five test changes out of
the 20-30 tests in the file (ie the function tests that use #error to
announce that the function was found but the number of arguments didn't
match any expectations).

-- System Information:
Debian Release: 5.0
  APT prefers unstable
  APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: i386 (i686)

Kernel: Linux 2.6.26-1-686 (SMP w/1 CPU core)
Locale: LANG=en_AU.UTF-8, LC_CTYPE=en_AU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Paul "TBBle" Hampson, Paul.Hampson at Pobox.com

Shorter .sig for a more eco-friendly paperless office.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: conftest.sh
Type: application/x-sh
Size: 48940 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-nvidia-devel/attachments/20090322/da4c6c7e/attachment-0001.sh 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.alioth.debian.org/pipermail/pkg-nvidia-devel/attachments/20090322/da4c6c7e/attachment-0001.pgp 

More information about the Pkg-nvidia-devel mailing list