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

  • Make all warnings into hard errors. Source code which triggers warnings will be rejected.
  • Inhibit all warning messages.
  • Make all warnings into errors.
  • 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 += -w
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.

Solution:
Edit drivers/net/wireless/bcm4329_204/Makefile

Locate -Werror within DHDCFLAGS, and delete it.

This will prevent gcc from treating mere warnings as errors.

-