Skip to content

Commit 000e22a

Browse files
committed
kbuild: move cmd_cc_o_c and cmd_as_o_S to scripts/Malefile.lib
The cmd_cc_o_c and cmd_as_o_S macros are duplicated in scripts/Makefile.{build,modfinal,vmlinux}. This commit factors them out to scripts/Makefile.lib. No functional changes are intended. Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 91ca8be commit 000e22a

File tree

4 files changed

+13
-21
lines changed

4 files changed

+13
-21
lines changed

scripts/Makefile.build

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,6 @@ ifdef CONFIG_LTO_CLANG
135135
cmd_ld_single_m = $(if $(is-single-obj-m), ; $(LD) $(ld_flags) -r -o $(tmp-target) $@; mv $(tmp-target) $@)
136136
endif
137137

138-
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
139-
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< \
140-
$(cmd_ld_single_m) \
141-
$(cmd_objtool)
142-
143138
ifdef CONFIG_MODVERSIONS
144139
# When module versioning is enabled the following steps are executed:
145140
# o compile a <file>.o from <file>.c
@@ -322,9 +317,6 @@ cmd_cpp_s_S = $(CPP) $(a_flags) -o $@ $<
322317
$(obj)/%.s: $(obj)/%.S FORCE
323318
$(call if_changed_dep,cpp_s_S)
324319

325-
quiet_cmd_as_o_S = AS $(quiet_modtag) $@
326-
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< $(cmd_objtool)
327-
328320
ifdef CONFIG_ASM_MODVERSIONS
329321

330322
# versioning matches the C process described above, with difference that

scripts/Makefile.lib

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -298,6 +298,18 @@ $(foreach m, $1, \
298298
$(addprefix $(obj)/, $(call suffix-search, $(patsubst $(obj)/%,%,$m), $2, $3))))
299299
endef
300300

301+
# Build commands
302+
# ===========================================================================
303+
# These are shared by some Makefile.* files.
304+
305+
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
306+
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $< \
307+
$(cmd_ld_single_m) \
308+
$(cmd_objtool)
309+
310+
quiet_cmd_as_o_S = AS $(quiet_modtag) $@
311+
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $< $(cmd_objtool)
312+
301313
# Copy a file
302314
# ===========================================================================
303315
# 'cp' preserves permissions. If you use it to copy a file in read-only srctree,

scripts/Makefile.modfinal

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ __modfinal:
88

99
include $(objtree)/include/config/auto.conf
1010
include $(srctree)/scripts/Kbuild.include
11-
12-
# for c_flags
1311
include $(srctree)/scripts/Makefile.lib
1412

1513
# find all modules listed in modules.order
@@ -23,9 +21,7 @@ modname = $(notdir $(@:.mod.o=))
2321
part-of-module = y
2422
GCOV_PROFILE := n
2523
KCSAN_SANITIZE := n
26-
27-
quiet_cmd_cc_o_c = CC [M] $@
28-
cmd_cc_o_c = $(CC) $(filter-out $(CC_FLAGS_CFI), $(c_flags)) -c -o $@ $<
24+
ccflags-remove-y := $(CC_FLAGS_CFI)
2925

3026
%.mod.o: %.mod.c FORCE
3127
$(call if_changed_dep,cc_o_c)

scripts/Makefile.vmlinux

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,13 @@ __default: vmlinux
55

66
include include/config/auto.conf
77
include $(srctree)/scripts/Kbuild.include
8-
9-
# for c_flags
108
include $(srctree)/scripts/Makefile.lib
119

1210
targets :=
1311

14-
quiet_cmd_cc_o_c = CC $@
15-
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
16-
1712
%.o: %.c FORCE
1813
$(call if_changed_dep,cc_o_c)
1914

20-
quiet_cmd_as_o_S = AS $@
21-
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
22-
2315
%.o: %.S FORCE
2416
$(call if_changed_dep,as_o_S)
2517

0 commit comments

Comments
 (0)