You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Linux 6.13.4及以上版本内核编译时如何传递编译器选项?

Linux 6.13.4+ 自定义优化标志编译内核失败问题及解决方法

从Linux 6.13.4版本起,无法再通过自定义优化标志编译内核。在Linux 6.13.2版本中,以下命令可正常运行:

make CFLAGS='-march=native -Os -ffast-math -flto -pipe' CXXFLAGS='-march=native -Os -ffast-math -flto -pipe'

但升级到Linux 6.13.6版本后,编译时出现如下报错:

CC      /home/user/Téléchargements/linux-6.13.6/tools/objtool/libsubcmd/exec-cmd.o
exec-cmd.c:2:10: fatal error: linux/compiler.h: No such file or directory
    2 | #include <linux/compiler.h>
      |          ^~~~~~~~~~~~~~~~~~
compilation terminated.

解决方法

问题已解决,使用以下命令即可完成编译:

export KCFLAGS=" -march=native -Os -ffast-math"
export KCPPFLAGS=" -march=native -Os -ffast-math"
export KRUSTFLAGS=" -C target-cpu=native"

make

补充说明:-flto选项无法生效,推测此前的编译命令实际并未正常启用该选项。


内容的提问来源于stack exchange,提问作者anclarma

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.13 22:45:58