• Home
  • Kernel
  • Solving Kernel compilation errors part #1 New toolchain

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 :

Code:
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)

Code:
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:

Code:
# Force warning message as hard error
ifdef CONFIG_FORCE_WARNING_AS_ERROR
#KBUILD_CFLAGS += -Werror
endif

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

#Droidzone
KBUILD_CFLAGS += -Wno-unused-but-set-variable
#-Werror=array-bounds

.............

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

2.

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:

Code:
# bcm4329
# bcm4329
DHDCFLAGS = -DLINUX -DBCMDRIVER -DBCMDONGLEHOST -DDHDTHREAD -DBCMWPA2
-DUNRELEASEDCHIP -Dlinux -DDHD_SDALIGN=64 -DMAX_HDR_READ=64
-DDHD_FIRSTREAD=64 -DDHD_GPL -DDHD_SCHED -DBDC -DTOE -DDHD_BCMEVENTS
-DSHOW_EVENTS -DBCMSDIO -DDHD_GPL -DBCMLXSDMMC -DBCMPLATFORM_BUS
-Wall -Wstrict-prototypes -Werror -DOOB_INTR_ONLY -DCUSTOMER_HW2
-DDHD_USE_STATIC_BUF -DMMC_SDIO_ABORT -DWLAN_PFN -DWLAN_PROTECT
-DBCMWAPI_WPI -DWLAN_LOW_RSSI_IND -DCSCAN -DSOFTAP_PROTECT
-DMMC_RECOVER -DBCM4329_LOW_POWER -DHTC_KlocWork
-Idrivers/net/wireless/bcm4329_204 -Idrivers/net/wireless/bcm4329_204/include

obj-$(CONFIG_BCM4329) += bcm4329.o
bcm4329-objs += $(DHDOFILES)
EXTRA_CFLAGS = $(DHDCFLAGS)
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:

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