Can anyone explain what the target "oldconfig" does exactly in the Linux kernel makefile? I see it referenced in some build documentation but never explained what it does exactly.
相关问题
- Is shmid returned by shmget() unique across proces
- how to get running process information in java?
- Kernel oops Oops: 80000005 on arm embedded system
- Error building gcc 4.8.3 from source: libstdc++.so
- Why should we check WIFEXITED after wait in order
From this page:
It reads the existing
.config
file and prompts the user for options in the current kernel source that are not found in the file. This is useful when taking an existing configuration and moving it to a new kernel.Before you run 'make oldconfig' You need to copy an kernel configuration file from an older kernel into the root directory of the new kernel.
You can find a copy of the old kernel configuration file on a running system at
/boot/config-3.11.0
. Alternatively, kernel source code has configs inlinux-3.11.0/arch/x86/configs/{i386_defconfig / x86_64_defconfig}
If your kernel source is located at /usr/src/linux
Updates an old config with new/changed/removed options.
Summary
As mentioned by Ignacio, it updates your
.config
for you after you update the kernel source, e.g. withgit pull
.It tries to keep your existing options.
Having a script for that is helpful because:
new options may have been added, or old ones removed
the kernel's Kconfig configuration format has options that:
select
depends
Those option relationships make manual config resolution even harder.
Let's modify .config manually to understand how it resolves configurations
First generate a default configuration with:
Now edit the generated
.config
file manually to emulate a kernel update and run:to see what happens. Some conclusions:
Lines of type:
are not mere comments, but actually indicate that the parameter is not set.
For example, if we remove the line:
and run
make oldconfig
, it will ask us:When it is over, the
.config
file will be updated.If you change any character of the line, e.g. to
# CONFIG_DEBUG_INFO
, it does not count.Lines of type:
are always used for the negation of a property, although:
is also understood as the negation.
For example, if you remove
# CONFIG_DEBUG_INFO is not set
and answer:with
N
, then the output file contains:and not:
Also, if we manually modify the line to:
and run
make oldconfig
, then the line gets modified to:without
oldconfig
asking us.Configs whose dependencies are not met, do not appear on the
.config
. All others do.For example, set:
and run
make oldconfig
. It will now ask us for:DEBUG_INFO_REDUCED
,DEBUG_INFO_SPLIT
, etc. configs.Those properties did not appear on the
defconfig
before.If we look under
lib/Kconfig.debug
where they are defined, we see that they depend onDEBUG_INFO
:So when
DEBUG_INFO
was off, they did not show up at all.Configs which are
selected
by turned on configs are automatically set without asking the user.For example, if
CONFIG_X86=y
and we remove the line:and run
make oldconfig
, the line gets recreated without asking us, unlikeDEBUG_INFO
.This happens because
arch/x86/Kconfig
contains:and select forces that option to be true. See also: https://unix.stackexchange.com/questions/117521/select-vs-depends-in-kernel-kconfig
Configs whose constraints are not met are asked for.
For example,
defconfig
had set:If we edit:
and run
make oldconfig
, it will ask us:This is because
RCU_FANOUT
is defined atinit/Kconfig
as:Therefore, without
64BIT
, the maximum value is32
, but we had64
set on the.config
, which would make it inconsistent.Bonuses
make olddefconfig
sets every option to their default value without asking interactively. It gets run automatically onmake
to ensure that the.config
is consistent in case you've modified it manually like we did. See also: https://serverfault.com/questions/116299/automatically-answer-defaults-when-doing-make-oldconfig-on-a-kernel-treemake alldefconfig
is likemake olddefconfig
, but it also accepts a config fragment to merge. This target is used by themerge_config.sh
script: https://stackoverflow.com/a/39440863/895245And if you want to automate the
.config
modification, that is not too simple: How do you non-interactively turn on features in a Linux kernel .config file?It's torture. Instead of including a generic conf file, they make you hit return 9000 times to generate one.