Solving Kernel compilation errors part #1 New toolchain

Ok, solved that issue too after a lot of Google-ing and manually editing scripts…

For the sake of doku..

I had two different errors while compiling kernel:

1. warning: variable ‘type’ set but not used [-Wunused-but-set-variable]

My first thoughts were that there was a particular variable called -Wunused-but-set-variable that must be toggled.

So did a :

grep -R -i -n 'Wunused' *[/code]

which didnt yield anything

So did a lot of searching, even posted on StackOverflow (where btw, I have to say that the it's much more easier to post development questions )

This happened in almost every piece of code that compiled (or NOT)

scripts/kconfig/conf.c: In function ‘conf_sym’:
scripts/kconfig/conf.c:159:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
scripts/kconfig/conf.c: In function ‘conf_choice’:
scripts/kconfig/conf.c:231:6: warning: variable ‘type’ set but not used [-Wunused-but-set-variable]
scripts/kconfig/conf.c:307:9: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result]
scripts/kconfig/conf.c: In function ‘conf_askvalue’:
scripts/kconfig/conf.c:105:8: warning: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Wunused-result][/code]

I solved this by adding this line to Makefile before any If blocks were processed:

KBUILD_CFLAGS += -Wno-unused-but-set-variable

My main Makefile now looks like this:

# Force warning message as hard error

# arch Makefile may override CC so keep this after arch Makefile is included
NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)

KBUILD_CFLAGS += -Wno-unused-but-set-variable


The first If block ............... ifneq ($(KCPPFLAGS),)
$(call warn-assign,CPPFLAGS)
ifneq ($(KAFLAGS),)[/code]


  LD      arch/arm/vfp/built-in.o
CC [M] drivers/net/wireless/bcm4329_204/wl_iw.o
drivers/net/wireless/bcm4329_204/wl_iw.c: In function 'wl_iw_set_pmksa':
drivers/net/wireless/bcm4329_204/wl_iw.c:5612:5: error: array subscript is above array bounds [-Werror=array-bounds]
drivers/net/wireless/bcm4329_204/wl_iw.c:5615:5: error: array subscript is above array bounds [-Werror=array-bounds]
cc1: all warnings being treated as errors[/code]

Ok, for this one I found a lot of threads explaining how to do this with gcc. Being inexperience with Make, I didnt at first figure out how to instruct gcc invoked from Make to add a flag to prevent throwing a tantrum and converting warning to error.

Finally did this.
I found these blocks within Makefile:

# bcm4329
# bcm4329
-Wall -Wstrict-prototypes -Werror -DOOB_INTR_ONLY -DCUSTOMER_HW2
-Idrivers/net/wireless/bcm4329_204 -Idrivers/net/wireless/bcm4329_204/include

obj-$(CONFIG_BCM4329) += bcm4329.o
bcm4329-objs += $(DHDOFILES)
EXTRA_LDFLAGS += --strip-debug[/code]

To make matters worse, this flag was not in the main Makefile, but within subfolders. Fixed by removing -Werror

You can find out which Makefiles have this toggle by running:

grep -R -i -n 'Werror' *[/code]

You are reading this post on Joel G Mathew’s tech blog. Joel's personal blog is the Eyrie, hosted here.