欢迎访问 生活随笔!

生活随笔

当前位置: 首页 > 运维知识 > linux >内容正文

linux

编译linux内核适用的编译器,编译Linux内核时,CC,LD和CC [M]输出的代码是什么?...

发布时间:2025/3/8 linux 50 豆豆
生活随笔 收集整理的这篇文章主要介绍了 编译linux内核适用的编译器,编译Linux内核时,CC,LD和CC [M]输出的代码是什么?... 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

所以一般情况下,你只需要 git grep 'cmd.* = CODE'

找到CODE。

获取scripts/Makefile.build定义的所有代码 make | grep -E '^ ' | sort -uk1,1

CC和CC [M]

名单: quiet_cmd_cc_o_c = CC $(quiet_modtag) [email protected]

cmd_cc_o_c = $(CC) $(c_flags) -c -o [email protected] $< $(real-objs-m) : quiet_modtag := [M]

$(real-objs-m:.o=.i) : quiet_modtag := [M]

$(real-objs-m:.o=.s) : quiet_modtag := [M]

$(real-objs-m:.o=.lst): quiet_modtag := [M]

$(obj-m) : quiet_modtag := [M]

据当时称为通过: $(obj)/%.o: $(src)/%.c $(recordmcount_source) FORCE

[...]

$(call if_changed_rule,cc_o_c)

define rule_cc_o_c

[...]

$(call echo-cmd,cc_o_c) $(cmd_cc_o_c); \

其中if_changed_rule在scripts/Kbuild.include定义为: if_changed_rule = $(if $(strip $(any-prereq) $(arg-check)), \

@set -e; \

$(rule_$(1)))

和Kbuild.include被包括在顶层的Makefile中。

LD

有几个版本,但最简单的似乎是: quiet_cmd_link_o_target = LD [email protected]

cmd_link_o_target = $(if $(strip $(obj-y)),\

$(LD) $(ld_flags) -r -o [email protected] $(filter $(obj-y), $^) \

$(cmd_secanalysis),\

rm -f [email protected]; $(AR) rcs$(KBUILD_ARFLAGS) [email protected])

$(builtin-target): $(obj-y) FORCE

$(call if_changed,link_o_target)

和scripts/Kbuild.include: # Execute command if command has changed or prerequisite(s) are updated.

#

if_changed = $(if $(strip $(any-prereq) $(arg-check)), \

@set -e; \

$(echo-cmd) $(cmd_$(1)); \

printf '%s\n' '[email protected] := $(make-cmd)' > $(dot-target).cmd)

总结

以上是生活随笔为你收集整理的编译linux内核适用的编译器,编译Linux内核时,CC,LD和CC [M]输出的代码是什么?...的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。