• Home
  • Tag: Refer Preprocessor

Kernel compilation flags – A pain in the a*

So I pulled snq’s froyo kernel (that guy is a marvel)..

Some kernel compilation errors:

    1. Treat warnings as errors-Solved by removing the string “-Werror” from all Makefiles of the file which failed to compile. Some people had said that the real error (Array out of bounds warning) was because of gcc optimizations. But putting -O2 to -O0 didnt do a thing. This can also be done from menuconfig: System type>Force warnings as errors
    2. No of jobs – ought not to exceed 50.
    3. “warning: variable set but not used [-Wunused-but-set-variable]”-Look at KBUILD_CFLAGS in the main Makefile. Add -Wno-unused-but-set-variable to the existing set of flags. You can alternately add a line that says

Note the following from gcc manual:

Refer Preprocessor options

  • -Werror[/code]Make all warnings into hard errors. Source code which triggers warnings will be rejected.
  • -w[/code]Inhibit all warning messages.
  • -Werror[/code]Make all warnings into errors.
  • -Werror=[/code]Make the specified warning into an error. The specifier for a warning is appended, for example -Werror=switch turns the warnings controlled by -Wswitch into errors. This switch takes a negative form, to be used to negate -Werror for specific warnings, for example -Wno-error=switch makes -Wswitch warnings not be errors, even when -Werror is in effect. You can use the -fdiagnostics-show-option option to have each controllable warning amended with the option which controls it, to determine what to use with this option.
So what I did to suppress errors was to add:
KBUILD_CFLAGS += -Wno-error=unused-but-set-variable


Though the -Wunused-but-set-variable is not a real issue in itself, it generates so much "noise" that you may miss actual make errors.

This is what I was talking about in No 1.

drivers/net/wireless/bcm4329_204/wl_iw.c: In function 'wl_iw_set_pmksa':
drivers/net/wireless/bcm4329_204/wl_iw.c:5075:5: error: array subscript is above array bounds [-Werror=array-bounds]
drivers/net/wireless/bcm4329_204/wl_iw.c:5078:5: error: array subscript is above array bounds [-Werror=array-bounds]

Edit drivers/net/wireless/bcm4329_204/Makefile

Locate -Werror within DHDCFLAGS, and delete it.

-Wall -Wstrict-prototypes -Werror -DOOB_INTR_ONLY -DCUSTOMER_HW2

This will prevent gcc from treating mere warnings as errors.