Kernel build fails while compiling nvram.c due to an unused variable.
nvram.c:56:21: error: 'nvram_mutex' defined but not used [-Werror=unused-variable]
Build should complete successfully.
Build fails due to -Werror treating warning as error.
[console-expect]#make -j 81 -s && make modules_install && make install
make -j 81 -s && make modules_install && make install
In file included from ^[[01m^[[K./include/linux/seqlock.h:20^[[m^[[K,
from ^[[01m^[[K./include/linux/mmzone.h:17^[[m^[[K,
from ^[[01m^[[K./include/linux/gfp.h:7^[[m^[[K,
from ^[[01m^[[K./include/linux/umh.h:4^[[m^[[K,
from ^[[01m^[[K./include/linux/kmod.h:9^[[m^[[K,
from ^[[01m^[[K./include/linux/module.h:18^[[m^[[K,
from ^[[01m^[[Kdrivers/char/nvram.c:34^[[m^[[K:
^[[01m^[[Kdrivers/char/nvram.c:56:21:^[[m^[[K ^[[01;31m^[[Kerror: ^[[m^[[K'^[[01m^[[Knvram_mutex^[[m^[[K' defined but not used [^[[01;31m^[[K^[]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-variable^G-Werror=unused-variable^[]8;;^G^[[m^[[K]
56 | static DEFINE_MUTEX(^[[01;31m^[[Knvram_mutex^[[m^[[K);
| ^[[01;31m^[[K^~~~~~~~~~~^[[m^[[K
^[[01m^[[K./include/linux/mutex.h:87:22:^[[m^[[K ^[[01;36m^[[Knote: ^[[m^[[Kin definition of macro '^[[01m^[[KDEFINE_MUTEX^[[m^[[K'
87 | struct mutex ^[[01;36m^[[Kmutexname^[[m^[[K = __MUTEX_INITIALIZER(mutexname)
| ^[[01;36m^[[K^~~~~~~~~^[[m^[[K
cc1: all warnings being treated as errors
make[4]: *** [scripts/Makefile.build:289: drivers/char/nvram.o] Error 1
make[4]: *** Waiting for unfinished jobs....
make[3]: *** [scripts/Makefile.build:548: drivers/char] Error 2
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [scripts/Makefile.build:548: drivers] Error 2
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [/home/linux_src/linux/Makefile:2141: .] Error 2
make: *** [Makefile:248: __sub-make] Error 2
[console-expect]#echo $?
echo $?
2
ERROR
======================================================================
ERROR: runTest (testcases.InstallUpstreamKernel.InstallUpstreamKernel)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/var/lib/jenkins/workspace/LTC/op-test/testcases/InstallUpstreamKernel.py", line 130, in runTest
con.run_command("make -j %d -s && make modules_install && make install" %
File "/var/lib/jenkins/workspace/LTC/op-test/common/OpTestSSH.py", line 225, in run_command
return self.util.run_command(self, command, timeout, retry)
File "/var/lib/jenkins/workspace/LTC/op-test/common/OpTestUtil.py", line 1820, in run_command
raise cf
File "/var/lib/jenkins/workspace/LTC/op-test/common/OpTestUtil.py", line 1815, in run_command
output = self.try_command(term_obj, command, timeout)
File "/var/lib/jenkins/workspace/LTC/op-test/common/OpTestUtil.py", line 1890, in try_command
raise CommandFailed(command, res, echo_rc)
common.Exceptions.CommandFailed: Command 'make -j 81 -s && make modules_install && make install' exited with '2'.
Output
['In file included from \x1b[01m\x1b[K./include/linux/seqlock.h:20\x1b[m\x1b[K,', ' from \x1b[01m\x1b[K./include/linux/mmzone.h:17\x1b[m\x1b[K,', ' from \x1b[01m\x1b[K./include/linux/gfp.h:7\x1b[m\x1b[K,', ' from \x1b[01m\x1b[K./include/linux/umh.h:4\x1b[m\x1b[K,', ' from \x1b[01m\x1b[K./include/linux/kmod.h:9\x1b[m\x1b[K,', ' from \x1b[01m\x1b[K./include/linux/module.h:18\x1b[m\x1b[K,', ' from \x1b[01m\x1b[Kdrivers/char/nvram.c:34\x1b[m\x1b[K:', "\x1b[01m\x1b[Kdrivers/char/nvram.c:56:21:\x1b[m\x1b[K \x1b[01;31m\x1b[Kerror: \x1b[m\x1b[K'\x1b[01m\x1b[Knvram_mutex\x1b[m\x1b[K' defined but not used [\x1b[01;31m\x1b[K\x1b]8;;https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wunused-variable\x07-Werror=unused-variable\x1b]8;;\x07\x1b[m\x1b[K]", ' 56 | static DEFINE_MUTEX(\x1b[01;31m\x1b[Knvram_mutex\x1b[m\x1b[K);', ' | \x1b[01;31m\x1b[K^~~~~~~~~~~\x1b[m\x1b[K', "\x1b[01m\x1b[K./include/linux/mutex.h:87:22:\x1b[m\x1b[K \x1b[01;36m\x1b[Knote: \x1b[m\x1b[Kin definition of macro '\x1b[01m\x1b[KDEFINE_MUTEX\x1b[m\x1b[K'", ' 87 | struct mutex \x1b[01;36m\x1b[Kmutexname\x1b[m\x1b[K = __MUTEX_INITIALIZER(mutexname)', ' | \x1b[01;36m\x1b[K^~~~~~~~~\x1b[m\x1b[K', 'cc1: all warnings being treated as errors', 'make[4]: *** [scripts/Makefile.build:289: drivers/char/nvram.o] Error 1', 'make[4]: *** Waiting for unfinished jobs....', 'make[3]: *** [scripts/Makefile.build:548: drivers/char] Error 2', 'make[3]: *** Waiting for unfinished jobs....', 'make[2]: *** [scripts/Makefile.build:548: drivers] Error 2', 'make[2]: *** Waiting for unfinished jobs....', 'make[1]: *** [/home/linux_src/linux/Makefile:2141: .] Error 2', 'make: *** [Makefile:248: __sub-make] Error 2']
----------------------------------------------------------------------
Ran 1 test in 606.075s
FAILED (errors=1)
Description
Kernel build fails while compiling nvram.c due to an unused variable.
Error
nvram.c:56:21: error: 'nvram_mutex' defined but not used [-Werror=unused-variable]
Steps to Reproduce
make -j81 -s
Expected Behavior
Build should complete successfully.
Actual Behavior
Build fails due to -Werror treating warning as error.
Is it a known issue ?