diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-03 18:51:22 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-04-03 18:51:22 -0400 |
commit | 3b24b83763e72a6c1e728100104fd99aa83a7b3b (patch) | |
tree | bd493c47804a9fe1e85ee41c2532b4748fca0b25 /Makefile | |
parent | 0734e00ef9e48e78c5c3ce1648572f160d07e323 (diff) | |
parent | a95b37e20db9a2b05354eec009b2188523a21c8e (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 'Makefile')
-rw-r--r-- | Makefile | 89 |
1 files changed, 49 insertions, 40 deletions
@@ -35,7 +35,7 @@ unexport GREP_OPTIONS | |||
35 | # Most importantly: sub-Makefiles should only ever modify files in | 35 | # Most importantly: sub-Makefiles should only ever modify files in |
36 | # their own directory. If in some directory we have a dependency on | 36 | # their own directory. If in some directory we have a dependency on |
37 | # a file in another dir (which doesn't happen often, but it's often | 37 | # a file in another dir (which doesn't happen often, but it's often |
38 | # unavoidable when linking the built-in.o targets which finally | 38 | # unavoidable when linking the built-in.a targets which finally |
39 | # turn into vmlinux), we will call a sub make in that other dir, and | 39 | # turn into vmlinux), we will call a sub make in that other dir, and |
40 | # after that we are sure that everything which is in that other dir | 40 | # after that we are sure that everything which is in that other dir |
41 | # is now up to date. | 41 | # is now up to date. |
@@ -220,7 +220,8 @@ export srctree objtree VPATH | |||
220 | version_h := include/generated/uapi/linux/version.h | 220 | version_h := include/generated/uapi/linux/version.h |
221 | old_version_h := include/linux/version.h | 221 | old_version_h := include/linux/version.h |
222 | 222 | ||
223 | no-dot-config-targets := clean mrproper distclean \ | 223 | clean-targets := %clean mrproper cleandocs |
224 | no-dot-config-targets := $(clean-targets) \ | ||
224 | cscope gtags TAGS tags help% %docs check% coccicheck \ | 225 | cscope gtags TAGS tags help% %docs check% coccicheck \ |
225 | $(version_h) headers_% archheaders archscripts \ | 226 | $(version_h) headers_% archheaders archscripts \ |
226 | kernelversion %src-pkg | 227 | kernelversion %src-pkg |
@@ -243,6 +244,14 @@ ifeq ($(KBUILD_EXTMOD),) | |||
243 | endif | 244 | endif |
244 | endif | 245 | endif |
245 | endif | 246 | endif |
247 | |||
248 | # For "make -j clean all", "make -j mrproper defconfig all", etc. | ||
249 | ifneq ($(filter $(clean-targets),$(MAKECMDGOALS)),) | ||
250 | ifneq ($(filter-out $(clean-targets),$(MAKECMDGOALS)),) | ||
251 | mixed-targets := 1 | ||
252 | endif | ||
253 | endif | ||
254 | |||
246 | # install and modules_install need also be processed one by one | 255 | # install and modules_install need also be processed one by one |
247 | ifneq ($(filter install,$(MAKECMDGOALS)),) | 256 | ifneq ($(filter install,$(MAKECMDGOALS)),) |
248 | ifneq ($(filter modules_install,$(MAKECMDGOALS)),) | 257 | ifneq ($(filter modules_install,$(MAKECMDGOALS)),) |
@@ -418,6 +427,7 @@ KBUILD_CFLAGS_KERNEL := | |||
418 | KBUILD_AFLAGS_MODULE := -DMODULE | 427 | KBUILD_AFLAGS_MODULE := -DMODULE |
419 | KBUILD_CFLAGS_MODULE := -DMODULE | 428 | KBUILD_CFLAGS_MODULE := -DMODULE |
420 | KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds | 429 | KBUILD_LDFLAGS_MODULE := -T $(srctree)/scripts/module-common.lds |
430 | LDFLAGS := | ||
421 | GCC_PLUGINS_CFLAGS := | 431 | GCC_PLUGINS_CFLAGS := |
422 | 432 | ||
423 | export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC | 433 | export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC |
@@ -556,14 +566,6 @@ endif | |||
556 | export KBUILD_MODULES KBUILD_BUILTIN | 566 | export KBUILD_MODULES KBUILD_BUILTIN |
557 | 567 | ||
558 | ifeq ($(KBUILD_EXTMOD),) | 568 | ifeq ($(KBUILD_EXTMOD),) |
559 | # Additional helpers built in scripts/ | ||
560 | # Carefully list dependencies so we do not try to build scripts twice | ||
561 | # in parallel | ||
562 | PHONY += scripts | ||
563 | scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \ | ||
564 | asm-generic gcc-plugins | ||
565 | $(Q)$(MAKE) $(build)=$(@) | ||
566 | |||
567 | # Objects we will link into vmlinux / subdirs we need to visit | 569 | # Objects we will link into vmlinux / subdirs we need to visit |
568 | init-y := init/ | 570 | init-y := init/ |
569 | drivers-y := drivers/ sound/ firmware/ | 571 | drivers-y := drivers/ sound/ firmware/ |
@@ -611,13 +613,6 @@ else | |||
611 | include/config/auto.conf: ; | 613 | include/config/auto.conf: ; |
612 | endif # $(dot-config) | 614 | endif # $(dot-config) |
613 | 615 | ||
614 | # For the kernel to actually contain only the needed exported symbols, | ||
615 | # we have to build modules as well to determine what those symbols are. | ||
616 | # (this can be evaluated only once include/config/auto.conf has been included) | ||
617 | ifdef CONFIG_TRIM_UNUSED_KSYMS | ||
618 | KBUILD_MODULES := 1 | ||
619 | endif | ||
620 | |||
621 | # The all: target is the default when no target is given on the | 616 | # The all: target is the default when no target is given on the |
622 | # command line. | 617 | # command line. |
623 | # This allow a user to issue only 'make' to build a kernel including modules | 618 | # This allow a user to issue only 'make' to build a kernel including modules |
@@ -984,13 +979,13 @@ vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \ | |||
984 | vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \ | 979 | vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \ |
985 | $(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-)))) | 980 | $(init-) $(core-) $(drivers-) $(net-) $(libs-) $(virt-)))) |
986 | 981 | ||
987 | init-y := $(patsubst %/, %/built-in.o, $(init-y)) | 982 | init-y := $(patsubst %/, %/built-in.a, $(init-y)) |
988 | core-y := $(patsubst %/, %/built-in.o, $(core-y)) | 983 | core-y := $(patsubst %/, %/built-in.a, $(core-y)) |
989 | drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y)) | 984 | drivers-y := $(patsubst %/, %/built-in.a, $(drivers-y)) |
990 | net-y := $(patsubst %/, %/built-in.o, $(net-y)) | 985 | net-y := $(patsubst %/, %/built-in.a, $(net-y)) |
991 | libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) | 986 | libs-y1 := $(patsubst %/, %/lib.a, $(libs-y)) |
992 | libs-y2 := $(filter-out %.a, $(patsubst %/, %/built-in.o, $(libs-y))) | 987 | libs-y2 := $(patsubst %/, %/built-in.a, $(filter-out %.a, $(libs-y))) |
993 | virt-y := $(patsubst %/, %/built-in.o, $(virt-y)) | 988 | virt-y := $(patsubst %/, %/built-in.a, $(virt-y)) |
994 | 989 | ||
995 | # Externally visible symbols (used by link-vmlinux.sh) | 990 | # Externally visible symbols (used by link-vmlinux.sh) |
996 | export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) | 991 | export KBUILD_VMLINUX_INIT := $(head-y) $(init-y) |
@@ -1003,25 +998,26 @@ export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Doc | |||
1003 | 998 | ||
1004 | vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) | 999 | vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) |
1005 | 1000 | ||
1006 | # Include targets which we want to execute sequentially if the rest of the | 1001 | # Recurse until adjust_autoksyms.sh is satisfied |
1007 | # kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be | 1002 | PHONY += autoksyms_recursive |
1008 | # evaluated more than once. | 1003 | autoksyms_recursive: $(vmlinux-deps) |
1009 | PHONY += vmlinux_prereq | ||
1010 | vmlinux_prereq: $(vmlinux-deps) FORCE | ||
1011 | ifdef CONFIG_HEADERS_CHECK | ||
1012 | $(Q)$(MAKE) -f $(srctree)/Makefile headers_check | ||
1013 | endif | ||
1014 | ifdef CONFIG_GDB_SCRIPTS | ||
1015 | $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) | ||
1016 | endif | ||
1017 | ifdef CONFIG_TRIM_UNUSED_KSYMS | 1004 | ifdef CONFIG_TRIM_UNUSED_KSYMS |
1018 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ | 1005 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ |
1019 | "$(MAKE) -f $(srctree)/Makefile vmlinux" | 1006 | "$(MAKE) -f $(srctree)/Makefile vmlinux" |
1020 | endif | 1007 | endif |
1021 | 1008 | ||
1022 | # standalone target for easier testing | 1009 | # For the kernel to actually contain only the needed exported symbols, |
1023 | include/generated/autoksyms.h: FORCE | 1010 | # we have to build modules as well to determine what those symbols are. |
1024 | $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh true | 1011 | # (this can be evaluated only once include/config/auto.conf has been included) |
1012 | ifdef CONFIG_TRIM_UNUSED_KSYMS | ||
1013 | KBUILD_MODULES := 1 | ||
1014 | endif | ||
1015 | |||
1016 | autoksyms_h := $(if $(CONFIG_TRIM_UNUSED_KSYMS), include/generated/autoksyms.h) | ||
1017 | |||
1018 | $(autoksyms_h): | ||
1019 | $(Q)mkdir -p $(dir $@) | ||
1020 | $(Q)touch $@ | ||
1025 | 1021 | ||
1026 | ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) | 1022 | ARCH_POSTLINK := $(wildcard $(srctree)/arch/$(SRCARCH)/Makefile.postlink) |
1027 | 1023 | ||
@@ -1030,7 +1026,13 @@ cmd_link-vmlinux = \ | |||
1030 | $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ | 1026 | $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ; \ |
1031 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) | 1027 | $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) |
1032 | 1028 | ||
1033 | vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE | 1029 | vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE |
1030 | ifdef CONFIG_HEADERS_CHECK | ||
1031 | $(Q)$(MAKE) -f $(srctree)/Makefile headers_check | ||
1032 | endif | ||
1033 | ifdef CONFIG_GDB_SCRIPTS | ||
1034 | $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) | ||
1035 | endif | ||
1034 | +$(call if_changed,link-vmlinux) | 1036 | +$(call if_changed,link-vmlinux) |
1035 | 1037 | ||
1036 | # Build samples along the rest of the kernel | 1038 | # Build samples along the rest of the kernel |
@@ -1060,6 +1062,13 @@ endef | |||
1060 | include/config/kernel.release: include/config/auto.conf FORCE | 1062 | include/config/kernel.release: include/config/auto.conf FORCE |
1061 | $(call filechk,kernel.release) | 1063 | $(call filechk,kernel.release) |
1062 | 1064 | ||
1065 | # Additional helpers built in scripts/ | ||
1066 | # Carefully list dependencies so we do not try to build scripts twice | ||
1067 | # in parallel | ||
1068 | PHONY += scripts | ||
1069 | scripts: scripts_basic include/config/auto.conf include/config/tristate.conf \ | ||
1070 | asm-generic gcc-plugins $(autoksyms_h) | ||
1071 | $(Q)$(MAKE) $(build)=$(@) | ||
1063 | 1072 | ||
1064 | # Things we need to do before we recursively start building the kernel | 1073 | # Things we need to do before we recursively start building the kernel |
1065 | # or the modules are listed in "prepare". | 1074 | # or the modules are listed in "prepare". |
@@ -1088,7 +1097,7 @@ endif | |||
1088 | # that need to depend on updated CONFIG_* values can be checked here. | 1097 | # that need to depend on updated CONFIG_* values can be checked here. |
1089 | prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic | 1098 | prepare2: prepare3 prepare-compiler-check outputmakefile asm-generic |
1090 | 1099 | ||
1091 | prepare1: prepare2 $(version_h) include/generated/utsrelease.h \ | 1100 | prepare1: prepare2 $(version_h) $(autoksyms_h) include/generated/utsrelease.h \ |
1092 | include/config/auto.conf | 1101 | include/config/auto.conf |
1093 | $(cmd_crmodverdir) | 1102 | $(cmd_crmodverdir) |
1094 | 1103 | ||
@@ -1327,7 +1336,7 @@ endif # CONFIG_MODULES | |||
1327 | # make distclean Remove editor backup files, patch leftover files and the like | 1336 | # make distclean Remove editor backup files, patch leftover files and the like |
1328 | 1337 | ||
1329 | # Directories & files removed with 'make clean' | 1338 | # Directories & files removed with 'make clean' |
1330 | CLEAN_DIRS += $(MODVERDIR) | 1339 | CLEAN_DIRS += $(MODVERDIR) include/ksym |
1331 | 1340 | ||
1332 | # Directories & files removed with 'make mrproper' | 1341 | # Directories & files removed with 'make mrproper' |
1333 | MRPROPER_DIRS += include/config usr/include include/generated \ | 1342 | MRPROPER_DIRS += include/config usr/include include/generated \ |