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
450$(obj)/lib.a: $(lib-y) FORCE450$(obj)/lib.a: $(lib-y) FORCE
451 $(call if_changed,ar_lib)451 $(call if_changed,ar_lib)
452 452
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.
457ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)453ifneq ($(CONFIG_LTO_CLANG)$(CONFIG_X86_KERNEL_IBT),)
458quiet_cmd_link_multi-m = AR [M] $@454quiet_cmd_link_multi-m = AR [M] $@
459cmd_link_multi-m = \455cmd_link_multi-m = \
460 $(cmd_update_lto_symversions); \456 $(cmd_update_lto_symversions); \
461 rm -f $@; \457 rm -f $@; \
462 $(AR) cDPrsT $@ $(filter %.o,$^)458 $(AR) cDPrsT $@ @$(patsubst %.o,%.mod,$@)
463else459else
464quiet_cmd_link_multi-m = LD [M] $@460quiet_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,$@)
466endif462endif
467 463
468$(multi-obj-m): FORCE464$(multi-obj-m): %.o: %.mod FORCE
469 $(call if_changed,link_multi-m)465 $(call if_changed,link_multi-m)
470$(call multi_depend, $(multi-obj-m), .o, -objs -y -m)466$(call multi_depend, $(multi-obj-m), .o, -objs -y -m)
471 467

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