1

使用运行 2.6.35 自定义内核的旧 ARM 板。制造商提供了两种不同的交叉工具链:

* gcc version 4.3.3 (Sourcery G++ Lite 2009q1-203) --> kernel toolchain
* gcc version 4.9.4 (crosstool-NG crosstool-ng-1.23.0) --> userspace toolchain

制造商还提供了一组脚本作为胶水来编译内核、模块并制作最终 rootfs 的包。

我的目的是删除所有自定义的“胶水”脚本,并将整个构建过程集成到一个 buildroot 中。我选择了 buildroot-2016.08.01。

运行 buildroot menuconfig 并设置此变量:

BR2_TOOLCHAIN_EXTERNAL_PATH="/opt/arm/crosstool-ng/"
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_PREFIX="armv5te-linux-gnueabi"
BR2_TOOLCHAIN_EXTERNAL_PREFIX="armv5te-linux-gnueabi"

我可以设置外部用户空间工具链。用户空间编译工作正常,按预期生成最终的 rootfs。

我的问题是:是否可以在 buildroot 中定义两个外部工具链,一个用于编译内核,另一个用于编译 rootfs 用户空间?我不知道。我在 buildroot 文档中没有找到任何相关内容。

我认为 buildroot 期望使用相同的工具链来编译内核和用户空间。但是在尝试仅使用一个工具链来编译它们时我遇到了问题。

a) 如果我尝试使用内核工具链编译用户空间,编译busybox会失败:

debianutils/lib.a(mktemp.o): In function `mktemp_main':
mktemp.c:(.text.mktemp_main+0x98): warning: the use of `mktemp' is dangerous, better use `mkstemp'
util-linux/lib.a(nsenter.o): In function `nsenter_main':
nsenter.c:(.text.nsenter_main+0x180): undefined reference to `setns'
coreutils/lib.a(sync.o): In function `sync_main':
sync.c:(.text.sync_main+0x78): undefined reference to `syncfs'
collect2: ld returned 1 exit status
Note: if build needs additional libraries, put them in CONFIG_EXTRA_LDLIBS.
Example: CONFIG_EXTRA_LDLIBS="pthread dl tirpc audit pam"
make[1]: *** [busybox_unstripped] Error 1
make[1]: Leaving directory `/usr/local/buildroot/output/build/busybox-1.25.0'

b) 如果我尝试使用用户空间工具链编译内核,我会收到意外错误:

In file included from /linux-2.6.35-custom/arch/arm/include/asm/page.h:206:0,
                 from include/linux/mmzone.h:20,
                 from include/linux/gfp.h:4,
                 from include/linux/kmod.h:22,
                 from include/linux/module.h:13,
                 from arch/arm/okl4-microvisor/vmmu.c:14:
arch/arm/okl4-microvisor/vmmu.c: In function 'reserve_node_zero':
arch/arm/okl4-microvisor/vmmu.c:488:35: error: taking address of expression of type 'void' [-Werror]
  reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext,
                               ^
/linux-2.6.35-custom/arch/arm/include/asm/memory.h:150:29: note: in definition of macro '__virt_to_phys'
 #define __virt_to_phys(x) ((x) - PAGE_OFFSET + PHYS_OFFSET)
                         ^
arch/arm/okl4-microvisor/vmmu.c:488:30: note: in expansion of macro '__pa'
  reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext,
                          ^
arch/arm/okl4-microvisor/vmmu.c:488:45: error: taking address of expression of type 'void' [-Werror]
  reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext,
                                         ^
arch/arm/okl4-microvisor/vmmu.c:488:53: error: taking address of expression of type 'void' [-Werror]
  reserve_bootmem_node(pgdat, __pa(&_stext), &_end - &_stext,
                                                 ^
arch/arm/okl4-microvisor/vmmu.c: In function 'setup_mm_for_reboot':
arch/arm/okl4-microvisor/vmmu.c:904:9: error: variable 'pgd' set but not used [-Werror=unused-but-set-variable]
  pgd_t *pgd;
         ^
cc1: all warnings being treated as errors
make[1]: *** [arch/arm/okl4-microvisor/vmmu.o] Error 1

但是,当使用适当的工具链编译用户空间和内核时,一切正常。我不明白为什么这个在用户空间工作得很好的工具链在编译内核时会产生错误。这是正常的吗?预先感谢!

4

0 回答 0