V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
wniming
V2EX  ›  Linux

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

  •  
  •   wniming · 157 天前 · 746 次点击
    这是一个创建于 157 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如果仅仅只是交叉编译内核或给内核打 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:~$ 
    
    1 条回复    2023-11-23 10:22:29 +08:00
    ttvast
        1
    ttvast  
       157 天前
    rpmbuild 好像并不是为交叉编译而生的
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5397 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 08:28 · PVG 16:28 · LAX 01:28 · JFK 04:28
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.