Search code examples
linuxcompilationlinux-kernelcross-compilinggcc-warning

regarding CFLAGS setting in Linux kernel?


While compiling Linux kernel I got following error :

no previous prototype for 'foo' [-Werror=missing-prototypes]

Command used to compile kernel:

 make -C kernel ARCH=arm CROSS_COMPILE=arm-eabi- 

I tried following command but not working

make ARCH=arm CROSS_COMPILE=arm-eabi- CFLAGS=-Wno-error

So I want to know to how to set CFLAGS to -Wno-error in Linux kernel from directory make command.

I know its great to have -Werror set and fix problem instead but as of now I want to know how to set CFLAGS to -Wno-error.

Any help will be appreciated.


Solution

  • You can either use ccflags-module_name, or ccflags-y to set it globally:

    ccflags-foo.o := -Wno-error
    

    or

    ccflags-y := -Wno-error
    

    As an alternative, you can use KBUILD_CFLAGS environment variable.

    But I would fix your mistake instead of shutting up compiler.