# nvidia-drivers Unable to determine the target kernel version

## [n00b@localhost]

Hi,

I just updated my linux kernel to 2.6.22-suspend2-r1 (on amd64) and ran "module-rebuild rebuild" to rebuild my external kernel modules. The script wants to rebuild nvidia-drivers-1.0.8776-r1 (because that's the version I currently have installed) but this error also occurs with nvidia-drivers-100.14.09.

```
>>> Emerging (1 of 2) x11-drivers/nvidia-drivers-1.0.8776-r1 to /

 * NVIDIA-Linux-x86_64-1.0-8776-pkg2.run RMD160 ;-) ...                   [ ok ]

 * NVIDIA-Linux-x86_64-1.0-8776-pkg2.run SHA1 ;-) ...                     [ ok ]

 * NVIDIA-Linux-x86_64-1.0-8776-pkg2.run SHA256 ;-) ...                   [ ok ]

 * NVIDIA-Linux-x86_64-1.0-8776-pkg2.run size ;-) ...                     [ ok ]

 * checking ebuild checksums ;-) ...                                      [ ok ]

 * checking auxfile checksums ;-) ...                                     [ ok ]

 * checking miscfile checksums ;-) ...                                    [ ok ]

 * checking NVIDIA-Linux-x86_64-1.0-8776-pkg2.run ;-) ...                 [ ok ]

 * Your CXXFLAGS contains "-fvisibility-inlines-hidden" which can break packages.

 *

 * Before you file a bug, please remove these flags and

 * re-compile the package in question as well as all its dependencies

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/2.6.22-suspend2-r1/build

 * Found sources for kernel version:

 *     2.6.22-suspend2-r1

 * Checking for MTRR support ...                                          [ ok ]

>>> Unpacking source...

Creating directory NVIDIA-Linux-x86_64-1.0-8776-pkg2

Verifying archive integrity... OK

Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 1.0-8776......................................................................................................................................

 * Applying NVIDIA_glx-defines.patch ...                                  [ ok ]

 * Applying NVIDIA_glx-glheader.patch ...                                 [ ok ]

 * Converting Makefile.kbuild to use M= instead of SUBDIRS= ...           [ ok ]

 * Applying NVIDIA_kernel-2.6.19.patch ...                                [ ok ]

>>> Source unpacked.

>>> Compiling source in /var/tmp/portage/x11-drivers/nvidia-drivers-1.0.8776-r1/work/NVIDIA-Linux-x86_64-1.0-8776-pkg2/usr/src/nv ...

 * Preparing nvidia module

If you are using a Linux 2.4 kernel, please make sure

you either have configured kernel sources matching your

kernel or the correct set of kernel headers installed

on your system.

If you are using a Linux 2.6 kernel, please make sure

you have configured kernel sources matching your kernel

installed on your system. If you specified a separate

output directory using either the "KBUILD_OUTPUT" or

the "O" KBUILD parameter, make sure to specify this

directory with the SYSOUT environment variable or with

the equivalent nvidia-installer command line option.

Depending on where and how the kernel sources (or the

kernel headers) were installed, you may need to specify

their location with the SYSSRC environment variable or

the equivalent nvidia-installer command line option.

*** Unable to determine the target kernel version. ***

make: *** [select_makefile] Error 1

!!! ERROR: x11-drivers/nvidia-drivers-1.0.8776-r1 failed.

Call stack:

  ebuild.sh, line 1638:   Called dyn_compile

  ebuild.sh, line 985:   Called qa_call 'src_compile'

  ebuild.sh, line 44:   Called src_compile

  nvidia-drivers-1.0.8776-r1.ebuild, line 186:   Called linux-mod_src_compile

  linux-mod.eclass, line 516:   Called die

!!! Unable to make  IGNORE_CC_MISMATCH=yes V=1 SYSSRC=/usr/src/linux SYSOUT=/lib/modules/2.6.22-suspend2-r1/build clean module.

!!! If you need support, post the topmost build error, and the call stack if relevant.

!!! A complete build log is located at '/var/log/portage/x11-drivers:nvidia-drivers-1.0.8776-r1:20070823-084045.log'.
```

```
>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-100.14.09 to /

 * NVIDIA-Linux-x86_64-100.14.09-pkg2.run RMD160 ;-) ...                  [ ok ]

 * NVIDIA-Linux-x86_64-100.14.09-pkg2.run SHA1 ;-) ...                    [ ok ]

 * NVIDIA-Linux-x86_64-100.14.09-pkg2.run SHA256 ;-) ...                  [ ok ]

 * NVIDIA-Linux-x86_64-100.14.09-pkg2.run size ;-) ...                    [ ok ]

 * checking ebuild checksums ;-) ...                                      [ ok ]

 * checking auxfile checksums ;-) ...                                     [ ok ]

 * checking miscfile checksums ;-) ...                                    [ ok ]

 * checking NVIDIA-Linux-x86_64-100.14.09-pkg2.run ;-) ...                [ ok ]

 * Your CXXFLAGS contains "-fvisibility-inlines-hidden" which can break packages.

 *

 * Before you file a bug, please remove these flags and

 * re-compile the package in question as well as all its dependencies

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/2.6.22-suspend2-r1/build

 * Found sources for kernel version:

 *     2.6.22-suspend2-r1

 * Checking for MTRR support ...                                          [ ok ]

>>> Unpacking source...

Creating directory NVIDIA-Linux-x86_64-100.14.09-pkg2

Verifying archive integrity... OK

Uncompressing NVIDIA Accelerated Graphics Driver for Linux-x86_64 100.14.09.....................................................................................................................................

 * Applying NVIDIA_glx-defines.patch ...                                  [ ok ]

 * Applying NVIDIA_glx-glheader.patch ...                                 [ ok ]

 * Applying NVIDIA_i2c-hwmon.patch ...                                    [ ok ]

 * Converting Makefile.kbuild to use M= instead of SUBDIRS= ...           [ ok ]

>>> Source unpacked.

>>> Compiling source in /var/tmp/portage/x11-drivers/nvidia-drivers-100.14.09/work/NVIDIA-Linux-x86_64-100.14.09-pkg2/usr/src/nv ...

 * Preparing nvidia module

sh ./conftest.sh "x86_64-pc-linux-gnu-gcc" "x86_64-pc-linux-gnu-gcc" /usr/src/linux /lib/modules/2.6.22-suspend2-r1/build cc_sanity_check full_output

rm -f Makefile

sh ./conftest.sh "x86_64-pc-linux-gnu-gcc" "x86_64-pc-linux-gnu-gcc" /usr/src/linux /lib/modules/2.6.22-suspend2-r1/build select_makefile full_output

If you are using a Linux 2.4 kernel, please make sure

you either have configured kernel sources matching your

kernel or the correct set of kernel headers installed

on your system.

If you are using a Linux 2.6 kernel, please make sure

you have configured kernel sources matching your kernel

installed on your system. If you specified a separate

output directory using either the "KBUILD_OUTPUT" or

the "O" KBUILD parameter, make sure to specify this

directory with the SYSOUT environment variable or with

the equivalent nvidia-installer command line option.

Depending on where and how the kernel sources (or the

kernel headers) were installed, you may need to specify

their location with the SYSSRC environment variable or

the equivalent nvidia-installer command line option.

*** Unable to determine the target kernel version. ***

make: *** [select_makefile] Error 1

!!! ERROR: x11-drivers/nvidia-drivers-100.14.09 failed.

Call stack:

  ebuild.sh, line 1638:   Called dyn_compile

  ebuild.sh, line 985:   Called qa_call 'src_compile'

  ebuild.sh, line 44:   Called src_compile

  nvidia-drivers-100.14.09.ebuild, line 212:   Called linux-mod_src_compile

  linux-mod.eclass, line 516:   Called die

!!! Unable to make  IGNORE_CC_MISMATCH=yes V=1 SYSSRC=/usr/src/linux SYSOUT=/lib/modules/2.6.22-suspend2-r1/build clean module.

!!! If you need support, post the topmost build error, and the call stack if relevant.

!!! A complete build log is located at '/var/log/portage/x11-drivers:nvidia-drivers-100.14.09:20070823-091619.log'.
```

I added a line to linux-mod.eclass to print out the command that is failing for debugging purposes. If I change to portage's temporary working directory after the emerge has failed and run the command manually it compiles fine but seeing as the emerge has failed I can't install it.

```
Portage 2.1.2.12 (default-linux/amd64/2007.0, gcc-4.1.2, glibc-2.5-r4, 2.6.22-suspend2-r1 x86_64)

=================================================================

System uname: 2.6.22-suspend2-r1 x86_64 AMD Athlon(tm) 64 X2 Dual Core Processor 4800+

Gentoo Base System release 1.12.9

Timestamp of tree: Wed, 22 Aug 2007 23:20:01 +0000

ccache version 2.4 [enabled]

dev-java/java-config: 1.3.7, 2.0.33-r1

dev-lang/python:     2.4.4-r4

dev-python/pycrypto: 2.0.1-r6

dev-util/ccache:     2.4-r7

sys-apps/sandbox:    1.2.17

sys-devel/autoconf:  2.13, 2.61

sys-devel/automake:  1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2, 1.10

sys-devel/binutils:  2.17

sys-devel/gcc-config: 1.3.16

sys-devel/libtool:   1.5.24

virtual/os-headers:  2.6.21

ACCEPT_KEYWORDS="amd64"

AUTOCLEAN="yes"

CBUILD="x86_64-pc-linux-gnu"

CFLAGS="-O3 -march=athlon64 -fforce-addr -fomit-frame-pointer -ftracer -pipe"

CHOST="x86_64-pc-linux-gnu"

CONFIG_PROTECT="/etc /usr/kde/3.5/env /usr/kde/3.5/share/config /usr/kde/3.5/shutdown /usr/share/X11/xkb /usr/share/config"

CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/php/apache2-php5/ext-active/ /etc/php/cgi-php5/ext-active/ /etc/php/cli-php5/ext-active/ /etc/revdep-rebuild /etc/splash /etc/terminfo"

CXXFLAGS="-O3 -march=athlon64 -fforce-addr -fomit-frame-pointer -ftracer -pipe -fvisibility-inlines-hidden"

DISTDIR="/usr/portage/distfiles"

FEATURES="candy ccache distlocks fixpackages metadata-transfer parallel-fetch prelink sandbox sfperms strict userpriv usersandbox"

GENTOO_MIRRORS="ftp://ftp.mirrorservice.org/sites/www.ibiblio.org/gentoo/ http://www.mirrorservice.org/sites/www.ibiblio.org/gentoo/ ftp://mirrors.blueyonder.co.uk/mirrors/gentoo http://gentoo.blueyonder.co.uk/"

LC_ALL="en_GB.utf8"

LINGUAS="en_GB"

MAKEOPTS="-j3"

PKGDIR="/usr/portage/packages"

PORTAGE_RSYNC_EXTRA_OPTS="--timeout=180"

PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages --filter=H_**/files/digest-*"

PORTAGE_TMPDIR="/var/tmp"

PORTDIR="/usr/portage"

PORTDIR_OVERLAY="/usr/local/portage"

SYNC="rsync://rsync.uk.gentoo.org/gentoo-portage"

USE="3dnow X a52 aac aalib accessibility acl acpi akode alsa amd64 amr apache2 ares arts audiofile avahi bash-completion bcmath berkdb bitmap-fonts bluetooth bzip2 cddb cli cracklib crypt cups dbus dedicated dga directfb dri dts dvb dvd dvdr dvdread dxr3 encode exif fam fbcon fftw flac fortran ftp gd gdbm ggi gif gnutls gphoto2 gpm graphviz gs hal iconv idn ieee1394 imagemagick imap imlib ipv6 isdnlog jack java javascript jpeg kde kdeenablefinal kdexdeltas lcms libcaca lirc lm_sensors mad midi mmap mmx mng modplug mp3 mpeg mudflap musicbrainz mysql mysqli ncurses nis nls nptl nptlonly nsplugin odbc ogg opengl openmp pam pcre perl php png posix pppd python qt3 qt4 quicktime rdesktop readline reflection samba sasl scanner sdl session slp sndfile sockets speex spell spl sse sse2 ssl symlink tcpd theora threads tidy tiff truetype truetype-fonts type1-fonts unicode usb v4l vcd vorbis wifi wmf x264 xcomposite xine xinerama xinetd xml xorg xpm xsl xv xvid xvmc zlib" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" ALSA_PCM_PLUGINS="adpcm alaw asym copy dmix dshare dsnoop empty extplug file hooks iec958 ioplug ladspa lfloat linear meter mulaw multi null plug rate route share shm softvol" ELIBC="glibc" INPUT_DEVICES="keyboard mouse evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LINGUAS="en_GB" LIRC_DEVICES="hauppauge_dvb" USERLAND="GNU" VIDEO_CARDS="nvidia"

Unset:  CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LDFLAGS, PORTAGE_COMPRESS, PORTAGE_COMPRESS_FLAGS
```

----------

## engil

Maybe

```

virtual/os-headers:  2.6.21

```

is not what you should have for a 2.6.22 kernel ?

----------

## i92guboj

Have you updated your /usr/src/linux symlink? Nvidia drivers and most external driver packages use that to decide what kernel to compile against. In addition, the kernel must be configured and compiled so it can link adequately to the relevant stuff.

$ eselect kernel list

$ eselect kernel set <n>

$ ls -ld /usr/src/linux

----------

## [n00b@localhost]

Well spotted engil! I was using the amd64 version of linux-headers with the ~amd64 version of suspend2-sources. I have updated linux-headers to the ~amd64 version and recompiled my kernel but the errors are still happening as before. I think it is an error with the ebuild because I can compile the driver manually.

My kernel symlink is correct and points to the compiled kernel I am currently running.

----------

## Alllg

kernel 2.6.217

Me help next commands:

echo "#define UTS_RELEASE "2.6.21.7"

#define LINUX_VERSION_CODE 132629

#define KERNEL_VERSION(a,b,c) (((a)<<16)+((b)<< :Cool: +(c)) " > /usr/src/linux/include/linux/version.h

ln -s /usr/src/linux/include/asm-i386   /usr/src/linux/include/asm

and edit file /usr/src/linux/.config

set option 

CONFIG_MODVERSION=y

and kernel compiling

----------

## apfritts

did you ever get this to work?

----------

## Alllg

Excuse, was mistaken. 

Expression should look so:

echo "#define UTS_RELEASE \"2.6.21.7\"

#define LINUX_VERSION_CODE 132629

#define KERNEL_VERSION(a,b,c) (((a)<<16)+((b)<< :Cool: +(c)) " > /usr/src/linux/include/linux/version.h

I have executed it in distribution kit Mandriva 2007 Spring

The kernel is received from a site ftp: //ftp.kernel.org/pub/linux/kernel/v2.6

----------

## T-800

I ran into the same problem.

I find, that my compiled kernel's files have 400 permission.

(my umask is 077)

solutions:

-change umask

or

-do the following

```

chown -R portage /usr/src/linux

emerge nvidia-drivers

chown -R root /usr/src/linux

```

----------

## srilliet

I have tried everything in this thread and nothing seems to be working. has anyone found a solution ?

----------

## kernelOfTruth

 *srilliet wrote:*   

> I have tried everything in this thread and nothing seems to be working. has anyone found a solution ?

 

yes, me !

finally I found out what was the problem all the years   :Surprised:   :Shocked: 

in the last 2 weeks I ran into this problem & kept on compiling kernel releases & nvidia-drivers but no help

until I remembered that I had emerged a new gcc -version (from 4.2.2 to 4.2.3) switching back temporarily to the old gcc-version solved it :

```
gcc-config -l
```

then select the old gcc-version by

```

gcc-config <X>
```

X == old gcc release

after that enter 

```
env-update && source /etc/profile
```

 twice

(after the first time push arrow up && enter, that should display the just entered command -> bash-history)

now try to emerge nvidia-drivers again

if you've updated from 4.1.1 to 4.2.0 it might be different, in that case please ask if someone has a solution to this problem on this forum / irc

good luck   :Smile: 

----------

## kitsunenokenja

To append to KernelOfTruth's post, I recall at some point reading that it is important that you should be consistent with which version of gcc you use when you build your kernel and modules for it. I guess this is an example of why you should follow that. I can't personally confirm this because I don't change gcc versions between kernel and module builds.

----------

## kernelOfTruth

 *DarkMorph wrote:*   

> To append to KernelOfTruth's post, I recall at some point reading that it is important that you should be consistent with which version of gcc you use when you build your kernel and modules for it. I guess this is an example of why you should follow that. I can't personally confirm this because I don't change gcc versions between kernel and module builds.

 

no !  :Wink: 

my post has EXACTLY the opposite meaning:

after having upgraded to gcc-4.2.3 I recompiled whole system & compiled a new kernel, but it wouldn't install nvidia-drivers (with the new compiler)

so I was FORCED to switch back to a different compiler version

strange - huh ?

----------

## kitsunenokenja

 *kernelOfTruth wrote:*   

>  *DarkMorph wrote:*   To append to KernelOfTruth's post, I recall at some point reading that it is important that you should be consistent with which version of gcc you use when you build your kernel and modules for it. I guess this is an example of why you should follow that. I can't personally confirm this because I don't change gcc versions between kernel and module builds. 
> 
> no ! 
> 
> my post has EXACTLY the opposite meaning:
> ...

 

What the..?! The only reasonable explanation I can think of is this: You mentioned going from gcc 4.1 to 4.2. Wasn't that change a cause for problems with nvidia-drivers up until a certain version when nVidia released drivers that would work with 4.2? It's been a while so I don't remember for certain. Depending on the version of the nvidia-drivers package, that might explain it.

----------

## kernelOfTruth

a temporary solution for hardened gentoo-users (especially amd64 ones) is to switch from the full blown gcc profile to the 

nopie / nossp profiles:

e.g. from

 *Quote:*   

> [7] x86_64-pc-linux-gnu-4.2.3 *
> 
>  [8] x86_64-pc-linux-gnu-4.2.3-hardenednopiessp
> 
>  [9] x86_64-pc-linux-gnu-4.2.3-hardenednossp
> ...

 

to 

 *Quote:*   

> [7] x86_64-pc-linux-gnu-4.2.3 
> 
>  [8] x86_64-pc-linux-gnu-4.2.3-hardenednopiessp *
> 
>  [9] x86_64-pc-linux-gnu-4.2.3-hardenednossp
> ...

 

that'll let you emerge nvidia-drivers,

don't forget to

```
 chmod -R go+rX .
```

 on the /usr/src/linux directory before emerging nvidia-drivers !   :Idea: 

----------

## amar_

I have only one gcc version [1] i686-pc-linux-gnu-4.1.2 * so what to do ?   :Embarassed: 

----------

## kernelOfTruth

ok, 2 things to do if you don't have hardened:

```
chmod -R go+rX /usr/src/linux && chmod -R go+rX /lib/modules/*
```

that should do it

good luck   :Smile: 

----------

## baldeante

Hello,

I had the same problem none of the above work with me but i found a solution on this topic

https://forums.gentoo.org/viewtopic-t-642722-postdays-0-postorder-asc-start-25.html

Please check Xaid Post.

----------

## kernelOfTruth

besides switching to the nopie profile for hardened toolchain users, you also might want to try

* switching between gcc releases (if something's not working right with your current gcc-version)

* switching between binutils versions: e.g. x86_64-pc-linux-gnu-2.19.51.0.2 doesn't work for me, whereas x86_64-pc-linux-gnu-2.19.51.0.1 works

for those of you running ~amd64 or ~x86

----------

