While working with the Linux kernel, I encountered a situation where some kernel configuration options did not appear explicitly in the .config file. To investigate further, I manually tested a few flags by adding code that intentionally fails the build if those flags are enabled, but I found no evidence of any such flag being active without appearing in the .config.
Here are my questions:
- Is it possible for a Kconfig option to be implicitly enabled through dependencies or defaults but not explicitly listed in .config?
No, the .config will accurately list what's built into the kernel (if it has been generated properly, and not modified manually). KConfig will have resolved the dependencies from your defconfig.
Traditionally you will configure your kernel using a *_defconfig
file. This is a condensed representation of a .config
. It basically contains all non default configurations. When you run make <your>_defconfig
, it will select all the configurations listed, and use the default values for all other ones. You can then make manual configurations with make menuconfig
. When done, save back the defconfig using make savedefconfig
. defconfig
files are suited for versioning because they are lighter than .config
. Some external build frameworks also allow saving config fragments, but are not standard.
If you use a .config or defconfig that you are not sure is proper, you can regenerate a proper config, with all default values resolved using make menuconfig
and saving.
- How do select directives, auto-selection, or architecture-specific conditions affect the visibility of flags in .config?
There are several ways dependencies are declared between KConfig options. You can find the one relevant to your options in the KConfig
files:
depends on
: Cannot be enabled without the dependancyselects
: Automatically selects said dependencyimply
: Like select, but dependency can be overriden with =n
visible if
: Condition to display in the menudefault
: Value that will be selected if not defined
- Could certain features be conditionally compiled or enabled by default behavior, even if the associated flag does not appear in .config?
Like 1). The .config provides the resolved final values after dependencies have been handled. You can also check the runtime effective configuration if enabled (zcat /proc/config.gz
). However other mechanisms allow to add new configurations on a kernel at runtime. The most common one are modules. You can list loaded modules with lsmod
.