Commit 40df759e2b9ec945f1a5ddc61b3fdfbb6583257e
1 parent
a8b8017c34
Exists in
master
and in
7 other branches
kbuild: Fix build with binutils <= 2.19
The D option of ar is only available in newer versions. Signed-off-by: Michal Marek <mmarek@suse.cz>
Showing 4 changed files with 16 additions and 2 deletions Side-by-side Diff
Documentation/kbuild/makefiles.txt
... | ... | @@ -955,6 +955,11 @@ |
955 | 955 | used when linking modules. This is often a linker script. |
956 | 956 | From commandline LDFLAGS_MODULE shall be used (see kbuild.txt). |
957 | 957 | |
958 | + KBUILD_ARFLAGS Options for $(AR) when creating archives | |
959 | + | |
960 | + $(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic | |
961 | + mode) if this option is supported by $(AR). | |
962 | + | |
958 | 963 | --- 6.2 Add prerequisites to archprepare: |
959 | 964 | |
960 | 965 | The archprepare: rule is used to list prerequisites that need to be |
Makefile
... | ... | @@ -382,6 +382,7 @@ |
382 | 382 | export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE |
383 | 383 | export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE |
384 | 384 | export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL |
385 | +export KBUILD_ARFLAGS | |
385 | 386 | |
386 | 387 | # When compiling out-of-tree modules, put MODVERDIR in the module |
387 | 388 | # tree rather than in the kernel tree. The kernel tree might |
... | ... | @@ -611,6 +612,9 @@ |
611 | 612 | |
612 | 613 | # conserve stack if available |
613 | 614 | KBUILD_CFLAGS += $(call cc-option,-fconserve-stack) |
615 | + | |
616 | +# use the deterministic mode of AR if available | |
617 | +KBUILD_ARFLAGS := $(call ar-option,D) | |
614 | 618 | |
615 | 619 | # check for 'asm goto' |
616 | 620 | ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y) |
scripts/Kbuild.include
... | ... | @@ -141,6 +141,11 @@ |
141 | 141 | ld-option = $(call try-run,\ |
142 | 142 | $(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2)) |
143 | 143 | |
144 | +# ar-option | |
145 | +# Usage: KBUILD_ARFLAGS := $(call ar-option,D) | |
146 | +# Important: no spaces around options | |
147 | +ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) | |
148 | + | |
144 | 149 | ###### |
145 | 150 | |
146 | 151 | ### |
scripts/Makefile.build
... | ... | @@ -345,7 +345,7 @@ |
345 | 345 | cmd_link_o_target = $(if $(strip $(obj-y)),\ |
346 | 346 | $(LD) $(ld_flags) -r -o $@ $(filter $(obj-y), $^) \ |
347 | 347 | $(cmd_secanalysis),\ |
348 | - rm -f $@; $(AR) rcsD $@) | |
348 | + rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@) | |
349 | 349 | |
350 | 350 | $(builtin-target): $(obj-y) FORCE |
351 | 351 | $(call if_changed,link_o_target) |
... | ... | @@ -371,7 +371,7 @@ |
371 | 371 | # |
372 | 372 | ifdef lib-target |
373 | 373 | quiet_cmd_link_l_target = AR $@ |
374 | -cmd_link_l_target = rm -f $@; $(AR) rcsD $@ $(lib-y) | |
374 | +cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y) | |
375 | 375 | |
376 | 376 | $(lib-target): $(lib-y) FORCE |
377 | 377 | $(call if_changed,link_l_target) |