Commit 3b7b3e6ec5f56118046594d3c62469e7d1d0aadd
Exists in
ti-lsk-linux-4.1.y
and in
10 other branches
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild
Pull kbuild updates from Michal Marek: - make clean also considers $(extra-m) and $(extra-) to be consistent - cleanup and fixes in scripts/Makefile.host - allow to override the name of the Python 2 executable with make PYTHON=... (only needed for ia64 in practice) - option to split debugingo into *.dwo files to save disk space if the compiler supports it (CONFIG_DEBUG_INFO_SPLIT) - option to use dwarf4 debuginfo if the compiler supports it (CONFIG_DEBUG_INFO_DWARF4) - fix for disabling certain warnings with clang - fix for unneeded rebuild with dash when a command contains backslashes * 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild: kbuild: Fix handling of backslashes in *.cmd files kbuild, LLVMLinux: Supress warnings unless W=1-3 Kbuild: Add a option to enable dwarf4 v2 kbuild: Support split debug info v4 kbuild: allow to override Python command name kbuild: clean-up and bug fix of scripts/Makefile.host kbuild: clean up scripts/Makefile.host kbuild: drop shared library support from Makefile.host kbuild: fix a bug of C++ host program handling kbuild: fix a typo in scripts/Makefile.host scripts/Makefile.clean: clean also $(extra-m) and $(extra-)
Showing 9 changed files Side-by-side Diff
.gitignore
Documentation/kbuild/makefiles.txt
... | ... | @@ -23,11 +23,10 @@ |
23 | 23 | === 4 Host Program support |
24 | 24 | --- 4.1 Simple Host Program |
25 | 25 | --- 4.2 Composite Host Programs |
26 | - --- 4.3 Defining shared libraries | |
27 | - --- 4.4 Using C++ for host programs | |
28 | - --- 4.5 Controlling compiler options for host programs | |
29 | - --- 4.6 When host programs are actually built | |
30 | - --- 4.7 Using hostprogs-$(CONFIG_FOO) | |
26 | + --- 4.3 Using C++ for host programs | |
27 | + --- 4.4 Controlling compiler options for host programs | |
28 | + --- 4.5 When host programs are actually built | |
29 | + --- 4.6 Using hostprogs-$(CONFIG_FOO) | |
31 | 30 | |
32 | 31 | === 5 Kbuild clean infrastructure |
33 | 32 | |
34 | 33 | |
... | ... | @@ -643,30 +642,8 @@ |
643 | 642 | Finally, the two .o files are linked to the executable, lxdialog. |
644 | 643 | Note: The syntax <executable>-y is not permitted for host-programs. |
645 | 644 | |
646 | ---- 4.3 Defining shared libraries | |
645 | +--- 4.3 Using C++ for host programs | |
647 | 646 | |
648 | - Objects with extension .so are considered shared libraries, and | |
649 | - will be compiled as position independent objects. | |
650 | - Kbuild provides support for shared libraries, but the usage | |
651 | - shall be restricted. | |
652 | - In the following example the libkconfig.so shared library is used | |
653 | - to link the executable conf. | |
654 | - | |
655 | - Example: | |
656 | - #scripts/kconfig/Makefile | |
657 | - hostprogs-y := conf | |
658 | - conf-objs := conf.o libkconfig.so | |
659 | - libkconfig-objs := expr.o type.o | |
660 | - | |
661 | - Shared libraries always require a corresponding -objs line, and | |
662 | - in the example above the shared library libkconfig is composed by | |
663 | - the two objects expr.o and type.o. | |
664 | - expr.o and type.o will be built as position independent code and | |
665 | - linked as a shared library libkconfig.so. C++ is not supported for | |
666 | - shared libraries. | |
667 | - | |
668 | ---- 4.4 Using C++ for host programs | |
669 | - | |
670 | 647 | kbuild offers support for host programs written in C++. This was |
671 | 648 | introduced solely to support kconfig, and is not recommended |
672 | 649 | for general use. |
... | ... | @@ -688,7 +665,7 @@ |
688 | 665 | qconf-cxxobjs := qconf.o |
689 | 666 | qconf-objs := check.o |
690 | 667 | |
691 | ---- 4.5 Controlling compiler options for host programs | |
668 | +--- 4.4 Controlling compiler options for host programs | |
692 | 669 | |
693 | 670 | When compiling host programs, it is possible to set specific flags. |
694 | 671 | The programs will always be compiled utilising $(HOSTCC) passed |
... | ... | @@ -716,7 +693,7 @@ |
716 | 693 | When linking qconf, it will be passed the extra option |
717 | 694 | "-L$(QTDIR)/lib". |
718 | 695 | |
719 | ---- 4.6 When host programs are actually built | |
696 | +--- 4.5 When host programs are actually built | |
720 | 697 | |
721 | 698 | Kbuild will only build host-programs when they are referenced |
722 | 699 | as a prerequisite. |
... | ... | @@ -747,7 +724,7 @@ |
747 | 724 | This will tell kbuild to build lxdialog even if not referenced in |
748 | 725 | any rule. |
749 | 726 | |
750 | ---- 4.7 Using hostprogs-$(CONFIG_FOO) | |
727 | +--- 4.6 Using hostprogs-$(CONFIG_FOO) | |
751 | 728 | |
752 | 729 | A typical pattern in a Kbuild file looks like this: |
753 | 730 |
Makefile
... | ... | @@ -372,6 +372,7 @@ |
372 | 372 | INSTALLKERNEL := installkernel |
373 | 373 | DEPMOD = /sbin/depmod |
374 | 374 | PERL = perl |
375 | +PYTHON = python | |
375 | 376 | CHECK = sparse |
376 | 377 | |
377 | 378 | CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \ |
... | ... | @@ -422,7 +423,7 @@ |
422 | 423 | export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION |
423 | 424 | export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC |
424 | 425 | export CPP AR NM STRIP OBJCOPY OBJDUMP |
425 | -export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE | |
426 | +export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE | |
426 | 427 | export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS |
427 | 428 | |
428 | 429 | export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS |
... | ... | @@ -687,6 +688,7 @@ |
687 | 688 | # source of a reference will be _MergedGlobals and not on of the whitelisted names. |
688 | 689 | # See modpost pattern 2 |
689 | 690 | KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,) |
691 | +KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior) | |
690 | 692 | else |
691 | 693 | |
692 | 694 | # This warning generated too much noise in a regular build. |
693 | 695 | |
694 | 696 | |
... | ... | @@ -710,9 +712,16 @@ |
710 | 712 | KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments) |
711 | 713 | |
712 | 714 | ifdef CONFIG_DEBUG_INFO |
715 | +ifdef CONFIG_DEBUG_INFO_SPLIT | |
716 | +KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g) | |
717 | +else | |
713 | 718 | KBUILD_CFLAGS += -g |
719 | +endif | |
714 | 720 | KBUILD_AFLAGS += -Wa,-gdwarf-2 |
715 | 721 | endif |
722 | +ifdef CONFIG_DEBUG_INFO_DWARF4 | |
723 | +KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,) | |
724 | +endif | |
716 | 725 | |
717 | 726 | ifdef CONFIG_DEBUG_INFO_REDUCED |
718 | 727 | KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \ |
... | ... | @@ -1398,6 +1407,7 @@ |
1398 | 1407 | @find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \ |
1399 | 1408 | \( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \ |
1400 | 1409 | -o -name '*.ko.*' \ |
1410 | + -o -name '*.dwo' \ | |
1401 | 1411 | -o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \ |
1402 | 1412 | -o -name '*.symtypes' -o -name 'modules.order' \ |
1403 | 1413 | -o -name modules.builtin -o -name '.tmp_*.o.*' \ |
arch/ia64/Makefile
... | ... | @@ -76,7 +76,7 @@ |
76 | 76 | $(Q)$(MAKE) $(build)=$(boot) $@ |
77 | 77 | |
78 | 78 | unwcheck: vmlinux |
79 | - -$(Q)READELF=$(READELF) python $(srctree)/arch/ia64/scripts/unwcheck.py $< | |
79 | + -$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $< | |
80 | 80 | |
81 | 81 | archclean: |
82 | 82 | $(Q)$(MAKE) $(clean)=$(boot) |
lib/Kconfig.debug
... | ... | @@ -143,6 +143,30 @@ |
143 | 143 | DEBUG_INFO build and compile times are reduced too. |
144 | 144 | Only works with newer gcc versions. |
145 | 145 | |
146 | +config DEBUG_INFO_SPLIT | |
147 | + bool "Produce split debuginfo in .dwo files" | |
148 | + depends on DEBUG_INFO | |
149 | + help | |
150 | + Generate debug info into separate .dwo files. This significantly | |
151 | + reduces the build directory size for builds with DEBUG_INFO, | |
152 | + because it stores the information only once on disk in .dwo | |
153 | + files instead of multiple times in object files and executables. | |
154 | + In addition the debug information is also compressed. | |
155 | + | |
156 | + Requires recent gcc (4.7+) and recent gdb/binutils. | |
157 | + Any tool that packages or reads debug information would need | |
158 | + to know about the .dwo files and include them. | |
159 | + Incompatible with older versions of ccache. | |
160 | + | |
161 | +config DEBUG_INFO_DWARF4 | |
162 | + bool "Generate dwarf4 debuginfo" | |
163 | + depends on DEBUG_INFO | |
164 | + help | |
165 | + Generate dwarf4 debug info. This requires recent versions | |
166 | + of gcc and gdb. It makes the debug information larger. | |
167 | + But it significantly improves the success of resolving | |
168 | + variables in gdb on optimized code. | |
169 | + | |
146 | 170 | config ENABLE_WARN_DEPRECATED |
147 | 171 | bool "Enable __deprecated logic" |
148 | 172 | default y |
scripts/Kbuild.include
... | ... | @@ -215,11 +215,13 @@ |
215 | 215 | arg-check = $(if $(strip $(cmd_$@)),,1) |
216 | 216 | endif |
217 | 217 | |
218 | -# >'< substitution is for echo to work, | |
219 | -# >$< substitution to preserve $ when reloading .cmd file | |
220 | -# note: when using inline perl scripts [perl -e '...$$t=1;...'] | |
221 | -# in $(cmd_xxx) double $$ your perl vars | |
222 | -make-cmd = $(subst \\,\\\\,$(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1)))))) | |
218 | +# Replace >$< with >$$< to preserve $ when reloading the .cmd file | |
219 | +# (needed for make) | |
220 | +# Replace >#< with >\#< to avoid starting a comment in the .cmd file | |
221 | +# (needed for make) | |
222 | +# Replace >'< with >'\''< to be able to enclose the whole string in '...' | |
223 | +# (needed for the shell) | |
224 | +make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1))))) | |
223 | 225 | |
224 | 226 | # Find any prerequisites that is newer than target or that does not exist. |
225 | 227 | # PHONY targets skipped in both cases. |
... | ... | @@ -230,7 +232,7 @@ |
230 | 232 | if_changed = $(if $(strip $(any-prereq) $(arg-check)), \ |
231 | 233 | @set -e; \ |
232 | 234 | $(echo-cmd) $(cmd_$(1)); \ |
233 | - echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) | |
235 | + printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd) | |
234 | 236 | |
235 | 237 | # Execute the command and also postprocess generated .d dependencies file. |
236 | 238 | if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \ |
scripts/Makefile.clean
... | ... | @@ -40,8 +40,8 @@ |
40 | 40 | # build a list of files to remove, usually relative to the current |
41 | 41 | # directory |
42 | 42 | |
43 | -__clean-files := $(extra-y) $(always) \ | |
44 | - $(targets) $(clean-files) \ | |
43 | +__clean-files := $(extra-y) $(extra-m) $(extra-) \ | |
44 | + $(always) $(targets) $(clean-files) \ | |
45 | 45 | $(host-progs) \ |
46 | 46 | $(hostprogs-y) $(hostprogs-m) $(hostprogs-) |
47 | 47 |
scripts/Makefile.extrawarn
... | ... | @@ -26,16 +26,6 @@ |
26 | 26 | warning-1 += $(call cc-option, -Wunused-but-set-variable) |
27 | 27 | warning-1 += $(call cc-disable-warning, missing-field-initializers) |
28 | 28 | |
29 | -# Clang | |
30 | -warning-1 += $(call cc-disable-warning, initializer-overrides) | |
31 | -warning-1 += $(call cc-disable-warning, unused-value) | |
32 | -warning-1 += $(call cc-disable-warning, format) | |
33 | -warning-1 += $(call cc-disable-warning, unknown-warning-option) | |
34 | -warning-1 += $(call cc-disable-warning, sign-compare) | |
35 | -warning-1 += $(call cc-disable-warning, format-zero-length) | |
36 | -warning-1 += $(call cc-disable-warning, uninitialized) | |
37 | -warning-1 += $(call cc-option, -fcatch-undefined-behavior) | |
38 | - | |
39 | 29 | warning-2 := -Waggregate-return |
40 | 30 | warning-2 += -Wcast-align |
41 | 31 | warning-2 += -Wdisabled-optimization |
... | ... | @@ -64,5 +54,16 @@ |
64 | 54 | endif |
65 | 55 | |
66 | 56 | KBUILD_CFLAGS += $(warning) |
57 | +else | |
58 | + | |
59 | +ifeq ($(COMPILER),clang) | |
60 | +KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides) | |
61 | +KBUILD_CFLAGS += $(call cc-disable-warning, unused-value) | |
62 | +KBUILD_CFLAGS += $(call cc-disable-warning, format) | |
63 | +KBUILD_CFLAGS += $(call cc-disable-warning, unknown-warning-option) | |
64 | +KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare) | |
65 | +KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length) | |
66 | +KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized) | |
67 | +endif | |
67 | 68 | endif |
scripts/Makefile.host
... | ... | @@ -20,21 +20,12 @@ |
20 | 20 | # Will compile qconf as a C++ program, and menu as a C program. |
21 | 21 | # They are linked as C++ code to the executable qconf |
22 | 22 | |
23 | -# hostprogs-y := conf | |
24 | -# conf-objs := conf.o libkconfig.so | |
25 | -# libkconfig-objs := expr.o type.o | |
26 | -# Will create a shared library named libkconfig.so that consists of | |
27 | -# expr.o and type.o (they are both compiled as C code and the object files | |
28 | -# are made as position independent code). | |
29 | -# conf.c is compiled as a C program, and conf.o is linked together with | |
30 | -# libkconfig.so as the executable conf. | |
31 | -# Note: Shared libraries consisting of C++ files are not supported | |
32 | - | |
33 | 23 | __hostprogs := $(sort $(hostprogs-y) $(hostprogs-m)) |
34 | 24 | |
35 | 25 | # C code |
36 | 26 | # Executables compiled from a single .c file |
37 | -host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m))) | |
27 | +host-csingle := $(foreach m,$(__hostprogs), \ | |
28 | + $(if $($(m)-objs)$($(m)-cxxobjs),,$(m))) | |
38 | 29 | |
39 | 30 | # C executables linked based on several .o files |
40 | 31 | host-cmulti := $(foreach m,$(__hostprogs),\ |
41 | 32 | |
42 | 33 | |
... | ... | @@ -44,33 +35,17 @@ |
44 | 35 | host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs))) |
45 | 36 | |
46 | 37 | # C++ code |
47 | -# C++ executables compiled from at least on .cc file | |
38 | +# C++ executables compiled from at least one .cc file | |
48 | 39 | # and zero or more .c files |
49 | 40 | host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m))) |
50 | 41 | |
51 | 42 | # C++ Object (.o) files compiled from .cc files |
52 | 43 | host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs))) |
53 | 44 | |
54 | -# Shared libaries (only .c supported) | |
55 | -# Shared libraries (.so) - all .so files referenced in "xxx-objs" | |
56 | -host-cshlib := $(sort $(filter %.so, $(host-cobjs))) | |
57 | -# Remove .so files from "xxx-objs" | |
58 | -host-cobjs := $(filter-out %.so,$(host-cobjs)) | |
59 | - | |
60 | -#Object (.o) files used by the shared libaries | |
61 | -host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs)))) | |
62 | - | |
63 | 45 | # output directory for programs/.o files |
64 | -# hostprogs-y := tools/build may have been specified. Retrieve directory | |
65 | -host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f)))) | |
66 | -# directory of .o files from prog-objs notation | |
67 | -host-objdirs += $(foreach f,$(host-cmulti), \ | |
68 | - $(foreach m,$($(f)-objs), \ | |
69 | - $(if $(dir $(m)),$(dir $(m))))) | |
70 | -# directory of .o files from prog-cxxobjs notation | |
71 | -host-objdirs += $(foreach f,$(host-cxxmulti), \ | |
72 | - $(foreach m,$($(f)-cxxobjs), \ | |
73 | - $(if $(dir $(m)),$(dir $(m))))) | |
46 | +# hostprogs-y := tools/build may have been specified. | |
47 | +# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation | |
48 | +host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs)) | |
74 | 49 | |
75 | 50 | host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs)))) |
76 | 51 | |
... | ... | @@ -81,8 +56,6 @@ |
81 | 56 | host-cobjs := $(addprefix $(obj)/,$(host-cobjs)) |
82 | 57 | host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti)) |
83 | 58 | host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs)) |
84 | -host-cshlib := $(addprefix $(obj)/,$(host-cshlib)) | |
85 | -host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs)) | |
86 | 59 | host-objdirs := $(addprefix $(obj)/,$(host-objdirs)) |
87 | 60 | |
88 | 61 | obj-dirs += $(host-objdirs) |
... | ... | @@ -123,7 +96,7 @@ |
123 | 96 | cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \ |
124 | 97 | $(addprefix $(obj)/,$($(@F)-objs)) \ |
125 | 98 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) |
126 | -$(host-cmulti): $(obj)/%: $(host-cobjs) $(host-cshlib) FORCE | |
99 | +$(host-cmulti): $(obj)/%: $(host-cobjs) FORCE | |
127 | 100 | $(call if_changed,host-cmulti) |
128 | 101 | |
129 | 102 | # Create .o file from a single .c file |
... | ... | @@ -140,7 +113,7 @@ |
140 | 113 | $(foreach o,objs cxxobjs,\ |
141 | 114 | $(addprefix $(obj)/,$($(@F)-$(o)))) \ |
142 | 115 | $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) |
143 | -$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE | |
116 | +$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) FORCE | |
144 | 117 | $(call if_changed,host-cxxmulti) |
145 | 118 | |
146 | 119 | # Create .o file from a single .cc (C++) file |
147 | 120 | |
... | ... | @@ -149,22 +122,6 @@ |
149 | 122 | $(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE |
150 | 123 | $(call if_changed_dep,host-cxxobjs) |
151 | 124 | |
152 | -# Compile .c file, create position independent .o file | |
153 | -# host-cshobjs -> .o | |
154 | -quiet_cmd_host-cshobjs = HOSTCC -fPIC $@ | |
155 | - cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $< | |
156 | -$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE | |
157 | - $(call if_changed_dep,host-cshobjs) | |
158 | - | |
159 | -# Link a shared library, based on position independent .o files | |
160 | -# *.o -> .so shared library (host-cshlib) | |
161 | -quiet_cmd_host-cshlib = HOSTLLD -shared $@ | |
162 | - cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \ | |
163 | - $(addprefix $(obj)/,$($(@F:.so=-objs))) \ | |
164 | - $(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F)) | |
165 | -$(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE | |
166 | - $(call if_changed,host-cshlib) | |
167 | - | |
168 | 125 | targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\ |
169 | - $(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs) | |
126 | + $(host-cxxmulti) $(host-cxxobjs) |