# Can't compile Nvidia Drivers on 4.9.6 kernel

## Troopo

Hi,

I've upgraded my kernel to v4.9.6 but nvidia-drivers (multiple versions) seem to fail at build.

```

>>> Verifying ebuild manifests

>>> Running pre-merge checks for x11-drivers/nvidia-drivers-367.57-r1

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/4.9.6-gentoo-r1/build

 * Found sources for kernel version:

 *     4.9.6-gentoo-r1

 * Gentoo supports kernels which are supported by NVIDIA

 * which are limited to the following kernels:

 * <sys-kernel/gentoo-sources-4.9

 * <sys-kernel/vanilla-sources-4.9

 * 

 * You are free to utilize epatch_user to provide whatever

 * support you feel is appropriate, but will not receive

 * support as a result of those changes.

 * 

 * Do not file a bug report about this.

 * 

 * Checking for suitable kernel configuration options...                                                                         [ ok ]

>>> Emerging (1 of 1) x11-drivers/nvidia-drivers-367.57-r1::gentoo

 * NVIDIA-Linux-x86_64-367.57.run SHA256 SHA512 WHIRLPOOL size ;-) ...                                                           [ ok ]

 * nvidia-settings-367.57.tar.bz2 SHA256 SHA512 WHIRLPOOL size ;-) ...                                                           [ ok ]

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/4.9.6-gentoo-r1/build

 * Found sources for kernel version:

 *     4.9.6-gentoo-r1

 * Checking for suitable kernel configuration options...                                                                         [ ok ]

>>> Unpacking source...

>>> Unpacking NVIDIA-Linux-x86_64-367.57.run to /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work

>>> Unpacking nvidia-settings-367.57.tar.bz2 to /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work

>>> Source unpacked in /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work

>>> Preparing source in /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work ...

 * Applying nvidia-drivers-367.57-profiles-rc.patch ...                                                                          [ ok ]

>>> Source prepared.

>>> Configuring source in /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work ...

>>> Source configured.

>>> Compiling source in /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work ...

 * Preparing nvidia module

make -j1 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' ARCH=x86_64 IGNORE_CC_MISMATCH=yes V=1 SYSSRC=/usr/src/linux SYSOUT=/lib/modules/4.9.6-gentoo-r1/build CC=x86_64-pc-linux-gnu-gcc NV_VERBOSE=1 clean module 

rm -f -r conftest

make "CC=x86_64-pc-linux-gnu-gcc" KBUILD_OUTPUT=/lib/modules/4.9.6-gentoo-r1/build KBUILD_VERBOSE=1 -C /usr/src/linux M=/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel ARCH=x86_64 NV_KERNEL_SOURCES=/usr/src/linux NV_KERNEL_OUTPUT=/lib/modules/4.9.6-gentoo-r1/build NV_KERNEL_MODULES="nvidia nvidia-uvm nvidia-modeset nvidia-drm" INSTALL_MOD_DIR=kernel/drivers/video Q= clean

make[1]: Entering directory '/usr/src/linux-4.9.6-gentoo-r1'

make -C /lib/modules/4.9.6-gentoo-r1/build KBUILD_SRC=/usr/src/linux-4.9.6-gentoo-r1 \

-f /usr/src/linux-4.9.6-gentoo-r1/Makefile clean

make[2]: Entering directory '/usr/src/linux-4.9.6-gentoo-r1'

make -f /usr/src/linux-4.9.6-gentoo-r1/scripts/Makefile.clean obj=/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel

  rm -rf /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/.tmp_versions

  rm -f /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/Module.symvers

make[2]: Leaving directory '/usr/src/linux-4.9.6-gentoo-r1'

make[1]: Leaving directory '/usr/src/linux-4.9.6-gentoo-r1'

make "CC=x86_64-pc-linux-gnu-gcc" KBUILD_OUTPUT=/lib/modules/4.9.6-gentoo-r1/build KBUILD_VERBOSE=1 -C /usr/src/linux M=/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel ARCH=x86_64 NV_KERNEL_SOURCES=/usr/src/linux NV_KERNEL_OUTPUT=/lib/modules/4.9.6-gentoo-r1/build NV_KERNEL_MODULES="nvidia nvidia-uvm nvidia-modeset nvidia-drm" INSTALL_MOD_DIR=kernel/drivers/video Q= modules

make[1]: Entering directory '/usr/src/linux-4.9.6-gentoo-r1'

make -C /lib/modules/4.9.6-gentoo-r1/build KBUILD_SRC=/usr/src/linux-4.9.6-gentoo-r1 \

-f /usr/src/linux-4.9.6-gentoo-r1/Makefile modules

make[2]: Entering directory '/usr/src/linux-4.9.6-gentoo-r1'

test -e include/generated/autoconf.h -a -e include/config/auto.conf || (                \

echo >&2;                                                       \

echo >&2 "  ERROR: Kernel configuration is invalid.";           \

echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\

echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.";      \

echo >&2 ;                                                      \

/bin/false)

mkdir -p /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/.tmp_versions ; rm -f /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/.tmp_versions/*

  WARNING: Symbol version dump ./Module.symvers

           is missing; modules will have no dependencies and modversions.

make -f /usr/src/linux-4.9.6-gentoo-r1/scripts/Makefile.build obj=/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel

 CONFTEST: INIT_WORK

 CONFTEST: remap_pfn_range

 CONFTEST: follow_pfn

 CONFTEST: vmap

 CONFTEST: set_pages_uc

 CONFTEST: set_memory_uc

 CONFTEST: set_memory_array_uc

 CONFTEST: change_page_attr

 CONFTEST: pci_get_class

 CONFTEST: pci_choose_state

 CONFTEST: vm_insert_page

 CONFTEST: acpi_device_id

 CONFTEST: acquire_console_sem

 CONFTEST: console_lock

 CONFTEST: kmem_cache_create

 CONFTEST: on_each_cpu

 CONFTEST: smp_call_function

 CONFTEST: acpi_evaluate_integer

 CONFTEST: ioremap_cache

 CONFTEST: ioremap_wc

 CONFTEST: acpi_walk_namespace

 CONFTEST: pci_domain_nr

 CONFTEST: pci_dma_mapping_error

 CONFTEST: sg_alloc_table

 CONFTEST: sg_init_table

 CONFTEST: pci_get_domain_bus_and_slot

 CONFTEST: get_num_physpages

 CONFTEST: efi_enabled

 CONFTEST: proc_create_data

 CONFTEST: pde_data

 CONFTEST: proc_remove

 CONFTEST: pm_vt_switch_required

 CONFTEST: drm_driver_has_set_busid

 CONFTEST: xen_ioemu_inject_msi

 CONFTEST: phys_to_dma

 CONFTEST: get_dma_ops

 CONFTEST: write_cr4

 CONFTEST: of_parse_phandle

 CONFTEST: for_each_online_node

 CONFTEST: node_end_pfn

 CONFTEST: pci_bus_address

 CONFTEST: request_threaded_irq

 CONFTEST: remap_page_range

 CONFTEST: address_space_init_once

 CONFTEST: kbasename

 CONFTEST: fatal_signal_pending

 CONFTEST: list_cut_position

 CONFTEST: vzalloc

 CONFTEST: wait_on_bit_lock_argument_count

 CONFTEST: bitmap_clear

 CONFTEST: usleep_range

 CONFTEST: radix_tree_empty

 CONFTEST: drm_dev_unref

 CONFTEST: drm_reinit_primary_mode_group

 CONFTEST: drm_atomic_set_mode_for_crtc

 CONFTEST: drm_atomic_clean_old_fb

 CONFTEST: get_user_pages_remote

 CONFTEST: drm_gem_object_lookup

 CONFTEST: i2c_adapter

 CONFTEST: pm_message_t

 CONFTEST: irq_handler_t

 CONFTEST: acpi_device_ops

 CONFTEST: acpi_op_remove

 CONFTEST: outer_flush_all

 CONFTEST: proc_dir_entry

 CONFTEST: scatterlist

 CONFTEST: sg_table

 CONFTEST: file_operations

 CONFTEST: vm_operations_struct

 CONFTEST: atomic_long_type

 CONFTEST: pci_save_state

 CONFTEST: file_inode

 CONFTEST: task_struct

 CONFTEST: kuid_t

 CONFTEST: dma_ops

 CONFTEST: dma_map_ops

 CONFTEST: noncoherent_swiotlb_dma_ops

 CONFTEST: fault_flags

 CONFTEST: atomic64_type

 CONFTEST: address_space

 CONFTEST: backing_dev_info

 CONFTEST: kernel_write

 CONFTEST: strnstr

 CONFTEST: iterate_dir

 CONFTEST: kstrtoull

 CONFTEST: mm_context_t

 CONFTEST: drm_bus_present

 CONFTEST: drm_bus_has_bus_type

 CONFTEST: drm_bus_has_get_irq

 CONFTEST: drm_bus_has_get_name

 CONFTEST: drm_driver_has_legacy_dev_list

 CONFTEST: drm_crtc_state_has_connectors_changed

 CONFTEST: drm_init_functions_have_name_arg

 CONFTEST: drm_mode_connector_list_update_has_merge_type_bits_arg

 CONFTEST: drm_helper_mode_fill_fb_struct_has_const_mode_cmd_arg

 CONFTEST: dom0_kernel_present

 CONFTEST: drm_available

 CONFTEST: nvidia_grid_build

 CONFTEST: drm_atomic_available

  x86_64-pc-linux-gnu-gcc -Wp,-MD,/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/nvidia/.nv-frontend.o.d  -nostdinc -isystem /usr/lib/gcc/x86_64-pc-linux-gnu/4.9.4/include -I/usr/src/linux-4.9.6-gentoo-r1/arch/x86/include -I./arch/x86/include/generated/uapi -I./arch/x86/include/generated  -I/usr/src/linux-4.9.6-gentoo-r1/include -I./include -I/usr/src/linux-4.9.6-gentoo-r1/arch/x86/include/uapi -I/usr/src/linux-4.9.6-gentoo-r1/include/uapi -I./include/generated/uapi -include /usr/src/linux-4.9.6-gentoo-r1/include/linux/kconfig.h -I/usr/src/linux-4.9.6-gentoo-r1//tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel -I/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel -D__KERNEL__ -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs -fno-strict-aliasing -fno-common -Werror-implicit-function-declaration -Wno-format-security -std=gnu89 -fno-PIE -mno-sse -mno-mmx -mno-sse2 -mno-3dnow -mno-avx -m64 -falign-jumps=1 -falign-loops=1 -mno-80387 -mno-fp-ret-in-387 -mpreferred-stack-boundary=3 -mtune=generic -mno-red-zone -mcmodel=kernel -funit-at-a-time -maccumulate-outgoing-args -DCONFIG_AS_CFI=1 -DCONFIG_AS_CFI_SIGNAL_FRAME=1 -DCONFIG_AS_CFI_SECTIONS=1 -DCONFIG_AS_FXSAVEQ=1 -DCONFIG_AS_SSSE3=1 -DCONFIG_AS_CRC32=1 -DCONFIG_AS_AVX=1 -DCONFIG_AS_AVX2=1 -DCONFIG_AS_AVX512=1 -DCONFIG_AS_SHA1_NI=1 -DCONFIG_AS_SHA256_NI=1 -pipe -Wno-sign-compare -fno-asynchronous-unwind-tables -fno-delete-null-pointer-checks -Os -Wno-maybe-uninitialized --param=allow-store-data-races=0 -Wframe-larger-than=2048 -fno-stack-protector -Wno-unused-but-set-variable -fno-omit-frame-pointer -fno-optimize-sibling-calls -fno-var-tracking-assignments -Wdeclaration-after-statement -Wno-pointer-sign -fno-strict-overflow -fconserve-stack -Werror=implicit-int -Werror=strict-prototypes -Werror=date-time -DCC_HAVE_ASM_GOTO  -I/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/common/inc  -I/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel -Wall -MD -Wsign-compare -Wno-cast-qual -Wno-error -D__KERNEL__ -DMODULE -DNVRM -DNV_VERSION_STRING=\"367.57\" -Wno-unused-function -Wuninitialized -fno-strict-aliasing -mno-red-zone -mcmodel=kernel -DNV_UVM_ENABLE -Wno-sign-compare -Wno-format-extra-args  -I/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/nvidia -DNV_BUILD_MODULE_INSTANCES=0 -UDEBUG -U_DEBUG -DNDEBUG  -DMODULE  -DKBUILD_BASENAME='"nv_frontend"'  -DKBUILD_MODNAME='"nvidia"' -c -o /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/nvidia/.tmp_nv-frontend.o /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/nvidia/nv-frontend.c

In file included from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/common/inc/conftest.h:5:0,

                 from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/common/inc/nv-linux.h:15,

                 from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/nvidia/nv-frontend.c:13:

/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/conftest/functions.h:13:2: error: #error kmem_cache_create() conftest failed!

 #error kmem_cache_create() conftest failed!

  ^

/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/conftest/functions.h:14:2: error: #error on_each_cpu() conftest failed!

 #error on_each_cpu() conftest failed!

  ^

/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/conftest/functions.h:15:2: error: #error smp_call_function() conftest failed!

 #error smp_call_function() conftest failed!

  ^

/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/conftest/functions.h:20:2: error: #error acpi_walk_namespace() conftest failed!

 #error acpi_walk_namespace() conftest failed!

  ^

/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/conftest/functions.h:22:2: error: #error pci_dma_mapping_error() conftest failed!

 #error pci_dma_mapping_error() conftest failed!

  ^

In file included from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/common/inc/conftest.h:7:0,

                 from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/common/inc/nv-linux.h:15,

                 from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/nvidia/nv-frontend.c:13:

/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/conftest/macros.h:1:2: error: #error INIT_WORK() conftest failed!

 #error INIT_WORK() conftest failed!

  ^

In file included from /usr/src/linux-4.9.6-gentoo-r1/include/linux/mmzone.h:18:0,

                 from /usr/src/linux-4.9.6-gentoo-r1/include/linux/gfp.h:5,

                 from /usr/src/linux-4.9.6-gentoo-r1/include/linux/mm.h:9,

                 from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/common/inc/nv-pgprot.h:17,

                 from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/common/inc/nv-linux.h:17,

                 from /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/nvidia/nv-frontend.c:13:

/usr/src/linux-4.9.6-gentoo-r1/include/linux/page-flags-layout.h:5:30: fatal error: generated/bounds.h: No such file or directory

 #include <generated/bounds.h>

                              ^

compilation terminated.

make[3]: *** [/usr/src/linux-4.9.6-gentoo-r1/scripts/Makefile.build:294: /tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel/nvidia/nv-frontend.o] Error 1

make[2]: *** [/usr/src/linux-4.9.6-gentoo-r1/Makefile:1490: _module_/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel] Error 2

make[2]: Leaving directory '/usr/src/linux-4.9.6-gentoo-r1'

make[1]: *** [Makefile:150: sub-make] Error 2

make[1]: Leaving directory '/usr/src/linux-4.9.6-gentoo-r1'

make: *** [Makefile:81: modules] Error 2

 * ERROR: x11-drivers/nvidia-drivers-367.57-r1::gentoo failed (compile phase):

 *   emake failed

 * 

 * If you need support, post the output of `emerge --info '=x11-drivers/nvidia-drivers-367.57-r1::gentoo'`,

 * the complete build log and the output of `emerge -pqv '=x11-drivers/nvidia-drivers-367.57-r1::gentoo'`.

 * The complete build log is located at '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/temp/build.log'.

 * The ebuild environment file is located at '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/temp/environment'.

 * Working directory: '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel'

 * S: '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/'

>>> Failed to emerge x11-drivers/nvidia-drivers-367.57-r1, Log file:

>>>  '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/temp/build.log'

 * Messages for package x11-drivers/nvidia-drivers-367.57-r1:

 * Gentoo supports kernels which are supported by NVIDIA

 * which are limited to the following kernels:

 * <sys-kernel/gentoo-sources-4.9

 * <sys-kernel/vanilla-sources-4.9

 * 

 * You are free to utilize epatch_user to provide whatever

 * support you feel is appropriate, but will not receive

 * support as a result of those changes.

 * 

 * Do not file a bug report about this.

 * 

 * Messages for package x11-drivers/nvidia-drivers-367.57-r1:

 * ERROR: x11-drivers/nvidia-drivers-367.57-r1::gentoo failed (compile phase):

 *   emake failed

 * 

 * If you need support, post the output of `emerge --info '=x11-drivers/nvidia-drivers-367.57-r1::gentoo'`,

 * the complete build log and the output of `emerge -pqv '=x11-drivers/nvidia-drivers-367.57-r1::gentoo'`.

 * The complete build log is located at '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/temp/build.log'.

 * The ebuild environment file is located at '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/temp/environment'.

 * Working directory: '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/kernel'

 * S: '/tmp/portage/x11-drivers/nvidia-drivers-367.57-r1/work/'

```

Any ideas?

----------

## marax_faraii

```
make[2]: Entering directory '/usr/src/linux-4.9.6-gentoo-r1' 

test -e include/generated/autoconf.h -a -e include/config/auto.conf || (                \ 

echo >&2;                                                       \ 

echo >&2 "  ERROR: Kernel configuration is invalid.";           \ 

echo >&2 "         include/generated/autoconf.h or include/config/auto.conf are missing.";\ 

echo >&2 "         Run 'make oldconfig && make prepare' on kernel src to fix it.[";      \ 

echo >&2 ;                                                      \ 

/bin/false) 
```

 *Quote:*   

> Run 'make oldconfig && make prepare' on kernel src to fix it.

 

----------

## tryn

Troopo 

This info is from the e-build for nvidia-drivers-367.57-r1.

```
ewarn "<sys-kernel/gentoo-sources-4.9"
```

 This means that you have to build nvidia-drivers  that are  a higher number for the kernel that you have built.

Because the one that you are trying to use will not work with 4.9.6-gentoo-r1

----------

