mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-01-11 07:39:47 +00:00
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-)
This commit is contained in:
commit
3b7b3e6ec5
1
.gitignore
vendored
1
.gitignore
vendored
@ -34,6 +34,7 @@
|
||||
*.gcno
|
||||
modules.builtin
|
||||
Module.symvers
|
||||
*.dwo
|
||||
|
||||
#
|
||||
# Top-level generic files
|
||||
|
@ -23,11 +23,10 @@ This document describes the Linux kernel Makefiles.
|
||||
=== 4 Host Program support
|
||||
--- 4.1 Simple Host Program
|
||||
--- 4.2 Composite Host Programs
|
||||
--- 4.3 Defining shared libraries
|
||||
--- 4.4 Using C++ for host programs
|
||||
--- 4.5 Controlling compiler options for host programs
|
||||
--- 4.6 When host programs are actually built
|
||||
--- 4.7 Using hostprogs-$(CONFIG_FOO)
|
||||
--- 4.3 Using C++ for host programs
|
||||
--- 4.4 Controlling compiler options for host programs
|
||||
--- 4.5 When host programs are actually built
|
||||
--- 4.6 Using hostprogs-$(CONFIG_FOO)
|
||||
|
||||
=== 5 Kbuild clean infrastructure
|
||||
|
||||
@ -643,29 +642,7 @@ Both possibilities are described in the following.
|
||||
Finally, the two .o files are linked to the executable, lxdialog.
|
||||
Note: The syntax <executable>-y is not permitted for host-programs.
|
||||
|
||||
--- 4.3 Defining shared libraries
|
||||
|
||||
Objects with extension .so are considered shared libraries, and
|
||||
will be compiled as position independent objects.
|
||||
Kbuild provides support for shared libraries, but the usage
|
||||
shall be restricted.
|
||||
In the following example the libkconfig.so shared library is used
|
||||
to link the executable conf.
|
||||
|
||||
Example:
|
||||
#scripts/kconfig/Makefile
|
||||
hostprogs-y := conf
|
||||
conf-objs := conf.o libkconfig.so
|
||||
libkconfig-objs := expr.o type.o
|
||||
|
||||
Shared libraries always require a corresponding -objs line, and
|
||||
in the example above the shared library libkconfig is composed by
|
||||
the two objects expr.o and type.o.
|
||||
expr.o and type.o will be built as position independent code and
|
||||
linked as a shared library libkconfig.so. C++ is not supported for
|
||||
shared libraries.
|
||||
|
||||
--- 4.4 Using C++ for host programs
|
||||
--- 4.3 Using C++ for host programs
|
||||
|
||||
kbuild offers support for host programs written in C++. This was
|
||||
introduced solely to support kconfig, and is not recommended
|
||||
@ -688,7 +665,7 @@ Both possibilities are described in the following.
|
||||
qconf-cxxobjs := qconf.o
|
||||
qconf-objs := check.o
|
||||
|
||||
--- 4.5 Controlling compiler options for host programs
|
||||
--- 4.4 Controlling compiler options for host programs
|
||||
|
||||
When compiling host programs, it is possible to set specific flags.
|
||||
The programs will always be compiled utilising $(HOSTCC) passed
|
||||
@ -716,7 +693,7 @@ Both possibilities are described in the following.
|
||||
When linking qconf, it will be passed the extra option
|
||||
"-L$(QTDIR)/lib".
|
||||
|
||||
--- 4.6 When host programs are actually built
|
||||
--- 4.5 When host programs are actually built
|
||||
|
||||
Kbuild will only build host-programs when they are referenced
|
||||
as a prerequisite.
|
||||
@ -747,7 +724,7 @@ Both possibilities are described in the following.
|
||||
This will tell kbuild to build lxdialog even if not referenced in
|
||||
any rule.
|
||||
|
||||
--- 4.7 Using hostprogs-$(CONFIG_FOO)
|
||||
--- 4.6 Using hostprogs-$(CONFIG_FOO)
|
||||
|
||||
A typical pattern in a Kbuild file looks like this:
|
||||
|
||||
|
12
Makefile
12
Makefile
@ -372,6 +372,7 @@ GENKSYMS = scripts/genksyms/genksyms
|
||||
INSTALLKERNEL := installkernel
|
||||
DEPMOD = /sbin/depmod
|
||||
PERL = perl
|
||||
PYTHON = python
|
||||
CHECK = sparse
|
||||
|
||||
CHECKFLAGS := -D__linux__ -Dlinux -D__STDC__ -Dunix -D__unix__ \
|
||||
@ -422,7 +423,7 @@ KERNELVERSION = $(VERSION)$(if $(PATCHLEVEL),.$(PATCHLEVEL)$(if $(SUBLEVEL),.$(S
|
||||
export VERSION PATCHLEVEL SUBLEVEL KERNELRELEASE KERNELVERSION
|
||||
export ARCH SRCARCH CONFIG_SHELL HOSTCC HOSTCFLAGS CROSS_COMPILE AS LD CC
|
||||
export CPP AR NM STRIP OBJCOPY OBJDUMP
|
||||
export MAKE AWK GENKSYMS INSTALLKERNEL PERL UTS_MACHINE
|
||||
export MAKE AWK GENKSYMS INSTALLKERNEL PERL PYTHON UTS_MACHINE
|
||||
export HOSTCXX HOSTCXXFLAGS LDFLAGS_MODULE CHECK CHECKFLAGS
|
||||
|
||||
export KBUILD_CPPFLAGS NOSTDINC_FLAGS LINUXINCLUDE OBJCOPYFLAGS LDFLAGS
|
||||
@ -687,6 +688,7 @@ KBUILD_CFLAGS += $(call cc-disable-warning, tautological-compare)
|
||||
# source of a reference will be _MergedGlobals and not on of the whitelisted names.
|
||||
# See modpost pattern 2
|
||||
KBUILD_CFLAGS += $(call cc-option, -mno-global-merge,)
|
||||
KBUILD_CFLAGS += $(call cc-option, -fcatch-undefined-behavior)
|
||||
else
|
||||
|
||||
# This warning generated too much noise in a regular build.
|
||||
@ -710,9 +712,16 @@ endif
|
||||
KBUILD_CFLAGS += $(call cc-option, -fno-var-tracking-assignments)
|
||||
|
||||
ifdef CONFIG_DEBUG_INFO
|
||||
ifdef CONFIG_DEBUG_INFO_SPLIT
|
||||
KBUILD_CFLAGS += $(call cc-option, -gsplit-dwarf, -g)
|
||||
else
|
||||
KBUILD_CFLAGS += -g
|
||||
endif
|
||||
KBUILD_AFLAGS += -Wa,-gdwarf-2
|
||||
endif
|
||||
ifdef CONFIG_DEBUG_INFO_DWARF4
|
||||
KBUILD_CFLAGS += $(call cc-option, -gdwarf-4,)
|
||||
endif
|
||||
|
||||
ifdef CONFIG_DEBUG_INFO_REDUCED
|
||||
KBUILD_CFLAGS += $(call cc-option, -femit-struct-debug-baseonly) \
|
||||
@ -1398,6 +1407,7 @@ clean: $(clean-dirs)
|
||||
@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
|
||||
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
|
||||
-o -name '*.ko.*' \
|
||||
-o -name '*.dwo' \
|
||||
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
|
||||
-o -name '*.symtypes' -o -name 'modules.order' \
|
||||
-o -name modules.builtin -o -name '.tmp_*.o.*' \
|
||||
|
@ -76,7 +76,7 @@ vmlinux.gz: vmlinux
|
||||
$(Q)$(MAKE) $(build)=$(boot) $@
|
||||
|
||||
unwcheck: vmlinux
|
||||
-$(Q)READELF=$(READELF) python $(srctree)/arch/ia64/scripts/unwcheck.py $<
|
||||
-$(Q)READELF=$(READELF) $(PYTHON) $(srctree)/arch/ia64/scripts/unwcheck.py $<
|
||||
|
||||
archclean:
|
||||
$(Q)$(MAKE) $(clean)=$(boot)
|
||||
|
@ -143,6 +143,30 @@ config DEBUG_INFO_REDUCED
|
||||
DEBUG_INFO build and compile times are reduced too.
|
||||
Only works with newer gcc versions.
|
||||
|
||||
config DEBUG_INFO_SPLIT
|
||||
bool "Produce split debuginfo in .dwo files"
|
||||
depends on DEBUG_INFO
|
||||
help
|
||||
Generate debug info into separate .dwo files. This significantly
|
||||
reduces the build directory size for builds with DEBUG_INFO,
|
||||
because it stores the information only once on disk in .dwo
|
||||
files instead of multiple times in object files and executables.
|
||||
In addition the debug information is also compressed.
|
||||
|
||||
Requires recent gcc (4.7+) and recent gdb/binutils.
|
||||
Any tool that packages or reads debug information would need
|
||||
to know about the .dwo files and include them.
|
||||
Incompatible with older versions of ccache.
|
||||
|
||||
config DEBUG_INFO_DWARF4
|
||||
bool "Generate dwarf4 debuginfo"
|
||||
depends on DEBUG_INFO
|
||||
help
|
||||
Generate dwarf4 debug info. This requires recent versions
|
||||
of gcc and gdb. It makes the debug information larger.
|
||||
But it significantly improves the success of resolving
|
||||
variables in gdb on optimized code.
|
||||
|
||||
config ENABLE_WARN_DEPRECATED
|
||||
bool "Enable __deprecated logic"
|
||||
default y
|
||||
|
@ -215,11 +215,13 @@ else
|
||||
arg-check = $(if $(strip $(cmd_$@)),,1)
|
||||
endif
|
||||
|
||||
# >'< substitution is for echo to work,
|
||||
# >$< substitution to preserve $ when reloading .cmd file
|
||||
# note: when using inline perl scripts [perl -e '...$$t=1;...']
|
||||
# in $(cmd_xxx) double $$ your perl vars
|
||||
make-cmd = $(subst \\,\\\\,$(subst \#,\\\#,$(subst $$,$$$$,$(call escsq,$(cmd_$(1))))))
|
||||
# Replace >$< with >$$< to preserve $ when reloading the .cmd file
|
||||
# (needed for make)
|
||||
# Replace >#< with >\#< to avoid starting a comment in the .cmd file
|
||||
# (needed for make)
|
||||
# Replace >'< with >'\''< to be able to enclose the whole string in '...'
|
||||
# (needed for the shell)
|
||||
make-cmd = $(call escsq,$(subst \#,\\\#,$(subst $$,$$$$,$(cmd_$(1)))))
|
||||
|
||||
# Find any prerequisites that is newer than target or that does not exist.
|
||||
# PHONY targets skipped in both cases.
|
||||
@ -230,7 +232,7 @@ any-prereq = $(filter-out $(PHONY),$?) $(filter-out $(PHONY) $(wildcard $^),$^)
|
||||
if_changed = $(if $(strip $(any-prereq) $(arg-check)), \
|
||||
@set -e; \
|
||||
$(echo-cmd) $(cmd_$(1)); \
|
||||
echo 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
|
||||
printf '%s\n' 'cmd_$@ := $(make-cmd)' > $(dot-target).cmd)
|
||||
|
||||
# Execute the command and also postprocess generated .d dependencies file.
|
||||
if_changed_dep = $(if $(strip $(any-prereq) $(arg-check) ), \
|
||||
|
@ -40,8 +40,8 @@ subdir-ymn := $(addprefix $(obj)/,$(subdir-ymn))
|
||||
# build a list of files to remove, usually relative to the current
|
||||
# directory
|
||||
|
||||
__clean-files := $(extra-y) $(always) \
|
||||
$(targets) $(clean-files) \
|
||||
__clean-files := $(extra-y) $(extra-m) $(extra-) \
|
||||
$(always) $(targets) $(clean-files) \
|
||||
$(host-progs) \
|
||||
$(hostprogs-y) $(hostprogs-m) $(hostprogs-)
|
||||
|
||||
|
@ -26,16 +26,6 @@ warning-1 += $(call cc-option, -Wmissing-include-dirs)
|
||||
warning-1 += $(call cc-option, -Wunused-but-set-variable)
|
||||
warning-1 += $(call cc-disable-warning, missing-field-initializers)
|
||||
|
||||
# Clang
|
||||
warning-1 += $(call cc-disable-warning, initializer-overrides)
|
||||
warning-1 += $(call cc-disable-warning, unused-value)
|
||||
warning-1 += $(call cc-disable-warning, format)
|
||||
warning-1 += $(call cc-disable-warning, unknown-warning-option)
|
||||
warning-1 += $(call cc-disable-warning, sign-compare)
|
||||
warning-1 += $(call cc-disable-warning, format-zero-length)
|
||||
warning-1 += $(call cc-disable-warning, uninitialized)
|
||||
warning-1 += $(call cc-option, -fcatch-undefined-behavior)
|
||||
|
||||
warning-2 := -Waggregate-return
|
||||
warning-2 += -Wcast-align
|
||||
warning-2 += -Wdisabled-optimization
|
||||
@ -64,4 +54,15 @@ ifeq ("$(strip $(warning))","")
|
||||
endif
|
||||
|
||||
KBUILD_CFLAGS += $(warning)
|
||||
else
|
||||
|
||||
ifeq ($(COMPILER),clang)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, initializer-overrides)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, unused-value)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, format)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, unknown-warning-option)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, sign-compare)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, format-zero-length)
|
||||
KBUILD_CFLAGS += $(call cc-disable-warning, uninitialized)
|
||||
endif
|
||||
endif
|
||||
|
@ -20,21 +20,12 @@
|
||||
# Will compile qconf as a C++ program, and menu as a C program.
|
||||
# They are linked as C++ code to the executable qconf
|
||||
|
||||
# hostprogs-y := conf
|
||||
# conf-objs := conf.o libkconfig.so
|
||||
# libkconfig-objs := expr.o type.o
|
||||
# Will create a shared library named libkconfig.so that consists of
|
||||
# expr.o and type.o (they are both compiled as C code and the object files
|
||||
# are made as position independent code).
|
||||
# conf.c is compiled as a C program, and conf.o is linked together with
|
||||
# libkconfig.so as the executable conf.
|
||||
# Note: Shared libraries consisting of C++ files are not supported
|
||||
|
||||
__hostprogs := $(sort $(hostprogs-y) $(hostprogs-m))
|
||||
|
||||
# C code
|
||||
# Executables compiled from a single .c file
|
||||
host-csingle := $(foreach m,$(__hostprogs),$(if $($(m)-objs),,$(m)))
|
||||
host-csingle := $(foreach m,$(__hostprogs), \
|
||||
$(if $($(m)-objs)$($(m)-cxxobjs),,$(m)))
|
||||
|
||||
# C executables linked based on several .o files
|
||||
host-cmulti := $(foreach m,$(__hostprogs),\
|
||||
@ -44,33 +35,17 @@ host-cmulti := $(foreach m,$(__hostprogs),\
|
||||
host-cobjs := $(sort $(foreach m,$(__hostprogs),$($(m)-objs)))
|
||||
|
||||
# C++ code
|
||||
# C++ executables compiled from at least on .cc file
|
||||
# C++ executables compiled from at least one .cc file
|
||||
# and zero or more .c files
|
||||
host-cxxmulti := $(foreach m,$(__hostprogs),$(if $($(m)-cxxobjs),$(m)))
|
||||
|
||||
# C++ Object (.o) files compiled from .cc files
|
||||
host-cxxobjs := $(sort $(foreach m,$(host-cxxmulti),$($(m)-cxxobjs)))
|
||||
|
||||
# Shared libaries (only .c supported)
|
||||
# Shared libraries (.so) - all .so files referenced in "xxx-objs"
|
||||
host-cshlib := $(sort $(filter %.so, $(host-cobjs)))
|
||||
# Remove .so files from "xxx-objs"
|
||||
host-cobjs := $(filter-out %.so,$(host-cobjs))
|
||||
|
||||
#Object (.o) files used by the shared libaries
|
||||
host-cshobjs := $(sort $(foreach m,$(host-cshlib),$($(m:.so=-objs))))
|
||||
|
||||
# output directory for programs/.o files
|
||||
# hostprogs-y := tools/build may have been specified. Retrieve directory
|
||||
host-objdirs := $(foreach f,$(__hostprogs), $(if $(dir $(f)),$(dir $(f))))
|
||||
# directory of .o files from prog-objs notation
|
||||
host-objdirs += $(foreach f,$(host-cmulti), \
|
||||
$(foreach m,$($(f)-objs), \
|
||||
$(if $(dir $(m)),$(dir $(m)))))
|
||||
# directory of .o files from prog-cxxobjs notation
|
||||
host-objdirs += $(foreach f,$(host-cxxmulti), \
|
||||
$(foreach m,$($(f)-cxxobjs), \
|
||||
$(if $(dir $(m)),$(dir $(m)))))
|
||||
# hostprogs-y := tools/build may have been specified.
|
||||
# Retrieve also directory of .o files from prog-objs or prog-cxxobjs notation
|
||||
host-objdirs := $(dir $(__hostprogs) $(host-cobjs) $(host-cxxobjs))
|
||||
|
||||
host-objdirs := $(strip $(sort $(filter-out ./,$(host-objdirs))))
|
||||
|
||||
@ -81,8 +56,6 @@ host-cmulti := $(addprefix $(obj)/,$(host-cmulti))
|
||||
host-cobjs := $(addprefix $(obj)/,$(host-cobjs))
|
||||
host-cxxmulti := $(addprefix $(obj)/,$(host-cxxmulti))
|
||||
host-cxxobjs := $(addprefix $(obj)/,$(host-cxxobjs))
|
||||
host-cshlib := $(addprefix $(obj)/,$(host-cshlib))
|
||||
host-cshobjs := $(addprefix $(obj)/,$(host-cshobjs))
|
||||
host-objdirs := $(addprefix $(obj)/,$(host-objdirs))
|
||||
|
||||
obj-dirs += $(host-objdirs)
|
||||
@ -123,7 +96,7 @@ quiet_cmd_host-cmulti = HOSTLD $@
|
||||
cmd_host-cmulti = $(HOSTCC) $(HOSTLDFLAGS) -o $@ \
|
||||
$(addprefix $(obj)/,$($(@F)-objs)) \
|
||||
$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
|
||||
$(host-cmulti): $(obj)/%: $(host-cobjs) $(host-cshlib) FORCE
|
||||
$(host-cmulti): $(obj)/%: $(host-cobjs) FORCE
|
||||
$(call if_changed,host-cmulti)
|
||||
|
||||
# Create .o file from a single .c file
|
||||
@ -140,7 +113,7 @@ quiet_cmd_host-cxxmulti = HOSTLD $@
|
||||
$(foreach o,objs cxxobjs,\
|
||||
$(addprefix $(obj)/,$($(@F)-$(o)))) \
|
||||
$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
|
||||
$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) $(host-cshlib) FORCE
|
||||
$(host-cxxmulti): $(obj)/%: $(host-cobjs) $(host-cxxobjs) FORCE
|
||||
$(call if_changed,host-cxxmulti)
|
||||
|
||||
# Create .o file from a single .cc (C++) file
|
||||
@ -149,21 +122,5 @@ quiet_cmd_host-cxxobjs = HOSTCXX $@
|
||||
$(host-cxxobjs): $(obj)/%.o: $(src)/%.cc FORCE
|
||||
$(call if_changed_dep,host-cxxobjs)
|
||||
|
||||
# Compile .c file, create position independent .o file
|
||||
# host-cshobjs -> .o
|
||||
quiet_cmd_host-cshobjs = HOSTCC -fPIC $@
|
||||
cmd_host-cshobjs = $(HOSTCC) $(hostc_flags) -fPIC -c -o $@ $<
|
||||
$(host-cshobjs): $(obj)/%.o: $(src)/%.c FORCE
|
||||
$(call if_changed_dep,host-cshobjs)
|
||||
|
||||
# Link a shared library, based on position independent .o files
|
||||
# *.o -> .so shared library (host-cshlib)
|
||||
quiet_cmd_host-cshlib = HOSTLLD -shared $@
|
||||
cmd_host-cshlib = $(HOSTCC) $(HOSTLDFLAGS) -shared -o $@ \
|
||||
$(addprefix $(obj)/,$($(@F:.so=-objs))) \
|
||||
$(HOST_LOADLIBES) $(HOSTLOADLIBES_$(@F))
|
||||
$(host-cshlib): $(obj)/%: $(host-cshobjs) FORCE
|
||||
$(call if_changed,host-cshlib)
|
||||
|
||||
targets += $(host-csingle) $(host-cmulti) $(host-cobjs)\
|
||||
$(host-cxxmulti) $(host-cxxobjs) $(host-cshlib) $(host-cshobjs)
|
||||
$(host-cxxmulti) $(host-cxxobjs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user