Compile script fails with gcc6 compiler (Debian testing)

Since the new gcc6 version (6.2.0) the compile script fails with the following message:

/var/lib/dkms/nvidia/367.44/build/nvidia/nv-frontend.c:1:0: error: code
model <b>kernel does not support PIC mode</b>

I have also tried the lastest driver (367.57), two different kernels (4.7 and 4.8) and with and w/o DKMS support, same error. I could solve the problem by adding these lines to the /usr/src/linux-headers-4.x.x.x-common/Makefile file.

KBUILD_CFLAGS += $(call cc-option, -fno-pie)
KBUILD_CFLAGS += $(call cc-option, -no-pie)
KBUILD_AFLAGS += $(call cc-option, -fno-pie)
KBUILD_CPPFLAGS += $(call cc-option, -fno-pie)


Is there a way to change the script instead of the system wide makefile?


I encounter the same problem in similar environment:
Debian testing
kernel – 4.7.0-1 and above
gcc – 6.2.0-13
nvidia version – Linux-x86_64-367.57

After adding the options suggested by ripat, the module compiles, but on loading it says: Unknown symbol mcount (err 0).

Any help would be welcome.

“-fno-pie” can be passed by using environment variables as follows;

export KCPPFLAGS="-fno-pie"
sh ./

FYI, this is a known issue and already fixed in linux-4.8.11.