I'm trying to build a kernel with gcc6 for Nextbit Robin and I'm getting tons of Werrors, mostly with messages about bad indentation.
Here's an example below:
drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c:4768:4: error: this 'for' clause does not guard... [-Werror=misleading-indentation] for (ptr = str; i_isspace(*ptr); ptr++); ^~~
I'm new to compiling kernels, so maybe I'm doing something wrong?
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items ...
Show closed items
Linked items 0
Link issues together to show that they're related.
Learn more.
In the prepare() of the linux- APKBUILD that has been generated should be the following:
# Remove -Werror from all makefilesfind .-type f -name Makefile -print0 | \ xargs -0sed-i's/-Werror-/-W/g'find .-type f -name Makefile -print0 | \ xargs -0sed-i's/-Werror//g'
This changes -Werror-* to -W* and removes the -Werror flag completely for all Makefiles. If you have this, then for some reason it does not work with the kernel sources you have (they probably have specified the -Werror flag in another way which we don't catch).
To debug this, you could run the build once and let it fail, then enter the chroot and find the remaining Werror statement:
Sorry, I meant: grep -r Werror .
Making patches for the Werrors also kind of works, but usually there are many of them, and it's just much easier to disable all of them. (In my opinion it's not worth putting much energy in the kernel forks beyond of making them compile and work once, because they won't get updates from upstream anyway.)
This is due to assumptions about the register assignments made by gcc on
function entry. The errors above occur when these assignments are not
as expected. It turns out that when you enable mcount preables (-pg)
these are altered and the compilation failed.
Thank you so much. I had a spare hour and tried to compile with this patch applied but I'm once again getting Werrors. This time it looks like this:
drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c: In function 'i_trim':drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c:4768:4: error: this 'for' clause does not guard... [-Werror=misleading-indentation] for (ptr = str; i_isspace(*ptr); ptr++); ^~~drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c:4769:7: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for' if (*ptr == '\0') ^~drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c:4777:4: error: this 'for' clause does not guard... [-Werror=misleading-indentation] for (; ptr != str && i_isspace(*ptr); ptr--); ^~~drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c:4779:7: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'for' ptr[1] = '\0'; ^~~drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c: In function 'hdd_update_config_dat':drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c:6641:5: error: this 'if' clause does not guard... [-Werror=misleading-indentation] if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_MCAST_BCAST_FILTER_SETTING, pConfig->mcastBcastFilterSetting, ^~drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.c:6652:6: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if' if (ccmCfgSetInt(pHddCtx->hHal, WNI_CFG_TELE_BCN_WAKEUP_EN, pConfig->teleBcnWakeupEn, ^~cc1: all warnings being treated as errorsmake[3]: *** [scripts/Makefile.build:309: drivers/staging/qcacld-2.0/CORE/HDD/src/wlan_hdd_cfg.o] Error 1make[2]: *** [scripts/Makefile.build:455: drivers/staging/qcacld-2.0] Error 2make[1]: *** [scripts/Makefile.build:455: drivers/staging] Error 2make: *** [Makefile:827: drivers] Error 2>>> ERROR: linux-nextbit-robin: all failed(012155) [20:24:01] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Maybe you can teach me identifying where those -Werrors are so the next time this happens I would be able to do it myself?
In general, you can run grep on the extracted kernel source to find out which files have the Werror statements:
grep-r Werror .
However, it would be more effective to automatically replace it in all Kbuild files (just like we replace it already in all Makefiles). In fact I did that with your kernel, and it compiled fine.
Just modify the prepare() function in your APKBUILD as shown here:
https://github.com/postmarketOS/pmbootstrap/pull/1139/files
(When this PR gets reviewed and merged, this will be the new default.)
Thanks! Closing this issue now, it seems like everything is resolved now.
If you have other problems/feature ideas etc, don't hesitate to open new issues.