# Cant compile nvidia-drivers

## pRivat1337

Hello,

Im having a wierd problem when trying to emerge nvidia-drivers:

here is a part of the build.log

```
 * Package:    x11-drivers/nvidia-drivers-367.35-r1

 * Repository: gentoo

 * Maintainer: jer@gentoo.org hardened@gentoo.org

 * USE:        X abi_x86_64 acpi amd64 driver elibc_glibc kernel_linux kms multilib tools userland_GNU

 * FEATURES:   preserve-libs sandbox userpriv usersandbox

 * Determining the location of the kernel source code

 * Found kernel source directory:

 *     /usr/src/linux

 * Found kernel object directory:

 *     /lib/modules/4.7.0-gentoo/build

 * Found sources for kernel version:

 *     4.7.0-gentoo

>>> Unpacking source...

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

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

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

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

 * Applying nvidia-drivers-367.35-profiles-rc.patch ...

 [ ok ]

>>> Source prepared.

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

>>> Source configured.

>>> Compiling source in /var/tmp/portage/x11-drivers/nvidia-drivers-367.35-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.7.0-gentoo/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.7.0-gentoo/build KBUILD_VERBOSE=1 -C /usr/src/linux M=/var/tmp/portage/x11-drivers/nvidia-drivers-367.35-r1/work/kernel ARCH=x86_64 NV_KERNEL_SOURCES=/usr/src/linux NV_KERNEL_OUTPUT=/lib/modules/4.7.0-gentoo/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.7.0-gentoo'

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

-f /usr/src/linux-4.7.0-gentoo/Makefile clean

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

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

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

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

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

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

make "CC=x86_64-pc-linux-gnu-gcc" KBUILD_OUTPUT=/lib/modules/4.7.0-gentoo/build KBUILD_VERBOSE=1 -C /usr/src/linux M=/var/tmp/portage/x11-drivers/nvidia-drivers-367.35-r1/work/kernel ARCH=x86_64 NV_KERNEL_SOURCES=/usr/src/linux NV_KERNEL_OUTPUT=/lib/modules/4.7.0-gentoo/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.7.0-gentoo'

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

-f /usr/src/linux-4.7.0-gentoo/Makefile modules

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

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 /var/tmp/portage/x11-drivers/nvidia-drivers-367.35-r1/work/kernel/.tmp_versions ; rm -f /var/tmp/portage/x11-drivers/nvidia-drivers-367.35-r1/work/kernel/.tmp_versions/*

make -f /usr/src/linux-4.7.0-gentoo/scripts/Makefile.build obj=/var/tmp/portage/x11-drivers/nvidia-drivers-367.35-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: hlist_for_each_entry

 CONFTEST: vzalloc

 CONFTEST: wait_on_bit_lock_argument_count

 CONFTEST: bitmap_clear

 CONFTEST: usleep_range

 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: 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

```

after that im recieving a huge amount of output which looks mostly like this: 

```
In file included from ./include/asm-generic/bug.h:4:0,

                 from /usr/src/linux-4.7.0-gentoo/arch/x86/include/asm/bug.h:35,

                 from ./include/linux/bug.h:4,

                 from ./include/linux/mmdebug.h:4,

                 from ./include/linux/mm.h:8,

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

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

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

./include/linux/list.h: In function ‘INIT_LIST_HEAD’:

./include/linux/list.h:27:2: error: dereferencing pointer to incomplete type

  WRITE_ONCE(list->next, list);

  ^

./include/linux/list.h:27:2: error: dereferencing pointer to incomplete type

  WRITE_ONCE(list->next, list);

  ^

./include/linux/list.h:27:2: error: dereferencing pointer to incomplete type

  WRITE_ONCE(list->next, list);

  ^

./include/linux/list.h:27:2: error: dereferencing pointer to incomplete type

  WRITE_ONCE(list->next, list);

  ^

In file included from ./include/linux/preempt.h:10:0,

                 from ./include/linux/spinlock.h:50,

                 from ./include/linux/mmzone.h:7,

                 from ./include/linux/gfp.h:5,

                 from ./include/linux/mm.h:9,

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

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

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

./include/linux/list.h:28:6: error: dereferencing pointer to incomplete type

  list->prev = list;

      ^

./include/linux/list.h: In function ‘__list_add’:

./include/linux/list.h:42:6: error: dereferencing pointer to incomplete type

  next->prev = new;

      ^

./include/linux/list.h:43:5: error: dereferencing pointer to incomplete type

  new->next = next;

     ^

./include/linux/list.h:44:5: error: dereferencing pointer to incomplete type

  new->prev = prev;

     ^

In file included from ./include/asm-generic/bug.h:4:0,

                 from /usr/src/linux-4.7.0-gentoo/arch/x86/include/asm/bug.h:35,

                 from ./include/linux/bug.h:4,

                 from ./include/linux/mmdebug.h:4,

                 from ./include/linux/mm.h:8,

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

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

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

./include/linux/list.h:45:2: error: dereferencing pointer to incomplete type

  WRITE_ONCE(prev->next, new);

  ^

./include/linux/list.h:45:2: error: dereferencing pointer to incomplete type

  WRITE_ONCE(prev->next, new);

  ^

./include/linux/list.h:45:2: error: dereferencing pointer to incomplete type

  WRITE_ONCE(prev->next, new);

  ^

./include/linux/list.h:45:2: error: dereferencing pointer to incomplete type

  WRITE_ONCE(prev->next, new);

  ^

```

but with different header files.

the end of the build log contain this:

```

In file included from /var/tmp/portage/x11-drivers/nvidia-drivers-367.35-r1/work/kernel/nvidia/nv-frontend.c:13:0:

/var/tmp/portage/x11-drivers/nvidia-drivers-367.35-r1/work/kernel/common/inc/nv-linux.h:139:75: fatal error: linux/ioctl32.h: No such file or directory

 #include <linux/ioctl32.h>          /* register_ioctl32_conversion()    */

                                                                           ^

cc1: some warnings being treated as errors

compilation terminated.

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

make[2]: *** [/usr/src/linux-4.7.0-gentoo/Makefile:1457: _module_/var/tmp/portage/x11-drivers/nvidia-drivers-367.35-r1/work/kernel] Error 2

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

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

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

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

```

I also tried emerging with other kernel versions but the problem still occours.

Thanks for helping

----------

## Hu

That looks to me like an error caused by using a version of the nVidia drivers that is not compatible with your active kernel sources.  This is a somewhat common problem with complicated out-of-tree modules, which is why the kernel developers push to have such modules brought in-tree.  Unfortunately, this is predicated on nVidia doing the right thing.  Given that they have had more than a decade in which to do it and have not done so, I doubt they ever will.  :Smile:   Do you need the closed nVidia drivers for your use case?

When you say you tried with other kernel versions, did you make the other kernel version active, such that the error message referenced some directory other than /usr/src/linux-4.7.0-gentoo?

----------

## Chiitoo

I'd expect something like

```
/var/tmp/portage/x11-drivers/nvidia-drivers-367.35-r1/work/kernel/nvidia-uvm/uvm_linux.h:557:13: error: redefinition of ‘radix_tree_empty’
```

from an un-patched build with 4.7.0 sources, so this might be something else yet (I get that with 'uvm' enabled as well as disabled).

Regardless, see: fixing nvidia-drivers with kernel-4.7

If indeed that doesn't help, other things that might would be posting 'emerge --info' output, and perhaps the complete build log.

----------

## HackingM2

Did you ever find a solution to this problem?

I've tested with several different combinations of x11-drivers/nvidia-drivers and kernel versions without success.

----------

## fedeliallalinea

 *HackingM2 wrote:*   

> I've tested with several different combinations of x11-drivers/nvidia-drivers and kernel versions without success.

 

I've kernel 4.7.10 with nvidia 367.57-r1. With versions that have problems? And what is the error?

----------

## HackingM2

 *fedeliallalinea wrote:*   

> With versions that have problems? And what is the error?

 

All version combinations of gentoo-sources and nvidia-drivers have the same problem.  The error message is the same as above...

```
In file included from /var/tmp/portage/x11-drivers/nvidia-drivers-361.28/work/kernel/nvidia/nv-frontend.c:13:0:

/var/tmp/portage/x11-drivers/nvidia-drivers-361.28/work/kernel/common/inc/nv-linux.h:146:75: fatal error: linux/ioctl32.h: No such file or directory

 #include <linux/ioctl32.h>          /* register_ioctl32_conversion()    */

                                                                           ^

compilation terminated.
```

...although there hundreds of undefined type errors before that.

What I can't understand is why this is happening.  In nv-linux.h there is a conditional include...

```
#if defined(NVCPU_X86_64) && !defined(HAVE_COMPAT_IOCTL)

#include <linux/syscalls.h>         /* sys_ioctl()                      */

#include <linux/ioctl32.h>          /* register_ioctl32_conversion()    */

#endif
```

...and HAVE_COMPAT_IOCTL is defined in /usr/src/linux/include/linux/fs.h which should be included already in nv-linux.h which begs the question why is linux/ioctl32.h ever being included?

Just to add to the confusion if I go to /var/tmp/portage/x11-drivers/nvidia-drivers-361.28/work/kernel and run make by hand the build proceeds perfectly with no errors or warnings at all.

Whatever the issue is seems to be causing problems building other kernel modules (virtual box), and even DHCP so it is not just an nvidia-drivers problem.

Any ideas?

----------

## fedeliallalinea

 *HackingM2 wrote:*   

> Any ideas?

 

You can post all build.log with wgetpsate?

----------

## HackingM2

 *fedeliallalinea wrote:*   

> You can post all build.log with wgetpsate?

 

nvidia-drivers https://gist.github.com/1379ab63d9a517d92c9415fc3d3c172b

virtualbox-modules https://gist.github.com/1965db9d0adbbd23e402cbc93da33eb6

----------

## fedeliallalinea

You use kernel 4.4.6 at this moment? You have tried with last stable in portage (4.4.26)?

----------

## HackingM2

 *fedeliallalinea wrote:*   

> You use kernel 4.4.6 at this moment? You have tried with last stable in portage (4.4.26)?

 

I've tried nvidia-drivers versions 361.28, 364.15 and 375.10-r1 with gentoo-sources 3.10.7, 4.2.0, 4.4.6 and 4.4.26 in various combinations all with the exact same result.

Another weird thing I have noticed is that the nvidia-drivers ebuild still works on the target machines, just not the build-server. If a target machine is updated to use the new binary packages then the nvidia-drivers ebuild fails. As far as I can tell there are no changes to any key packages (kernel, kernel-headers, nvidia-drivers, automake, etc) so I am stumped as to what could be different.

I'm going to take a snapshot of the build-space and do an emerge --emptytree world to see if that changes anything. I'll let you know what happens.

----------

## HackingM2

 *HackingM2 wrote:*   

> I'm going to take a snapshot of the build-space and do an emerge --emptytree world to see if that changes anything. I'll let you know what happens.

 

Well, that's weird - still the same problem.

I am going to snapshot an existing workspace (where the nvidia-drivers ebuild still works) and copy over the world file and /etc/portage/package.* directories.  If that works I'll diff the nvidia build directory in both build-spaces and see what has changed.

I'll keep the thread updated.

----------

