【问题标题】:error when building 32-bit linux kernel on 64-bit linux host在 64 位 linux 主机上构建 32 位 linux 内核时出错
【发布时间】:2013-01-09 01:03:36
【问题描述】:

我正在尝试在具有 2.6.9(相同版本)的 64 位 linux 主机上构建 32 位 linux 内核 2.6.9。做了一些谷歌搜索并尝试了以下内容:

步骤 1) 使 ARCH=i386 CFLAGS=-m32 menuconfig

步骤 2) 使 ARCH=i386 CFLAGS=-m32

第 1 步没问题。但第 2 步出现以下错误。我做错什么了?

make ARCH=i386 CFLAGS=-m32 
< snip >
In file included from include/asm/smp.h:18,
                 from include/linux/smp.h:17,
                 from include/linux/sched.h:23,
                 from arch/i386/kernel/asm-offsets.c:7:
include/asm/mpspec.h:6:25: mach_mpspec.h: No such file or directory
In file included from include/asm/smp.h:18,
                 from include/linux/smp.h:17,
                 from include/linux/sched.h:23,
                 from arch/i386/kernel/asm-offsets.c:7:
include/asm/mpspec.h:8: error: `MAX_MP_BUSSES' undeclared here (not in a function)
include/asm/mpspec.h:22: error: `MAX_IRQ_SOURCES' undeclared here (not in a function)
In file included from include/linux/smp.h:17,
                 from include/linux/sched.h:23,
                 from arch/i386/kernel/asm-offsets.c:7:
include/asm/smp.h:72:26: mach_apicdef.h: No such file or directory
make[1]: *** [arch/i386/kernel/asm-offsets.s] Error 1
make: *** [arch/i386/kernel/asm-offsets.s] Error 2

【问题讨论】:

  • 你安装了 kernel-devel 包吗?

标签: linux kernel


【解决方案1】:

make ARCH=i386 应该足够了,前提是您已经在机器上安装了构建所需的一切。我几乎每天都使用它在“ubuntu 12.04”上构建 i386。

如果您之前构建了 64 位内核,那么您应该拥有一切,并且您可能需要“make clean”甚至“make mrproper”[将您的 .config 保存在安全的地方以供后者使用],因为我知道例如 asm_offsets.s 在 32 位和 64 位之间会有所不同。

【讨论】:

  • 感谢您的回复。 “机器上安装的构建所需的一切”是什么意思?为了澄清,我没有安装任何额外/特殊的构建工具。 gcc 和 make 都是原生的。我认为它们应该可以工作,因为主机 linux 的版本相同(2.6.9 x86_64)。
  • 我不确定我安装了什么来构建内核,我认为是源代码和 gcc 编译器。你能建立64位版本吗?如果是这样,您应该能够构建 32 位版本。当然,2.6.9 是一个 ANCIENT 版本 - 2.6.38 是最新的 2.6 内核,而 3.x 内核现在已经达到 3.8(我在我正在输入这个的机器上运行 3.7rc5+) .
  • 是的。我可以成功构建 64 位版本。我取得了一些进展。在CFLAGS中加入:-Iinclude/asm/mach-default后,上面的错误就没有了。但是我从 AS 遇到了一个新错误:arch/i386/kernel/entry.S:145: Error: suffix or operands invalid for `pushf' 我怀疑 AS 仍在尝试使用 x86_64。我什至添加了 ASFLAGS='-march=i386 --32' 但没有帮助。
  • 你不应该乱搞这些类型的设置。您是否尝试过简单地在 32 位中编译一个“hello world”,以确保 32 位构建完全有效 - 在我的 Fedora 机器上,我无法构建 32 位代码 [我真的不需要,所以我还没有试图找出它为什么不起作用]。
  • 构建像“hellow world”这样的程序是成功的。实际上,所有用户空间的 32 位版本在这台主机上都可以。只有在构建 32 位内核时才会出现问题。
猜你喜欢
  • 2012-11-26
  • 2012-08-01
  • 1970-01-01
  • 2012-07-20
  • 1970-01-01
  • 1970-01-01
  • 2020-08-16
  • 2013-11-14
  • 1970-01-01
相关资源
最近更新 更多