编译内核模块时如何使用标志

How to use flags while compiling Kernel Modules

我需要为我的内核模块使用一些优化和循环展开标志。但是我不知道如何将这些标志添加到 makefile 中。

KMOD= hello   # Name of KLD to build
SRCS= hello.c # List of source files

.include <bsd.kmod.mk>

我尝试 google 搜索但没有得到任何我可以使用的东西。谢谢你的时间。

编辑 1: 我正在循环执行一些内核内存修补。所以我不希望循环展开,因为这意味着需要更多修补。

我试过了

KMOD= hello   # Name of KLD to build
SRCS= hello.c # List of source files
CFLAGS = -O0 -fno-unroll-loops #tried combination of this and +=
.include <bsd.kmod.mk>

我也试过了,(我知道这只是一厢情愿)

make DEBUG_FLAGS = -O0 -fno-unroll-loops

很抱歉浪费了大家的时间。我得到了答案。

KMOD= hello
SRCS= hello.c
CFLAGS= -O0
.include <bsd.kmod.mk>

P.S请注意间距

谢谢

@Ctx 在问题评论中提出解决方案

@Rob 对于 providing/reminding 人们的资源在哪里,他们没有尽职调查就跳到问题上(像我一样)

资源:

FreeBSD devs Mailing List

FreeBSD Porter's Handbook