]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
kbuild: refactor modversions build rules
authorIlias Apalodimas <ilias.apalodimas@linaro.org>
Tue, 20 May 2025 05:21:24 +0000 (08:21 +0300)
committerTom Rini <trini@konsulko.com>
Fri, 30 May 2025 00:42:37 +0000 (18:42 -0600)
Backport from kernel
commit ee3e46b7efd2 ("kbuild: refactor modversions build rules")

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
scripts/Makefile.build

index b2bf5a2c00013cc2f36e1b66d5d0c829b87b18ee..639091e7b29c7d37c35b0370baa643337a0905bf 100644 (file)
@@ -171,34 +171,30 @@ $(obj)/%.symtypes : $(src)/%.c FORCE
 # (See cmd_cc_o_c + relevant part of rule_cc_o_c)
 
 quiet_cmd_cc_o_c = CC $(quiet_modtag)  $@
-
-ifndef CONFIG_MODVERSIONS
 cmd_cc_o_c = $(CC) $(c_flags) -c -o $@ $<
 
-else
+ifdef CONFIG_MODVERSIONS
 # When module versioning is enabled the following steps are executed:
-# o compile a .tmp_<file>.o from <file>.c
-# o if .tmp_<file>.o doesn't contain a __ksymtab version, i.e. does
-#   not export symbols, we just rename .tmp_<file>.o to <file>.o and
-#   are done.
+# o compile a <file>.o from <file>.c
+# o if <file>.o doesn't contain a __ksymtab version, i.e. does
+#   not export symbols, it's done
 # o otherwise, we calculate symbol versions using the good old
 #   genksyms on the preprocessed source and postprocess them in a way
 #   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
 #   the actual value of the checksum generated by genksyms
 
-cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
+# o remove .tmp_<file>.o to <file>.o
 cmd_modversions =                                                              \
-       if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then             \
+       if $(OBJDUMP) -h $@ | grep -q __ksymtab; then                           \
                $(call cmd_gensymtypes,$(KBUILD_SYMTYPES),$(@:.o=.symtypes))    \
                    > $(@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);                            \
-               rm -f $(@D)/.tmp_$(@F) $(@D)/.tmp_$(@F:.o=.ver);                \
-       else                                                                    \
                mv -f $(@D)/.tmp_$(@F) $@;                                      \
+               rm -f $(@D)/.tmp_$(@F:.o=.ver);                                 \
        fi;
 endif