summaryrefslogtreecommitdiff
path: root/scripts/Makefile.build
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 15:51:22 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2018-04-03 15:51:22 -0700
commit3b24b83763e72a6c1e728100104fd99aa83a7b3b (patch)
treebd493c47804a9fe1e85ee41c2532b4748fca0b25 /scripts/Makefile.build
parent0734e00ef9e48e78c5c3ce1648572f160d07e323 (diff)
parenta95b37e20db9a2b05354eec009b2188523a21c8e (diff)
Merge tag 'kbuild-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild
Pull Kbuild updates from Masahiro Yamada: - add a shell script to get Clang version - improve portability of build scripts - drop always-enabled CONFIG_THIN_ARCHIVE and remove unused code - rename built-in.o which is now thin archive to built-in.a - process clean/build targets one by one to get along with -j option - simplify ld-option - improve building with CONFIG_TRIM_UNUSED_KSYMS - define KBUILD_MODNAME even for objects shared among multiple modules - avoid linking multiple instances of same objects from composite objects - move <linux/compiler_types.h> to c_flags to include it only for C files - clean-up various Makefiles * tag 'kbuild-v4.17' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (29 commits) kbuild: get <linux/compiler_types.h> out of <linux/kconfig.h> kbuild: clean up link rule of composite modules kbuild: clean up archive rule of built-in.a kbuild: remove partial section mismatch detection for built-in.a net: liquidio: clean up Makefile for simpler composite object handling lib: zstd: clean up Makefile for simpler composite object handling kbuild: link $(real-obj-y) instead of $(obj-y) into built-in.a kbuild: rename real-objs-y/m to real-obj-y/m kbuild: move modname and modname-multi close to modname_flags kbuild: simplify modname calculation kbuild: fix modname for composite modules kbuild: define KBUILD_MODNAME even if multiple modules share objects kbuild: remove unnecessary $(subst $(obj)/, , ...) in modname-multi kbuild: Use ls(1) instead of stat(1) to obtain file size kbuild: link vmlinux only once for CONFIG_TRIM_UNUSED_KSYMS kbuild: move include/config/ksym/* to include/ksym/* kbuild: move CONFIG_TRIM_UNUSED_KSYMS code unneeded for external module kbuild: restore autoksyms.h touch to the top Makefile kbuild: move 'scripts' target below kbuild: remove wrong 'touch' in adjust_autoksyms.sh ...
Diffstat (limited to 'scripts/Makefile.build')
-rw-r--r--scripts/Makefile.build97
1 files changed, 30 insertions, 67 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index 4f2b25d43ec9..77cce68c4d63 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -73,11 +73,11 @@ endif
ifneq ($(strip $(lib-y) $(lib-m) $(lib-)),)
lib-target := $(obj)/lib.a
-obj-y += $(obj)/lib-ksyms.o
+real-obj-y += $(obj)/lib-ksyms.o
endif
-ifneq ($(strip $(obj-y) $(need-builtin)),)
-builtin-target := $(obj)/built-in.o
+ifneq ($(strip $(real-obj-y) $(need-builtin)),)
+builtin-target := $(obj)/built-in.a
endif
modorder-target := $(obj)/modules.order
@@ -104,7 +104,7 @@ ifneq ($(KBUILD_ENABLE_EXTRA_GCC_CHECKS),)
cmd_checkdoc = $(srctree)/scripts/kernel-doc -none $< ;
endif
-# Do section mismatch analysis for each module/built-in.o
+# Do section mismatch analysis for each module/built-in.a
ifdef CONFIG_DEBUG_SECTION_MISMATCH
cmd_secanalysis = ; scripts/mod/modpost $@
endif
@@ -119,29 +119,17 @@ modkern_cflags = \
$(KBUILD_CFLAGS_KERNEL) $(CFLAGS_KERNEL))
quiet_modtag := $(empty) $(empty)
-$(real-objs-m) : part-of-module := y
-$(real-objs-m:.o=.i) : part-of-module := y
-$(real-objs-m:.o=.s) : part-of-module := y
-$(real-objs-m:.o=.lst): part-of-module := y
+$(real-obj-m) : part-of-module := y
+$(real-obj-m:.o=.i) : part-of-module := y
+$(real-obj-m:.o=.s) : part-of-module := y
+$(real-obj-m:.o=.lst): part-of-module := y
-$(real-objs-m) : quiet_modtag := [M]
-$(real-objs-m:.o=.i) : quiet_modtag := [M]
-$(real-objs-m:.o=.s) : quiet_modtag := [M]
-$(real-objs-m:.o=.lst): quiet_modtag := [M]
+$(real-obj-m) : quiet_modtag := [M]
+$(real-obj-m:.o=.i) : quiet_modtag := [M]
+$(real-obj-m:.o=.s) : quiet_modtag := [M]
+$(real-obj-m:.o=.lst): quiet_modtag := [M]
-$(obj-m) : quiet_modtag := [M]
-
-# Default for not multi-part modules
-modname = $(basetarget)
-
-$(multi-objs-m) : modname = $(modname-multi)
-$(multi-objs-m:.o=.i) : modname = $(modname-multi)
-$(multi-objs-m:.o=.s) : modname = $(modname-multi)
-$(multi-objs-m:.o=.lst) : modname = $(modname-multi)
-$(multi-objs-y) : modname = $(modname-multi)
-$(multi-objs-y:.o=.i) : modname = $(modname-multi)
-$(multi-objs-y:.o=.s) : modname = $(modname-multi)
-$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
+$(obj-m) : quiet_modtag := [M]
quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
@@ -314,7 +302,7 @@ endef
# List module undefined symbols (or empty line if not enabled)
ifdef CONFIG_TRIM_UNUSED_KSYMS
-cmd_undef_syms = $(NM) $@ | sed -n 's/^ \+U //p' | xargs echo
+cmd_undef_syms = $(NM) $@ | sed -n 's/^ *U //p' | xargs echo
else
cmd_undef_syms = echo
endif
@@ -345,8 +333,8 @@ $(obj)/%.lst: $(src)/%.c FORCE
modkern_aflags := $(KBUILD_AFLAGS_KERNEL) $(AFLAGS_KERNEL)
-$(real-objs-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
-$(real-objs-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
+$(real-obj-m) : modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
+$(real-obj-m:.o=.s): modkern_aflags := $(KBUILD_AFLAGS_MODULE) $(AFLAGS_MODULE)
# .S file exports must have their C prototypes defined in asm/asm-prototypes.h
# or a file that it includes, in order to get versioned symbols. We build a
@@ -424,7 +412,7 @@ endif
$(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
$(call if_changed_rule,as_o_S)
-targets += $(real-objs-y) $(real-objs-m) $(lib-y)
+targets += $(filter-out $(subdir-obj-y), $(real-obj-y)) $(real-obj-m) $(lib-y)
targets += $(extra-y) $(MAKECMDGOALS) $(always)
# Linker scripts preprocessor (.lds.S -> .lds)
@@ -458,24 +446,16 @@ $(sort $(subdir-obj-y)): $(subdir-ym) ;
#
ifdef builtin-target
-ifdef CONFIG_THIN_ARCHIVES
- cmd_make_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS)
- cmd_make_empty_builtin = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS)
- quiet_cmd_link_o_target = AR $@
-else
- cmd_make_builtin = $(LD) $(ld_flags) -r -o
- cmd_make_empty_builtin = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS)
- quiet_cmd_link_o_target = LD $@
-endif
-
-# If the list of objects to link is empty, just create an empty built-in.o
-cmd_link_o_target = $(if $(strip $(obj-y)),\
- $(cmd_make_builtin) $@ $(filter $(obj-y), $^) \
- $(cmd_secanalysis),\
- $(cmd_make_empty_builtin) $@)
+# built-in.a archives are made with no symbol table or index which
+# makes them small and fast, but unable to be used by the linker.
+# scripts/link-vmlinux.sh builds an aggregate built-in.a with a symbol
+# table and index.
+quiet_cmd_ar_builtin = AR $@
+ cmd_ar_builtin = rm -f $@; \
+ $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(filter $(real-obj-y), $^)
-$(builtin-target): $(obj-y) FORCE
- $(call if_changed,link_o_target)
+$(builtin-target): $(real-obj-y) FORCE
+ $(call if_changed,ar_builtin)
targets += $(builtin-target)
endif # builtin-target
@@ -499,11 +479,8 @@ $(modorder-target): $(subdir-ym) FORCE
ifdef lib-target
quiet_cmd_link_l_target = AR $@
-ifdef CONFIG_THIN_ARCHIVES
- cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y)
-else
- cmd_link_l_target = rm -f $@; $(AR) rcs$(KBUILD_ARFLAGS) $@ $(lib-y)
-endif
+# lib target archives do get a symbol table and index
+cmd_link_l_target = rm -f $@; $(AR) rcsTP$(KBUILD_ARFLAGS) $@ $(lib-y)
$(lib-target): $(lib-y) FORCE
$(call if_changed,link_l_target)
@@ -549,22 +526,8 @@ $($(subst $(obj)/,,$(@:.o=-objs))) \
$($(subst $(obj)/,,$(@:.o=-y))) \
$($(subst $(obj)/,,$(@:.o=-m)))), $^)
-cmd_link_multi-link = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
-
-ifdef CONFIG_THIN_ARCHIVES
- quiet_cmd_link_multi-y = AR $@
- cmd_link_multi-y = rm -f $@; $(AR) rcSTP$(KBUILD_ARFLAGS) $@ $(link_multi_deps)
-else
- quiet_cmd_link_multi-y = LD $@
- cmd_link_multi-y = $(cmd_link_multi-link)
-endif
-
quiet_cmd_link_multi-m = LD [M] $@
-cmd_link_multi-m = $(cmd_link_multi-link)
-
-$(multi-used-y): FORCE
- $(call if_changed,link_multi-y)
-$(call multi_depend, $(multi-used-y), .o, -objs -y)
+cmd_link_multi-m = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalysis)
$(multi-used-m): FORCE
$(call if_changed,link_multi-m)
@@ -572,7 +535,7 @@ $(multi-used-m): FORCE
$(cmd_undef_syms); } > $(MODVERDIR)/$(@F:.o=.mod)
$(call multi_depend, $(multi-used-m), .o, -objs -y -m)
-targets += $(multi-used-y) $(multi-used-m)
+targets += $(multi-used-m)
targets := $(filter-out $(PHONY), $(targets))
# Descending