# [SOLVED] Error compiling external modules on 4.9.5/4.9.6-r1

## assaf

I'm currently running gentoo-sources-4.4.26 mostly stable and was trying to upgrade to 4.9.5 (and then 4.9.6-r1)

All external modules i try to recompile fail with the newer kernels, usually complaining about "no rule to make target" on one of the object files.

Am i missing something that needs to be keyworded or something messed up with my machine? Or did something change with the kernel's makefiles?

For example:

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

make[1]: *** No rule to make target '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/fthd_hw.o', needed by '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/facetimehd.o'.  Stop.

make: *** [Makefile:1490: _module_/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999] Error 2

make: Leaving directory '/usr/src/linux-4.9.6-gentoo-r1'
```

Last edited by assaf on Thu Feb 02, 2017 8:25 pm; edited 1 time in total

----------

## audiodef

Is this manual config or genkernel? If manual, did you cp an old .config? Did you make oldconfig, make defconfig, make clean, or whatever is appropriate for your needs?

----------

## assaf

I'm using genkernel to build but with my own customized .config which I copied from the previous kernel, and ran make oldconfig (like I always do).

Running make with -d there's seems to be a difference when running against the old and new kernels:

With the old kernel:

```
 Trying implicit prerequisite '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/fthd_hw.c'.

 Trying rule prerequisite 'FORCE'.

 Found an implicit rule for '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/fthd_hw.o'.

  Considering target file '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/fthd_hw.c'.
```

With the new:

```
 Trying implicit prerequisite '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/fthd_hw.c'.

 Trying rule prerequisite 'tools/objtool/objtool'.

 Trying pattern rule with stem 'fthd_hw'.

 Trying implicit prerequisite '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/fthd_hw.S'.

 Trying pattern rule with stem 'fthd_hw.o'.

 Trying implicit prerequisite '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/fthd_hw.o_shipped'.

 Trying pattern rule with stem 'fthd_hw'.

 Trying implicit prerequisite '/tmp/portage/media-video/bcwc_pcie-9999/work/bcwc_pcie-9999/fthd_hw.c'.

 Trying rule prerequisite 'tools/objtool/objtool'.
```

----------

## eccerr0r

These are all external DKMS so they may not line up with latest...

Try installing a 4.8 kernel as an experiment.  A quick look at a webpage seems to indicate it just got a commit for 4.8 kernels...

----------

## assaf

I did try with 4.8 and also with vanilla-sources, same issue.

This is just an example - I'm getting similar errors with other modules as well.

The error seems to be Makefile related (or maybe there's a hidden error message somewhere?).

It seems pretty basic: you have an .o file, you need to build the .c file, but it doesn't even try to.

Maybe something changed in kbuild after 4.4?

----------

## eccerr0r

Are these from an overlay?  Is there one from the default repository that doesn't work?

Despite a 9999 I can't be sure that the latest git was actually pulled or not..

----------

## assaf

I've compared the git commit number and it's the latest one (in the mainline branch).

Another example - vmware-modules:

```
>>> Compiling source in /tmp/portage/app-emulation/vmware-modules-308.1.0/work ...

 * Preparing vmblock module

make -j9 -l8 HOSTCC=x86_64-pc-linux-gnu-gcc CROSS_COMPILE=x86_64-pc-linux-gnu- 'LDFLAGS=-m elf_x86_64' auto-build KERNEL_DIR=/usr/src/linux KBUILD_OUTPUT=/lib/modules/4.9.6-gentoo-r1/build 

Using kernel build system.

make -C /lib/modules/4.9.6-gentoo-r1/build SUBDIRS=$PWD SRCROOT=$PWD/. \

  MODULEBUILDDIR= modules

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

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

make[3]: *** No rule to make target '/tmp/portage/app-emulation/vmware-modules-308.1.0/work/vmblock-only/linux/filesystem.o', needed by '/tmp/portage/app-emulation/vmware-modules-308.1.0/work/vmblock-only/vmblock.o'.  Stop.

make[2]: *** [/usr/src/linux-4.9.6-gentoo-r1/Makefile:1490: _module_/tmp/portage/app-emulation/vmware-modules-308.1.0/work/vmblock-only] Error 2

```

I think if I write a hello world kernel module I will get the same error.

----------

## assaf

Looks like the problem is with the kernel .config. I tried make defconfig on a clean vanilla-sources-4.9.6 and the compilation passes.

Looking for the offending config option now...

----------

## eccerr0r

A lot of these external modules do not build properly if you didn't actually cleanly build the kernel (at least the setup region after .config was changed) before building the module.

I'm surprised that there are so many modules that failed build, would imply more than just a config option and some systemic error like the clean build.

----------

## Roman_Gruber

Just my opinion:

 *Quote:*   

> I'm using genkernel to build but with my own customized .config 

 

Leave out genkernel and do it properly by hand. Just the good old compile by hand and file manipulation by hand. Those scripts are buggy by hell, add a layer of possible errors, make things complicated

----------

## assaf

Found it! I enabled stack validations, but didn't notice this error message:

```
Cannot use CONFIG_STACK_VALIDATION, please install libelf-dev, libelf-devel or elfutils-libelf-devel
```

Installed elfutils, and now it works!

----------

## audiodef

There's often a little trip-up somewhere. Until recent versions, I had to always disable building documentation in tree when invoking --menuconfig. Now it seems to have been removed, thank goodness.

----------

