History

kbuild: read *.mod to get objects passed to $(LD) or $(AR)

ld and ar support @file, which command-line options are read from. Now that *.mod lists the member objects in the correct order, without duplication, it is ready to be passed to ld and ar. By using the @file syntax, people will not be worried about the pitfall described in the NOTE.

Masahiro Yamada committed 4 years ago

Commit feb7d791 parent fc93a4c1 file · +3 −7Browse files

Showing the changes to scripts (1 of 1 file). Show all

Unified · Split

scripts/Makefile.build+3−7
@@ -450,22 +450,18 @@ quiet_cmd_ar_lib = AR $@ · 449 unmodified lines
450450 $(obj)/lib.a: $(lib-y) FORCE
451451 $(call if_changed,ar_lib)
452452
453−# NOTE:
454−# Do not replace $(filter %.o,^) with $(real-prereqs). When a single object
455−# module is turned into a multi object module, $^ will contain header file
456−# dependencies recorded in the .*.cmd file.
457453 ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
458454 quiet_cmd_link_multi-m = AR [M] $@
459455 cmd_link_multi-m = \
460456 $(cmd_update_lto_symversions); \
461457 rm -f $@; \
462− $(AR) cDPrsT $@ $(filter %.o,$^)
458+ $(AR) cDPrsT $@ @$(patsubst %.o,%.mod,$@)
463459 else
464460 quiet_cmd_link_multi-m = LD [M] $@
465− cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(filter %.o,$^)
461+ cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ @$(patsubst %.o,%.mod,$@)
466462 endif
467463
468−$(multi-obj-m): FORCE
464+$(multi-obj-m): %.o: %.mod FORCE
469465 $(call if_changed,link_multi-m)
470466 $(call multi_depend, $(multi-obj-m), .o, -objs -y -m)
471467

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t