“make oldconfig”是什么意思? Linux内核makefile中到底做了什么?
谁能解释一下目标“oldconfig”在 Linux 内核 makefile 中到底做了什么?我在一些构建文档中看到它被引用,但从未解释过它到底是做什么的。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
它读取用于旧内核的现有
.config
文件,并提示用户输入当前内核源代码中未在该文件中找到的选项。当采用现有配置并将其移动到新内核时,这非常有用。It reads the existing
.config
file that was used for an old kernel 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.摘要
正如 Ignacio所述,它会更新您的
.config
更新内核源代码后,例如使用 git pull 。它试图保留您现有的选项。
为此编写一个脚本很有帮助,因为:
可能已添加新选项,或删除旧选项
内核的 Kconfig 配置格式具有以下选项:
选择
相互暗示depends
依赖另一个这些选项关系使手动配置解析变得更加困难。
让我们手动修改 .config 以了解它如何解析配置
首先使用以下命令生成默认配置:
现在手动编辑生成的
.config
文件以模拟内核更新并运行:以查看会发生什么。一些结论:
行类型:
并非单纯的注释,而是实际表明该参数未设置。
例如,如果我们删除该行:
并运行
make oldconfig
,它会询问我们:结束后,
.config
文件将被更新。如果您更改该行的任何字符,例如更改为
# CONFIG_DEBUG_INFO
,则不算。行类型:
总是用于属性的否定,尽管:
<前><代码>CONFIG_XXX=n
也可以理解为否定。
例如,如果您删除
# CONFIG_DEBUG_INFO is not set
并回答:使用
N
,则输出文件包含:而不是:
<前><代码>CONFIG_DEBUG_INFO=n
此外,如果我们手动将该行修改为:
<前><代码>CONFIG_DEBUG_INFO=n
并运行
make oldconfig
,然后该行被修改为:没有
oldconfig
询问我们。不满足依赖关系的配置不会出现在
.config
中。其他人都这样做。例如设置:
并运行
make oldconfig
。现在它会要求我们提供:DEBUG_INFO_REDUCED
、DEBUG_INFO_SPLIT
等配置。这些属性之前没有出现在
defconfig
中。如果我们在
lib/Kconfig.debug
下查看它们的定义位置,我们会发现它们依赖于DEBUG_INFO
:因此,当
DEBUG_INFO
关闭时,它们根本不会显示。通过打开的配置
选择
的配置会自动设置,无需询问用户。例如,如果
CONFIG_X86=y
并且我们删除该行:并运行
make oldconfig
,该行会在不询问我们的情况下重新创建,这与DEBUG_INFO
不同。发生这种情况是因为
arch/x86/Kconfig
包含:<前><代码>配置X86
def_bool y
[...]
选择 ARCH_MIGHT_HAVE_PC_PARPORT
并选择强制该选项为真。另请参阅:https://unix.stackexchange.com/questions/117521/select -vs-depends-in-kernel-kconfig
要求不满足约束的配置。
例如,
defconfig
已设置:<前><代码>CONFIG_64BIT=y
CONFIG_RCU_FANOUT=64
如果我们编辑:
<前><代码>CONFIG_64BIT=n
并运行
make oldconfig
,它会询问我们:这是因为
RCU_FANOUT
在init/Kconfig
中定义为:因此,如果没有
64BIT
,最大值为32
,但我们在.config
上设置了64
>,这会使其不一致。奖励
make olddefconfig
将每个选项设置为默认值,无需交互询问。它会在make
上自动运行,以确保.config
保持一致,以防您像我们一样手动修改它。另请参阅:https://serverfault.com /questions/116299/automatically-answer-defaults-when-doing-make-oldconfig-on-a-kernel-treemake alldefconfig
就像make olddefconfig
,但它也接受要合并的配置片段。此目标由merge_config.sh
脚本使用:https://stackoverflow.com/a/39440863/ 895245如果你想自动修改
.config
,那就不太简单了:如何以非交互方式打开 Linux 内核 .config 文件中的功能?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?在运行
make oldconfig
之前,您需要将旧内核中的内核配置文件复制到新内核的根目录中。您可以在正在运行的系统上的
/boot/config-3.11.0
中找到旧内核配置文件的副本。或者,如果您的内核源代码位于
/usr/src/linux
,内核 源代码的配置位于linux-3.11.0/arch/x86/configs/{i386_defconfig / x86_64_defconfig}
代码>:Before you run
make oldconfig
, you need to copy a 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.
从这个页面:
From this page:
这是一种折磨。它们不包含通用的conf 文件,而是让您按回车键9000 次才能生成一个文件。
It's torture. Instead of including a generic conf file, they make you hit return 9000 times to generate one.