Skip to content

Commit 2bb732c

Browse files
committed
Merge branch 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6
* 'kbuild' of git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild-2.6: kbuild: make KBUILD_NOCMDDEP=1 handle empty built-in.o scripts/kallsyms.c: fix potential segfault scripts/gen_initramfs_list.sh: Convert to a /bin/sh script kbuild: Fix GNU make v3.80 compatibility kbuild: Fix passing -Wno-* options to gcc 4.4+ kbuild: move scripts/basic/docproc.c to scripts/docproc.c kbuild: Fix Makefile.asm-generic for um kbuild: Allow to combine multiple W= levels kbuild: Disable -Wunused-but-set-variable for gcc 4.6.0 Fix handling of backlash character in LINUX_COMPILE_BY name kbuild: asm-generic support kbuild: implement several W= levels kbuild: Fix build with binutils <= 2.19 initramfs: Use KBUILD_BUILD_TIMESTAMP for generated entries kbuild: Allow to override LINUX_COMPILE_BY and LINUX_COMPILE_HOST macros kbuild: Drop unused LINUX_COMPILE_TIME and LINUX_COMPILE_DOMAIN macros kbuild: Use the deterministic mode of ar kbuild: Call gzip with -n kbuild: move KALLSYMS_EXTRA_PASS from Kconfig to Makefile Kconfig: improve KALLSYMS_ALL documentation Fix up trivial conflict in Makefile
2 parents f50d1d9 + c4d5ee1 commit 2bb732c

20 files changed

Lines changed: 287 additions & 108 deletions

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ modules.builtin
5757
include/config
5858
include/linux/version.h
5959
include/generated
60+
arch/*/include/generated
6061

6162
# stgit generated dirs
6263
patches-*

‎Documentation/DocBook/Makefile‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ installmandocs: mandocs
7373
###
7474
#External programs used
7575
KERNELDOC = $(srctree)/scripts/kernel-doc
76-
DOCPROC = $(objtree)/scripts/basic/docproc
76+
DOCPROC = $(objtree)/scripts/docproc
7777

7878
XMLTOFLAGS = -m $(srctree)/Documentation/DocBook/stylesheet.xsl
7979
XMLTOFLAGS += --skip-validation

‎Documentation/kbuild/kbuild.txt‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,16 @@ KBUILD_ENABLE_EXTRA_GCC_CHECKS
201201
--------------------------------------------------
202202
If enabled over the make command line with "W=1", it turns on additional
203203
gcc -W... options for more extensive build-time checking.
204+
205+
KBUILD_BUILD_TIMESTAMP
206+
--------------------------------------------------
207+
Setting this to a date string overrides the timestamp used in the
208+
UTS_VERSION definition (uname -v in the running kernel). The value has to
209+
be a string that can be passed to date -d. The default value
210+
is the output of the date command at one point during build.
211+
212+
KBUILD_BUILD_USER, KBUILD_BUILD_HOST
213+
--------------------------------------------------
214+
These two variables allow to override the user@host string displayed during
215+
boot and in /proc/version. The default value is the output of the commands
216+
whoami and host, respectively.

‎Documentation/kbuild/makefiles.txt‎

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ This document describes the Linux kernel Makefiles.
4040
--- 6.6 Commands useful for building a boot image
4141
--- 6.7 Custom kbuild commands
4242
--- 6.8 Preprocessing linker scripts
43+
--- 6.9 Generic header files
4344

4445
=== 7 Kbuild syntax for exported headers
4546
--- 7.1 header-y
4647
--- 7.2 objhdr-y
4748
--- 7.3 destination-y
49+
--- 7.4 generic-y
4850

4951
=== 8 Kbuild Variables
5052
=== 9 Makefile language
@@ -499,6 +501,18 @@ more details, with real examples.
499501
gcc >= 3.00. For gcc < 3.00, -malign-functions=4 is used.
500502
Note: cc-option-align uses KBUILD_CFLAGS for $(CC) options
501503

504+
cc-disable-warning
505+
cc-disable-warning checks if gcc supports a given warning and returns
506+
the commandline switch to disable it. This special function is needed,
507+
because gcc 4.4 and later accept any unknown -Wno-* option and only
508+
warn about it if there is another warning in the source file.
509+
510+
Example:
511+
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
512+
513+
In the above example, -Wno-unused-but-set-variable will be added to
514+
KBUILD_CFLAGS only if gcc really accepts it.
515+
502516
cc-version
503517
cc-version returns a numerical version of the $(CC) compiler version.
504518
The format is <major><minor> where both are two digits. So for example
@@ -955,6 +969,11 @@ When kbuild executes, the following steps are followed (roughly):
955969
used when linking modules. This is often a linker script.
956970
From commandline LDFLAGS_MODULE shall be used (see kbuild.txt).
957971

972+
KBUILD_ARFLAGS Options for $(AR) when creating archives
973+
974+
$(KBUILD_ARFLAGS) set by the top level Makefile to "D" (deterministic
975+
mode) if this option is supported by $(AR).
976+
958977
--- 6.2 Add prerequisites to archprepare:
959978

960979
The archprepare: rule is used to list prerequisites that need to be
@@ -1209,6 +1228,14 @@ When kbuild executes, the following steps are followed (roughly):
12091228
The kbuild infrastructure for *lds file are used in several
12101229
architecture-specific files.
12111230

1231+
--- 6.9 Generic header files
1232+
1233+
The directory include/asm-generic contains the header files
1234+
that may be shared between individual architectures.
1235+
The recommended approach how to use a generic header file is
1236+
to list the file in the Kbuild file.
1237+
See "7.4 generic-y" for further info on syntax etc.
1238+
12121239
=== 7 Kbuild syntax for exported headers
12131240

12141241
The kernel include a set of headers that is exported to userspace.
@@ -1265,6 +1292,32 @@ See subsequent chapter for the syntax of the Kbuild file.
12651292
In the example above all exported headers in the Kbuild file
12661293
will be located in the directory "include/linux" when exported.
12671294

1295+
--- 7.4 generic-y
1296+
1297+
If an architecture uses a verbatim copy of a header from
1298+
include/asm-generic then this is listed in the file
1299+
arch/$(ARCH)/include/asm/Kbuild like this:
1300+
1301+
Example:
1302+
#arch/x86/include/asm/Kbuild
1303+
generic-y += termios.h
1304+
generic-y += rtc.h
1305+
1306+
During the prepare phase of the build a wrapper include
1307+
file is generated in the directory:
1308+
1309+
arch/$(ARCH)/include/generated/asm
1310+
1311+
When a header is exported where the architecture uses
1312+
the generic header a similar wrapper is generated as part
1313+
of the set of exported headers in the directory:
1314+
1315+
usr/include/asm
1316+
1317+
The generated wrapper will in both cases look like the following:
1318+
1319+
Example: termios.h
1320+
#include <asm-generic/termios.h>
12681321

12691322
=== 8 Kbuild Variables
12701323

‎Makefile‎

Lines changed: 37 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ ifeq ("$(origin O)", "command line")
103103
endif
104104

105105
ifeq ("$(origin W)", "command line")
106-
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := 1
106+
export KBUILD_ENABLE_EXTRA_GCC_CHECKS := $(W)
107107
endif
108108

109109
# That's our default target when none is given on the command line
@@ -349,7 +349,8 @@ CFLAGS_GCOV = -fprofile-arcs -ftest-coverage
349349

350350
# Use LINUXINCLUDE when you must reference the include/ directory.
351351
# Needed to be compatible with the O= option
352-
LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include -Iinclude \
352+
LINUXINCLUDE := -I$(srctree)/arch/$(hdr-arch)/include \
353+
-Iarch/$(hdr-arch)/include/generated -Iinclude \
353354
$(if $(KBUILD_SRC), -I$(srctree)/include) \
354355
-include include/generated/autoconf.h
355356

@@ -382,6 +383,7 @@ export KBUILD_CFLAGS CFLAGS_KERNEL CFLAGS_MODULE CFLAGS_GCOV
382383
export KBUILD_AFLAGS AFLAGS_KERNEL AFLAGS_MODULE
383384
export KBUILD_AFLAGS_MODULE KBUILD_CFLAGS_MODULE KBUILD_LDFLAGS_MODULE
384385
export KBUILD_AFLAGS_KERNEL KBUILD_CFLAGS_KERNEL
386+
export KBUILD_ARFLAGS
385387

386388
# When compiling out-of-tree modules, put MODVERDIR in the module
387389
# tree rather than in the kernel tree. The kernel tree might
@@ -416,6 +418,12 @@ ifneq ($(KBUILD_SRC),)
416418
$(srctree) $(objtree) $(VERSION) $(PATCHLEVEL)
417419
endif
418420

421+
# Support for using generic headers in asm-generic
422+
PHONY += asm-generic
423+
asm-generic:
424+
$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.asm-generic \
425+
obj=arch/$(SRCARCH)/include/generated/asm
426+
419427
# To make sure we do not include .config for any of the *config targets
420428
# catch them early, and hand them over to scripts/kconfig/Makefile
421429
# It is allowed to specify more targets when calling make, including
@@ -559,6 +567,10 @@ ifndef CONFIG_CC_STACKPROTECTOR
559567
KBUILD_CFLAGS += $(call cc-option, -fno-stack-protector)
560568
endif
561569

570+
# This warning generated too much noise in a regular build.
571+
# Use make W=1 to enable this warning (see scripts/Makefile.build)
572+
KBUILD_CFLAGS += $(call cc-disable-warning, unused-but-set-variable)
573+
562574
ifdef CONFIG_FRAME_POINTER
563575
KBUILD_CFLAGS += -fno-omit-frame-pointer -fno-optimize-sibling-calls
564576
else
@@ -604,14 +616,17 @@ CHECKFLAGS += $(NOSTDINC_FLAGS)
604616
KBUILD_CFLAGS += $(call cc-option,-Wdeclaration-after-statement,)
605617

606618
# disable pointer signed / unsigned warnings in gcc 4.0
607-
KBUILD_CFLAGS += $(call cc-option,-Wno-pointer-sign,)
619+
KBUILD_CFLAGS += $(call cc-disable-warning, pointer-sign)
608620

609621
# disable invalid "can't wrap" optimizations for signed / pointers
610622
KBUILD_CFLAGS += $(call cc-option,-fno-strict-overflow)
611623

612624
# conserve stack if available
613625
KBUILD_CFLAGS += $(call cc-option,-fconserve-stack)
614626

627+
# use the deterministic mode of AR if available
628+
KBUILD_ARFLAGS := $(call ar-option,D)
629+
615630
# check for 'asm goto'
616631
ifeq ($(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-goto.sh $(CC)), y)
617632
KBUILD_CFLAGS += -DCC_HAVE_ASM_GOTO
@@ -797,15 +812,17 @@ ifdef CONFIG_KALLSYMS
797812
# o The correct .tmp_kallsyms2.o is linked into the final vmlinux.
798813
# o Verify that the System.map from vmlinux matches the map from
799814
# .tmp_vmlinux2, just in case we did not generate kallsyms correctly.
800-
# o If CONFIG_KALLSYMS_EXTRA_PASS is set, do an extra pass using
815+
# o If 'make KALLSYMS_EXTRA_PASS=1" was used, do an extra pass using
801816
# .tmp_vmlinux3 and .tmp_kallsyms3.o. This is only meant as a
802817
# temporary bypass to allow the kernel to be built while the
803818
# maintainers work out what went wrong with kallsyms.
804819

805-
ifdef CONFIG_KALLSYMS_EXTRA_PASS
806-
last_kallsyms := 3
807-
else
808820
last_kallsyms := 2
821+
822+
ifdef KALLSYMS_EXTRA_PASS
823+
ifneq ($(KALLSYMS_EXTRA_PASS),0)
824+
last_kallsyms := 3
825+
endif
809826
endif
810827

811828
kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
@@ -816,7 +833,8 @@ define verify_kallsyms
816833
$(cmd_sysmap) .tmp_vmlinux$(last_kallsyms) .tmp_System.map
817834
$(Q)cmp -s System.map .tmp_System.map || \
818835
(echo Inconsistent kallsyms data; \
819-
echo Try setting CONFIG_KALLSYMS_EXTRA_PASS; \
836+
echo This is a bug - please report about it; \
837+
echo Try "make KALLSYMS_EXTRA_PASS=1" as a workaround; \
820838
rm .tmp_kallsyms* ; /bin/false )
821839
endef
822840

@@ -947,7 +965,7 @@ ifneq ($(KBUILD_SRC),)
947965
endif
948966

949967
# prepare2 creates a makefile if using a separate output directory
950-
prepare2: prepare3 outputmakefile
968+
prepare2: prepare3 outputmakefile asm-generic
951969

952970
prepare1: prepare2 include/linux/version.h include/generated/utsrelease.h \
953971
include/config/auto.conf
@@ -1021,7 +1039,7 @@ hdr-inst := -rR -f $(srctree)/scripts/Makefile.headersinst obj
10211039
hdr-dst = $(if $(KBUILD_HEADERS), dst=include/asm-$(hdr-arch), dst=include/asm)
10221040

10231041
PHONY += __headers
1024-
__headers: include/linux/version.h scripts_basic FORCE
1042+
__headers: include/linux/version.h scripts_basic asm-generic FORCE
10251043
$(Q)$(MAKE) $(build)=scripts build_unifdef
10261044

10271045
PHONY += headers_install_all
@@ -1136,7 +1154,8 @@ CLEAN_FILES += vmlinux System.map \
11361154
.tmp_kallsyms* .tmp_version .tmp_vmlinux* .tmp_System.map
11371155

11381156
# Directories & files removed with 'make mrproper'
1139-
MRPROPER_DIRS += include/config usr/include include/generated
1157+
MRPROPER_DIRS += include/config usr/include include/generated \
1158+
arch/*/include/generated
11401159
MRPROPER_FILES += .config .config.old .version .old_version \
11411160
include/linux/version.h \
11421161
Module.symvers tags TAGS cscope* GPATH GTAGS GRTAGS GSYMS
@@ -1267,7 +1286,11 @@ help:
12671286
@echo ' make O=dir [targets] Locate all output files in "dir", including .config'
12681287
@echo ' make C=1 [targets] Check all c source with $$CHECK (sparse by default)'
12691288
@echo ' make C=2 [targets] Force check of all c source with $$CHECK'
1270-
@echo ' make W=1 [targets] Enable extra gcc checks'
1289+
@echo ' make W=n [targets] Enable extra gcc checks, n=1,2,3 where'
1290+
@echo ' 1: warnings which may be relevant and do not occur too often'
1291+
@echo ' 2: warnings which occur quite often but may still be relevant'
1292+
@echo ' 3: more obscure warnings, can most likely be ignored'
1293+
@echo ' Multiple levels can be combined with W=12 or W=123'
12711294
@echo ' make RECORDMCOUNT_WARN=1 [targets] Warn about ignored mcount sections'
12721295
@echo ''
12731296
@echo 'Execute "make" or "make all" to build all targets marked with [*] '
@@ -1291,6 +1314,7 @@ $(help-board-dirs): help-%:
12911314
# Documentation targets
12921315
# ---------------------------------------------------------------------------
12931316
%docs: scripts_basic FORCE
1317+
$(Q)$(MAKE) $(build)=scripts build_docproc
12941318
$(Q)$(MAKE) $(build)=Documentation/DocBook $@
12951319

12961320
else # KBUILD_EXTMOD
@@ -1375,7 +1399,7 @@ endif # KBUILD_EXTMOD
13751399
clean: $(clean-dirs)
13761400
$(call cmd,rmdirs)
13771401
$(call cmd,rmfiles)
1378-
@find $(or $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
1402+
@find $(if $(KBUILD_EXTMOD), $(KBUILD_EXTMOD), .) $(RCS_FIND_IGNORE) \
13791403
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
13801404
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
13811405
-o -name '*.symtypes' -o -name 'modules.order' \

‎init/Kconfig‎

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -959,24 +959,18 @@ config KALLSYMS_ALL
959959
bool "Include all symbols in kallsyms"
960960
depends on DEBUG_KERNEL && KALLSYMS
961961
help
962-
Normally kallsyms only contains the symbols of functions, for nicer
963-
OOPS messages. Some debuggers can use kallsyms for other
964-
symbols too: say Y here to include all symbols, if you need them
965-
and you don't care about adding 300k to the size of your kernel.
966-
967-
Say N.
968-
969-
config KALLSYMS_EXTRA_PASS
970-
bool "Do an extra kallsyms pass"
971-
depends on KALLSYMS
972-
help
973-
If kallsyms is not working correctly, the build will fail with
974-
inconsistent kallsyms data. If that occurs, log a bug report and
975-
turn on KALLSYMS_EXTRA_PASS which should result in a stable build.
976-
Always say N here unless you find a bug in kallsyms, which must be
977-
reported. KALLSYMS_EXTRA_PASS is only a temporary workaround while
978-
you wait for kallsyms to be fixed.
979-
962+
Normally kallsyms only contains the symbols of functions for nicer
963+
OOPS messages and backtraces (i.e., symbols from the text and inittext
964+
sections). This is sufficient for most cases. And only in very rare
965+
cases (e.g., when a debugger is used) all symbols are required (e.g.,
966+
names of variables from the data sections, etc).
967+
968+
This option makes sure that all symbols are loaded into the kernel
969+
image (i.e., symbols from all sections) in cost of increased kernel
970+
size (depending on the kernel configuration, it may be 300KiB or
971+
something like this).
972+
973+
Say N unless you really need all symbols.
980974

981975
config HOTPLUG
982976
bool "Support for hot-pluggable devices" if EXPERT

‎scripts/.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,4 @@ bin2c
88
unifdef
99
ihex2fw
1010
recordmcount
11+
docproc

‎scripts/Kbuild.include‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,11 @@ cc-option-yn = $(call try-run,\
118118
cc-option-align = $(subst -functions=0,,\
119119
$(call cc-option,-falign-functions=0,-malign-functions=0))
120120

121+
# cc-disable-warning
122+
# Usage: cflags-y += $(call cc-disable-warning,unused-but-set-variable)
123+
cc-disable-warning = $(call try-run,\
124+
$(CC) $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS) -W$(strip $(1)) -c -xc /dev/null -o "$$TMP",-Wno-$(strip $(1)))
125+
121126
# cc-version
122127
# Usage gcc-ver := $(call cc-version)
123128
cc-version = $(shell $(CONFIG_SHELL) $(srctree)/scripts/gcc-version.sh $(CC))
@@ -141,6 +146,11 @@ cc-ldoption = $(call try-run,\
141146
ld-option = $(call try-run,\
142147
$(CC) /dev/null -c -o "$$TMPO" ; $(LD) $(1) "$$TMPO" -o "$$TMP",$(1),$(2))
143148

149+
# ar-option
150+
# Usage: KBUILD_ARFLAGS := $(call ar-option,D)
151+
# Important: no spaces around options
152+
ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
153+
144154
######
145155

146156
###
@@ -187,6 +197,8 @@ ifneq ($(KBUILD_NOCMDDEP),1)
187197
# User may override this check using make KBUILD_NOCMDDEP=1
188198
arg-check = $(strip $(filter-out $(cmd_$(1)), $(cmd_$@)) \
189199
$(filter-out $(cmd_$@), $(cmd_$(1))) )
200+
else
201+
arg-check = $(if $(strip $(cmd_$@)),,1)
190202
endif
191203

192204
# >'< substitution is for echo to work,

‎scripts/Makefile‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
# pnmttologo: Convert pnm files to logo files
77
# conmakehash: Create chartable
88
# conmakehash: Create arrays for initializing the kernel console tables
9+
# docproc: Used in Documentation/DocBook
910

1011
hostprogs-$(CONFIG_KALLSYMS) += kallsyms
1112
hostprogs-$(CONFIG_LOGO) += pnmtologo
@@ -16,12 +17,14 @@ hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount
1617
always := $(hostprogs-y) $(hostprogs-m)
1718

1819
# The following hostprogs-y programs are only build on demand
19-
hostprogs-y += unifdef
20+
hostprogs-y += unifdef docproc
2021

21-
# This target is used internally to avoid "is up to date" messages
22+
# These targets are used internally to avoid "is up to date" messages
2223
PHONY += build_unifdef
2324
build_unifdef: scripts/unifdef FORCE
2425
@:
26+
build_docproc: scripts/docproc FORCE
27+
@:
2528

2629
subdir-$(CONFIG_MODVERSIONS) += genksyms
2730
subdir-y += mod

0 commit comments

Comments
 (0)