For reasons, I need to compile the Linux kernel (currently 4.7.10) passing some simple and innocent additional command line options (e.g. -pipe -Wsomething
etc) to the C compiler.
How do I do it?
More specifically, how do I enforce these compiler flags during plain make
as well as during make menuconfig
and similar, i.e. so that they are always passed to the C compiler whenever the latter is executed.
From Linux kernel's makefile:
# Add any arch overrides and user supplied CPPFLAGS, AFLAGS and CFLAGS as the
# last assignments
KBUILD_CPPFLAGS += $(ARCH_CPPFLAGS) $(KCPPFLAGS)
KBUILD_AFLAGS += $(ARCH_AFLAGS) $(KAFLAGS)
KBUILD_CFLAGS += $(ARCH_CFLAGS) $(KCFLAGS)
So, passing additional options for Kbuild uses usual environment/makefile variables but with K
prefix:
make "KCFLAGS=-pipe -Wsomething"