在 fedora 上怎么交叉编译内核并打 rpm 包?

172 天前
 wniming

如果仅仅只是交叉编译内核或给内核打 rpm 包都很容易,但是给交叉编译的内核打 rpm 包我折腾了 2 天都没搞定,遇到的问题如下:


用这种方式:

make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j32 
make ARCH=arm64 CROSS_COMPILE=aarch64-linux-gnu- -j32 binrpm-pkg

这样是可以打出 rpm 包的,但这样打出的 rpm 包安装时有问题:

root@macmini-m2:/home/d# rpm -ivh /home/d/kernel-6.5.0_asahi+-1.aarch64.rpm 
Verifying...                          ################################# [100%]
Preparing...                          ################################# [100%]
Updating / installing...
   1:kernel-6.5.0_asahi+-1            ################################# [100%]
grub2-mkrelpath: error: failed to get canonical path of `/boot/vmlinuz-6.5.0-asahi+'.
dirname: missing operand
Try 'dirname --help' for more information.

如果用这种方式:

d@7950x:~$ rpmbuild -bb --target=aarch64 rpmbuild/SPECS/kernel.spec

则 rpmbuild 执行失败,遇到这种报错:

cc1: error: unrecognized command-line option ‘-mbranch-protection=standard’

做如下测试可以发现是 rpmbuild 没有用正确的编译器导致的:

d@7950x:~$ gcc -mbranch-protection=standard
gcc: error: unrecognized command-line option ‘-mbranch-protection=standard’
gcc: fatal error: no input files
compilation terminated.
d@7950x:~$ 
d@7950x:~$ /usr/bin/aarch64-linux-gnu-gcc -mbranch-protection=standard
aarch64-linux-gnu-gcc: fatal error: no input files
compilation terminated.
d@7950x:~$ 
762 次点击
所在节点    Linux
1 条回复
ttvast
171 天前
rpmbuild 好像并不是为交叉编译而生的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/994232

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX