Skip to content

Commit eb27ea5

Browse files
committed
kbuild: move modkern_{c,a}flags to Makefile.lib from Makefile.build
Makefile.lib is included by Makefile.modfinal as well as Makefile.build. Move modkern_cflags to Makefile.lib in order to simplify cmd_cc_o_c in Makefile.modfinal. Move modkern_cflags as well for consistency. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
1 parent 2ff2b7e commit eb27ea5

3 files changed

Lines changed: 15 additions & 16 deletions

File tree

‎scripts/Makefile.build‎

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -92,15 +92,6 @@ endif
9292
# Compile C sources (.c)
9393
# ---------------------------------------------------------------------------
9494

95-
# Default is built-in, unless we know otherwise
96-
part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
97-
98-
modkern_cflags = \
99-
$(if $(part-of-module), \
100-
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
101-
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
102-
quiet_modtag = $(if $(part-of-module),[M], )
103-
10495
quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
10596
cmd_cc_s_c = $(CC) $(filter-out $(DEBUG_CFLAGS), $(c_flags)) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
10697

@@ -304,10 +295,6 @@ $(obj)/%.h.s: $(src)/%.h FORCE
304295
# Compile assembler sources (.S)
305296
# ---------------------------------------------------------------------------
306297

307-
modkern_aflags = $(if $(part-of-module), \
308-
$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \
309-
$(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
310-
311298
# .S file exports must have their C prototypes defined in asm/asm-prototypes.h
312299
# or a file that it includes, in order to get versioned symbols. We build a
313300
# dummy C file that includes asm-prototypes and the EXPORT_SYMBOL lines from

‎scripts/Makefile.lib‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,18 @@ _cpp_flags += -I $(srctree)/$(src) -I $(objtree)/$(obj)
159159
endif
160160
endif
161161

162+
part-of-module = $(if $(filter $(basename $@).o, $(real-obj-m)),y)
163+
quiet_modtag = $(if $(part-of-module),[M], )
164+
165+
modkern_cflags = \
166+
$(if $(part-of-module), \
167+
$(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE), \
168+
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
169+
170+
modkern_aflags = $(if $(part-of-module), \
171+
$(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE), \
172+
$(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL))
173+
162174
c_flags = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE) \
163175
-include $(srctree)/include/linux/compiler_types.h \
164176
$(_c_flags) $(modkern_cflags) \

‎scripts/Makefile.modfinal‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ modules := $(sort $(shell cat $(MODORDER)))
1717
__modfinal: $(modules)
1818
@:
1919

20-
# modname is set to make c_flags define KBUILD_MODNAME
20+
# modname and part-of-module are set to make c_flags define proper module flags
2121
modname = $(notdir $(@:.mod.o=))
22+
part-of-module = y
2223

2324
quiet_cmd_cc_o_c = CC [M] $@
24-
cmd_cc_o_c = $(CC) $(c_flags) $(KBUILD_CFLAGS_MODULE) $(CFLAGS_MODULE) \
25-
-c -o $@ $<
25+
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
2626

2727
%.mod.o: %.mod.c FORCE
2828
$(call if_changed_dep,cc_o_c)

0 commit comments

Comments
 (0)