在18.04.1-Ubuntu下的VirtualBox中构建最新的Linux内核时出现错误。

4
我正在尝试使用Oracel虚拟机和18.04.1-Ubuntu镜像构建最新的Linux内核(GitHub)。
我已经安装了所需的软件包,可能还安装了更多。这是我安装的软件包的一部分:
sudo apt-get update
sudo apt-get install git fakeroot build-essential ncurses-dev xz-utils libssl-dev bc bison flex libelf-def kernel-package

完整列表可以在这里找到。
我从GitHub克隆存储库后,在linux文件夹中运行了以下命令。
$ cp /boot/config-$(uname -r) .config

$ make menuconfig
scripts/kconfig/mconf  Kconfig
.config:1118:warning: symbol value 'm' invalid for NF_CT_PROTO_GRE
.config:1923:warning: symbol value 'm' invalid for NET_DEVLINK
.config:7865:warning: symbol value 'm' invalid for ASHMEM
.config:8724:warning: symbol value 'm' invalid for ANDROID_BINDER_IPC
.config:8725:warning: symbol value 'm' invalid for ANDROID_BINDERFS


*** End of the configuration.
*** Execute 'make' to start the build or try 'make help'.

我保存并退出了menuconfig。最终运行make出现了以下错误。

$ make -j2
Makefile:608: include/config/auto.conf: No such file or directory
Makefile:660: include/config/auto.conf.cmd: No such file or directory
  HOSTCC  scripts/kconfig/conf.o
  HOSTLD  scripts/kconfig/conf
scripts/kconfig/conf  --syncconfig Kconfig

*** Error during sync of the configuration.

scripts/kconfig/Makefile:73: recipe for target 'syncconfig' failed
make[2]: *** [syncconfig] Error 1
Makefile:562: recipe for target 'syncconfig' failed
make[1]: *** [syncconfig] Error 2
Makefile:678: recipe for target 'include/config/auto.conf.cmd' failed
make: *** [include/config/auto.conf.cmd] Error 2
make: *** Deleting file 'include/config/auto.conf.cmd'

看起来 make 需要一些额外的配置文件 include/config/auto.conf。有人能给我提示吗?
谢谢!

git clean -xdf; export ARCH=...; cp /boot/config-$(uname -r) .config; make olddefconfig; make -j2 - 0andriy
不行,无法工作 $ make olddefconfig Makefile:555: arch/.../Makefile: 没有那个文件或目录 make: *** 没有指定目标的规则。 停止。 - Nawin
当然。你必须应用你想要构建的架构,而不是使用“...”。 - 0andriy
所以我尝试使用export ARCH=x86_64描述的过程,但仍然导致`Makefile: 608:include / config / auto.conf:没有那个文件或目录scripts / kconfig / conf --syncconfig Kconfig***同步配置期间发生错误。 - Nawin
export ARCH=ia64也没有起作用,但我在执行make olddefconfig期间已经出现了错误。 - Nawin
$ make olddefconfig ./arch/ia64/scripts/check-segrel.S: Assembler messages: ./arch/ia64/scripts/check-segrel.S:2: Error: unknown pseudo-op: .rodata' ./arch/ia64/scripts/check-segrel.S:3: Error: no such instruction: data4 @segrel(start)' objdump: '/tmp/out8220': No such file objdump: section '.rodata' mentioned in a -j option, but not found in any input file ./arch/ia64/scripts/toolchain-flags: 20: [: !=: unexpected operator ./arch/ia64/scripts/check-text-align.S: Assembler messages: - Nawin
1个回答

4

尝试以非root用户身份编译kernel 5.6.3时,我遇到了这个确切的问题。运行Oandiy评论中的建议。

git clean -xdf

发现我的源代码中有一些文件是属于 root 用户,无法被删除。在查看版本历史记录时,我找到了以下的信息:

sudo make localmodconfig  # DO NOT DO THIS

问题出在某些文件被以root权限安装到了include/config/*include/generated/autoconf.h目录下。

如果想要确认是否存在相同的问题,请运行以下命令:

sudo find . -uid 0

或者只需查看git clean -xdf的错误消息(不应该有任何错误)。

在删除所有由root拥有的文件和目录后,我使用以下方法恢复了这个死锁:

unset ARCH
cp .config ../config.backup  # If you still have this.
git clean -xdf               # No errors (this also deletes .config)
cp ../config.backup .config  # Or generate a new one *).
make olddefconfig            # Printed at the end: 'No change to .config'

请注意,我需要清除环境中的ARCH。
之后,我像往常一样继续进行。
VERSION=5.6.3                # I have checked out tag v5.6.3 **)
FLAVOUR=lowlatlocxhci        # Or whatever you want to call your kernel.
make -j8 deb-pkg LOCALVERSION=-$FLAVOUR
sudo dpkg -i ../linux-headers-$VERSION-${FLAVOUR}_$VERSION-$FLAVOUR-1_amd64.deb ../linux-image-$VERSION-${FLAVOUR}_$VERSION-${FLAVOUR}-1_amd64.deb

最后一条命令目前无法编译virtualbox内核模块,但我不介意这些错误,可以忽略这些错误(只要您不使用虚拟机)。
*) 使用的.config是通过启动带有所有内容的内核(即分发内核),将其配置从/boot复制到源树中,并确保加载了我需要的所有内核模块(通过运行导致这些模块被加载的应用程序)。最后运行make menuconfig,关闭此内核中的CONFIG_DEBUG_INFO并将一些通常构建到内核中的东西也变为模块(我需要这样做的某些原因)。
**) 我的git树已准备好:
VERSION=5.6.3
FLAVOUR=lowlatlocxhci
git clone git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git linux-$VERSION-$FLAVOUR-$VERSION-$FLAVOUR
cd linux-$VERSION-$FLAVOUR-$VERSION-$FLAVOUR
git checkout -b test_$FLAVOUR v$VERSION
# Make manual changes here, and commit as usual.

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接