kbuild: refactor modversions build rules
Let $(CC) compile objects into normal files *.o instead of .tmp_*.o
whether CONFIG_MODVERSIONS is enabled or not. With this, the input
file for objtool is always *.o so objtool_o can go away.
I guess the reason of using .tmp_*.o for intermediate objects was
to avoid leaving incomplete *.o file (, whose timestamp says it is
up-to-date) when the genksyms tool failed for some reasons.
It no longer matters because any targets are deleted on errors since
commit 9c2af1c737
("kbuild: add .DELETE_ON_ERROR special target").
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
This commit is contained in:
parent
4317ee3b6a
commit
ee3e46b7ef
@ -154,35 +154,30 @@ $(obj)/%.ll: $(src)/%.c FORCE
|
|||||||
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
|
# (See cmd_cc_o_c + relevant part of rule_cc_o_c)
|
||||||
|
|
||||||
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
|
quiet_cmd_cc_o_c = CC $(quiet_modtag) $@
|
||||||
|
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
|
||||||
|
|
||||||
ifndef CONFIG_MODVERSIONS
|
ifdef CONFIG_MODVERSIONS
|
||||||
cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
|
|
||||||
|
|
||||||
else
|
|
||||||
# When module versioning is enabled the following steps are executed:
|
# When module versioning is enabled the following steps are executed:
|
||||||
# o compile a .tmp_<file>.o from <file>.c
|
# o compile a <file>.o from <file>.c
|
||||||
# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
|
# o if <file>.o doesn't contain a __ksymtab version, i.e. does
|
||||||
# not export symbols, we just rename .tmp_<file>.o to <file>.o and
|
# not export symbols, it's done.
|
||||||
# are done.
|
|
||||||
# o otherwise, we calculate symbol versions using the good old
|
# o otherwise, we calculate symbol versions using the good old
|
||||||
# genksyms on the preprocessed source and postprocess them in a way
|
# genksyms on the preprocessed source and postprocess them in a way
|
||||||
# that they are usable as a linker script
|
# that they are usable as a linker script
|
||||||
# o generate <file>.o from .tmp_<file>.o using the linker to
|
# o generate .tmp_<file>.o from <file>.o using the linker to
|
||||||
# replace the unresolved symbols __crc_exported_symbol with
|
# replace the unresolved symbols __crc_exported_symbol with
|
||||||
# the actual value of the checksum generated by genksyms
|
# the actual value of the checksum generated by genksyms
|
||||||
|
# o remove .tmp_<file>.o to <file>.o
|
||||||
cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
|
|
||||||
|
|
||||||
cmd_modversions_c = \
|
cmd_modversions_c = \
|
||||||
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
|
if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
|
||||||
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
$(call cmd_gensymtypes_c,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
||||||
> $(@D)/.tmp_$(@F:.o=.ver); \
|
> $(@D)/.tmp_$(@F:.o=.ver); \
|
||||||
\
|
\
|
||||||
$(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
|
$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
|
||||||
-T $(@D)/.tmp_$(@F:.o=.ver); \
|
-T $(@D)/.tmp_$(@F:.o=.ver); \
|
||||||
rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
|
|
||||||
else \
|
|
||||||
mv -f $(@D)/.tmp_$(@F) $@; \
|
mv -f $(@D)/.tmp_$(@F) $@; \
|
||||||
|
rm -f $(@D)/.tmp_$(@F:.o=.ver); \
|
||||||
fi;
|
fi;
|
||||||
endif
|
endif
|
||||||
|
|
||||||
@ -241,19 +236,12 @@ ifneq ($(RETPOLINE_CFLAGS),)
|
|||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
|
||||||
ifdef CONFIG_MODVERSIONS
|
|
||||||
objtool_o = $(@D)/.tmp_$(@F)
|
|
||||||
else
|
|
||||||
objtool_o = $(@)
|
|
||||||
endif
|
|
||||||
|
|
||||||
# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
|
# 'OBJECT_FILES_NON_STANDARD := y': skip objtool checking for a directory
|
||||||
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
|
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'y': skip objtool checking for a file
|
||||||
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
|
# 'OBJECT_FILES_NON_STANDARD_foo.o := 'n': override directory skip for a file
|
||||||
cmd_objtool = $(if $(patsubst y%,, \
|
cmd_objtool = $(if $(patsubst y%,, \
|
||||||
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
||||||
$(__objtool_obj) $(objtool_args) "$(objtool_o)";)
|
$(__objtool_obj) $(objtool_args) $@;)
|
||||||
objtool_obj = $(if $(patsubst y%,, \
|
objtool_obj = $(if $(patsubst y%,, \
|
||||||
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
$(OBJECT_FILES_NON_STANDARD_$(basetarget).o)$(OBJECT_FILES_NON_STANDARD)n), \
|
||||||
$(__objtool_obj))
|
$(__objtool_obj))
|
||||||
@ -357,34 +345,26 @@ $(obj)/%.s: $(src)/%.S FORCE
|
|||||||
$(call if_changed_dep,cpp_s_S)
|
$(call if_changed_dep,cpp_s_S)
|
||||||
|
|
||||||
quiet_cmd_as_o_S = AS $(quiet_modtag) $@
|
quiet_cmd_as_o_S = AS $(quiet_modtag) $@
|
||||||
|
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
|
||||||
|
|
||||||
ifndef CONFIG_MODVERSIONS
|
ifdef CONFIG_MODVERSIONS
|
||||||
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)
|
ASM_PROTOTYPES := $(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/asm-prototypes.h)
|
||||||
|
|
||||||
ifeq ($(ASM_PROTOTYPES),)
|
ifneq ($(ASM_PROTOTYPES),)
|
||||||
cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
|
|
||||||
|
|
||||||
else
|
|
||||||
|
|
||||||
# versioning matches the C process described above, with difference that
|
# versioning matches the C process described above, with difference that
|
||||||
# we parse asm-prototypes.h C header to get function definitions.
|
# we parse asm-prototypes.h C header to get function definitions.
|
||||||
|
|
||||||
cmd_as_o_S = $(CC) $(a_flags) -c -o $(@D)/.tmp_$(@F) $<
|
|
||||||
|
|
||||||
cmd_modversions_S = \
|
cmd_modversions_S = \
|
||||||
if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then \
|
if $(OBJDUMP) -h $@ | grep -q __ksymtab; then \
|
||||||
$(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
$(call cmd_gensymtypes_S,$(KBUILD_SYMTYPES),$(@:.o=.symtypes)) \
|
||||||
> $(@D)/.tmp_$(@F:.o=.ver); \
|
> $(@D)/.tmp_$(@F:.o=.ver); \
|
||||||
\
|
\
|
||||||
$(LD) $(KBUILD_LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) \
|
$(LD) $(KBUILD_LDFLAGS) -r -o $(@D)/.tmp_$(@F) $@ \
|
||||||
-T $(@D)/.tmp_$(@F:.o=.ver); \
|
-T $(@D)/.tmp_$(@F:.o=.ver); \
|
||||||
rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver); \
|
|
||||||
else \
|
|
||||||
mv -f $(@D)/.tmp_$(@F) $@; \
|
mv -f $(@D)/.tmp_$(@F) $@; \
|
||||||
|
rm -f $(@D)/.tmp_$(@F:.o=.ver); \
|
||||||
fi;
|
fi;
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
Loading…
Reference in New Issue
Block a user