Kernel doesn't support PIC mode for compiling?

The issue is with your gcc installation, in gcc 6+ versions PIE( position independent executables) is enabled by default. So in order to compile you need to disable it. Even gcc 5 has the issue. This is a known bug for gcc. Bug Link.

So far there is no official patch from gcc side, so the workaround is to patch the Makefile of kernel source.

If you are familiar with patching the source file use the codes from this link to create the patch file then try to compile.Patch File

Let me know if you are having difficulties installing the patch.


Open the Makefile, look for CFLAGS_EXTRA and add the following option to it -fno-pie

I had the line:

EXTRA_CFLAGS += $(CFLAGS_EXTRA)

I changed it for:

EXTRA_CFLAGS += $(CFLAGS_EXTRA) -fno-pie

For building kernel 4, above flag is: KBUILD_CFLAGS.

And it started compiling again.