Skip to contentSkip to conversation

kbuild-next content

PATCH In review Sam Ravnborg 5 participants 34 messages Dec 20, 2008 – Dec 22, 2008

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

Following is the collected patched in kbuild-next for the upcoming merge window.

Highlights:

o Better track of symbol checksum changes (Andreas Gruenbacher)
o Improved strinning of modules (Jan Beulich)
o silent is now really silent (Mike Frysinger)
o improved svn support (Peter Korsgaard)
o detect include looks (new target: headerdep) (Vegard Nossum)

And a lot of smaller things. Shortlog + diffstat below.

I have still stuff pending but the queue is getting smaller.

Bugzilla say that I have 5 bugs assigned. But I guess in reality there is a few more.

It will all be part of -next and some of the patches is there already. Patches will follow.

Sam

Andreas Gruenbacher (2):
genksyms: track symbol checksum changes
genksyms: allow to ignore symbol checksum changes

Arjan van de Ven (1):
scripts: improve the decodecode script

Jan Beulich (2):
kbuild: strip generated symbols from *.ko
allow stripping of generated symbols under CONFIG_KALLSYMS_ALL

Jeremy Kerr (1):
scripts/package: allow custom options to rpm

Jiri Slaby (2):
kbuild: fix make tags/cscope
kbuild: fix string equality testing in tags.sh

Mike Frysinger (3):
kbuild: kill output in silent mode of mkcompile_h
kbuild: introduce $(kecho) convenience echo
kbuild: use KECHO convenience echo

Peter Korsgaard (2):
setlocalversion: print correct subversion revision
setlocalversion: add git-svn support

Randy Dunlap (1):
kernel-doc: check for extra kernel-doc notations

Robert P. J. Day (1):
kbuild: remove TAR_IGNORE

Sally, Gene (1):
kbuild: gen_init_cpio expands shell variables in file names

Sam Ravnborg (8):
kbuild: fix -I option expansion with O=... builds
kbuild: expand -I in KBUILD_CPPFLAGS
kbuild: teach mkmakfile to be silent
kconfig: fix options to check-lxdialog.sh
tags and cscope support really belongs in a shell script
kbuild: fix make incompatibility
kbuild: simplify use of genksyms
kbuild: support switching source directories with O=.. builds

Vegard Nossum (1):
kbuild: add headerdep used to detect inclusion cycles in header files

Werner Almesberger (1):
remove bashisms from scripts/extract-ikconfig

 Documentation/kbuild/makefiles.txt         |   14 ++
 Makefile                                   |  209 +++++++--------------
 arch/blackfin/boot/Makefile                |    2 +-
 arch/x86/scripts/strip-symbols             |    1 +
 init/Kconfig                               |    7 +
 kernel/kallsyms.c                          |   16 +-
 scripts/Kbuild.include                     |   22 ++-
 scripts/Makefile.build                     |   67 +++++---
 scripts/Makefile.lib                       |   15 +-
 scripts/Makefile.modinst                   |    3 +-
 scripts/decodecode                         |   32 +++-
 scripts/extract-ikconfig                   |    8 +-
 scripts/genksyms/genksyms.c                |  277 ++++++++++++++++++++++++++--
 scripts/genksyms/genksyms.h                |    7 +
 scripts/genksyms/keywords.c_shipped        |  189 ++++++++++----------
 scripts/genksyms/keywords.gperf            |    2 +
 scripts/headerdep.pl                       |  193 +++++++++++++++++++
 scripts/kallsyms.c                         |   21 +--
 scripts/kconfig/lxdialog/check-lxdialog.sh |    2 +-
 scripts/kernel-doc                         |   67 +++++++-
 scripts/mkcompile_h                        |    6 +-
 scripts/mkmakefile                         |    4 +-
 scripts/mksysmap                           |    7 +-
 scripts/package/Makefile                   |    9 +-
 scripts/setlocalversion                    |    7 +-
 scripts/strip-symbols                      |   22 +++
 scripts/tags.sh                            |  160 ++++++++++++++++
 usr/gen_init_cpio.c                        |   28 +++-
 28 files changed, 1046 insertions(+), 351 deletions(-)
#1 lore raw

PATCH 1/26 kbuild: fix -I option expansion with O=... builds

When adding extra -I options with O=... we could end up in a situation where there were no parameters to -I. So we had a commandline that looked like this:

    ... -I -Wall ...

This had the undesired side effect that gcc assumed "-Wall" was a path to look for include files so this options was effectively ignored.

This happens only when we build the generated module.mod.c files as part of the final modules builds and is as such harmless with current kbuild.
This bug was exposed when we rearranged the options to gcc.

---
 scripts/Kbuild.include |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
scripts/Kbuild.include +3 -1
index 982dcae..936940b 100644
@@ -144,7 +144,9 @@ ld-option = $(call try-run,\
 build := -f $(if $(KBUILD_SRC),$(srctree)/)scripts/Makefile.build obj
 
 # Prefix -I with $(srctree) if it is not an absolute path.
-addtree = $(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1)
+# skip if -I has no parameter
+addtree = $(if $(patsubst -I%,%,$(1)), \
+$(if $(filter-out -I/%,$(1)),$(patsubst -I%,-I$(srctree)/%,$(1))) $(1))
 
 # Find all -I options and call addtree
 flags = $(foreach o,$($(1)),$(if $(filter -I%,$(o)),$(call addtree,$(o)),$(o)))
Signature · 1 line
1.6.0.2.GIT
#2 lore raw

PATCH 2/26 kbuild: expand -I in KBUILD_CPPFLAGS

In reply to Sam Ravnborg

kbuild failed to expand include flags in KBUILD_CPPFLAGS resulting in code like this in arch Makefiles:

ifeq ($(KBUILD_SRC),)
KBUILD_CPPFLAGS += -Iinclude/foo
else
KBUILD_CPPFLAGS += -I$(srctree)/include/foo
endif

Move use of LINUXINCLUDE into Makefile.lib to allow us to expand -I directives of KBUILD_CPPFLAGS so we can avoid the above code.

---
 Makefile             |    4 ++--
 scripts/Makefile.lib |   15 +++++++++------
 2 files changed, 11 insertions(+), 8 deletions(-)
Makefile +2 -2
index 9a49960..3075586 100644
@@ -336,7 +336,7 @@ LINUXINCLUDE    := -Iinclude \
                    -I$(srctree)/arch/$(hdr-arch)/include               \
                    -include include/linux/autoconf.h
 
-KBUILD_CPPFLAGS := -D__KERNEL__ $(LINUXINCLUDE)
+KBUILD_CPPFLAGS := -D__KERNEL__
 
 KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs \
 		   -fno-strict-aliasing -fno-common \
@@ -1638,7 +1638,7 @@ cmd_crmodverdir = $(Q)mkdir -p $(MODVERDIR) \
                   $(if $(KBUILD_MODULES),; rm -f $(MODVERDIR)/*)
 
 a_flags = -Wp,-MD,$(depfile) $(KBUILD_AFLAGS) $(AFLAGS_KERNEL) \
-	  $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
+	  $(NOSTDINC_FLAGS) $(LINUXINCLUDE) $(KBUILD_CPPFLAGS) \
 	  $(modkern_aflags) $(EXTRA_AFLAGS) $(AFLAGS_$(basetarget).o)
 
 quiet_cmd_as_o_S = AS      $@
scripts/Makefile.lib +9 -6
index b4ca38a..e063657 100644
@@ -104,9 +104,11 @@ else
 debug_flags =
 endif
 
-orig_c_flags   = $(KBUILD_CFLAGS) $(ccflags-y) $(CFLAGS_$(basetarget).o)
+orig_c_flags   = $(KBUILD_CPPFLAGS) $(KBUILD_CFLAGS)                     \
+                 $(ccflags-y) $(CFLAGS_$(basetarget).o)
 _c_flags       = $(filter-out $(CFLAGS_REMOVE_$(basetarget).o), $(orig_c_flags))
-_a_flags       = $(KBUILD_AFLAGS) $(asflags-y) $(AFLAGS_$(basetarget).o)
+_a_flags       = $(KBUILD_CPPFLAGS) $(KBUILD_AFLAGS)                     \
+                 $(asflags-y) $(AFLAGS_$(basetarget).o)
 _cpp_flags     = $(KBUILD_CPPFLAGS) $(cppflags-y) $(CPPFLAGS_$(@F))
 
 # If building the kernel in a separate objtree expand all occurrences
@@ -127,15 +129,16 @@ __a_flags	=                          $(call flags,_a_flags)
 __cpp_flags     =                          $(call flags,_cpp_flags)
 endif
 
-c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
-		 $(__c_flags) $(modkern_cflags) \
+c_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+		 $(__c_flags) $(modkern_cflags)                           \
 		 -D"KBUILD_STR(s)=\#s" $(basename_flags) $(modname_flags) \
 		  $(debug_flags)
 
-a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(KBUILD_CPPFLAGS) \
+a_flags        = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
 		 $(__a_flags) $(modkern_aflags)
 
-cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(__cpp_flags)
+cpp_flags      = -Wp,-MD,$(depfile) $(NOSTDINC_FLAGS) $(LINUXINCLUDE)     \
+		 $(__cpp_flags)
 
 ld_flags       = $(LDFLAGS) $(ldflags-y)
 
Signature · 1 line
1.6.0.2.GIT
#3 lore raw

PATCH 3/26 kbuild: kill output in silent mode of mkcompile_h

In reply to Sam Ravnborg

From: Mike Frysinger <[email protected]>

The mkcompile_h script does echo regardless of silent mode the make is running at, so have it respect $quiet from kbuild and only echo when not in silent mode.

---
 scripts/mkcompile_h |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
scripts/mkcompile_h +4 -2
index a8740df..6a12dd9 100755
@@ -4,6 +4,8 @@ SMP=$3
 PREEMPT=$4
 CC=$5
 
+vecho() { [ "${quiet}" = "silent_" ] || echo "$@" ; }
+
 # If compile.h exists already and we don't own autoconf.h
 # (i.e. we're not the same user who did make *config), don't
 # modify compile.h
@@ -11,7 +13,7 @@ CC=$5
 # do "compiled by root"
 
 if [ -r $TARGET -a ! -O include/linux/autoconf.h ]; then
-  echo "  SKIPPED $TARGET"
+  vecho "  SKIPPED $TARGET"
   exit 0
 fi
 
@@ -89,7 +91,7 @@ if [ -r $TARGET ] && \
       cmp -s .tmpver.1 .tmpver.2; then
    rm -f .tmpcompile
 else
-   echo "  UPD     $TARGET"
+   vecho "  UPD     $TARGET"
    mv -f .tmpcompile $TARGET
 fi
 rm -f .tmpver.1 .tmpver.2
Signature · 1 line
1.6.0.2.GIT
#4 lore raw

PATCH 4/26 kbuild: introduce $(kecho) convenience echo

In reply to Sam Ravnborg

From: Mike Frysinger <[email protected]>

There is a bunch of places in the build system where we do 'echo' to show some nice status lines. This means we still get output when running in silent mode. So declare a new KECHO variable that only does 'echo' when we are in a suitable verbose build mode.

[sam: added Documentation]
---
 Documentation/kbuild/makefiles.txt |   14 ++++++++++++++
 scripts/Kbuild.include             |    7 +++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
Documentation/kbuild/makefiles.txt +14 -0
index 7a77533..51104f9 100644
@@ -383,6 +383,20 @@ more details, with real examples.
 	to prerequisites are referenced with $(src) (because they are not
 	generated files).
 
+    $(kecho)
+	echoing information to user in a rule is often a good practice
+	but when execution "make -s" one does not expect to see any output
+	except for warnings/errors.
+	To support this kbuild define $(kecho) which will echo out the
+	text following $(kecho) to stdout except if "make -s" is used.
+
+	Example:
+		#arch/blackfin/boot/Makefile
+		$(obj)/vmImage: $(obj)/vmlinux.gz
+			$(call if_changed,uimage)
+			@$(kecho) 'Kernel: $@ is ready'
+
+
 --- 3.11 $(CC) support functions
 
 	The kernel may be built with several different versions of
scripts/Kbuild.include +7 -0
index 936940b..8cf87e8 100644
@@ -25,6 +25,13 @@ basetarget = $(basename $(notdir $@))
 escsq = $(subst $(squote),'\$(squote)',$1)
 
 ###
+# Easy method for doing a status message
+       kecho := :
+ quiet_kecho := echo
+silent_kecho := :
+kecho := $($(quiet)kecho)
+
+###
 # filechk is used to check if the content of a generated file is updated.
 # Sample usage:
 # define filechk_sample
Signature · 1 line
1.6.0.2.GIT
#5 lore raw

Re: [PATCH 04/26] kbuild: introduce $(kecho) convenience echo

Hi,

Quoted 45 lines · Sam Ravnborg

From: Mike Frysinger <[email protected]>

There is a bunch of places in the build system where we do 'echo' to show some nice status lines. This means we still get output when running in silent mode. So declare a new KECHO variable that only does 'echo' when we are in a suitable verbose build mode.

[sam: added Documentation]
---
 Documentation/kbuild/makefiles.txt |   14 ++++++++++++++
 scripts/Kbuild.include             |    7 +++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
Documentation/kbuild/makefiles.txt +14 -0
index 7a77533..51104f9 100644
@@ -383,6 +383,20 @@ more details, with real examples.
       to prerequisites are referenced with $(src) (because they are not
       generated files).
 
+    $(kecho)
+       echoing information to user in a rule is often a good practice
+       but when execution "make -s" one does not expect to see any output
+       except for warnings/errors.
+       To support this kbuild define $(kecho) which will echo out the
+       text following $(kecho) to stdout except if "make -s" is used.
+
+       Example:
+               #arch/blackfin/boot/Makefile
+               $(obj)/vmImage: $(obj)/vmlinux.gz
+                       $(call if_changed,uimage)
+                       @$(kecho) 'Kernel: $@ is ready'
+
+
 --- 3.11 $(CC) support functions
 
       The kernel may be built with several different versions of
scripts/Kbuild.include +0 -0
index 936940b..8cf87e8 100644

scripts/Kbuild.include basetarget = $(basename $(notdir $@)) · line 32

Quoted 8 lines
scripts/Kbuild.include +5 -0
@@ -25,6 +25,13 @@ basetarget = $(basename $(notdir $@))
 escsq = $(subst $(squote),'\$(squote)',$1)
 
 ###
+# Easy method for doing a status message
+       kecho := :
+ quiet_kecho := echo
+silent_kecho := :
+kecho := $($(quiet)kecho)

Hm, why don't we put

  +kecho := @$($(quiet)kecho)

instead, so each caller can omit the @? And the example would then be:

scripts/Kbuild.include basetarget = $(basename $(notdir $@)) · line 35

Quoted 3 lines
scripts/Kbuild.include +3 -0
+               $(obj)/vmImage: $(obj)/vmlinux.gz
+                       $(call if_changed,uimage)
+                       $(kecho) 'Kernel: $@ is ready'

It seems to work correctly over here.

Vegard

Signature · 4 lines
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
#6 lore raw

Re: [PATCH 04/26] kbuild: introduce $(kecho) convenience echo

Quoted 61 lines · Vegard Nossum

Hi,

Quoted 45 lines · Sam Ravnborg

From: Mike Frysinger <[email protected]>

There is a bunch of places in the build system where we do 'echo' to show some nice status lines. This means we still get output when running in silent mode. So declare a new KECHO variable that only does 'echo' when we are in a suitable verbose build mode.

[sam: added Documentation]
---
 Documentation/kbuild/makefiles.txt |   14 ++++++++++++++
 scripts/Kbuild.include             |    7 +++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
Documentation/kbuild/makefiles.txt +14 -0
index 7a77533..51104f9 100644
@@ -383,6 +383,20 @@ more details, with real examples.
       to prerequisites are referenced with $(src) (because they are not
       generated files).
 
+    $(kecho)
+       echoing information to user in a rule is often a good practice
+       but when execution "make -s" one does not expect to see any output
+       except for warnings/errors.
+       To support this kbuild define $(kecho) which will echo out the
+       text following $(kecho) to stdout except if "make -s" is used.
+
+       Example:
+               #arch/blackfin/boot/Makefile
+               $(obj)/vmImage: $(obj)/vmlinux.gz
+                       $(call if_changed,uimage)
+                       @$(kecho) 'Kernel: $@ is ready'
+
+
 --- 3.11 $(CC) support functions
 
       The kernel may be built with several different versions of
scripts/Kbuild.include +0 -0
index 936940b..8cf87e8 100644

scripts/Kbuild.include basetarget = $(basename $(notdir $@)) · line 32

Quoted 8 lines
scripts/Kbuild.include +5 -0
@@ -25,6 +25,13 @@ basetarget = $(basename $(notdir $@))
 escsq = $(subst $(squote),'\$(squote)',$1)
 
 ###
+# Easy method for doing a status message
+       kecho := :
+ quiet_kecho := echo
+silent_kecho := :
+kecho := $($(quiet)kecho)

Hm, why don't we put

  +kecho := @$($(quiet)kecho)
Quoted 7 lines

instead, so each caller can omit the @? And the example would then be:

scripts/Kbuild.include basetarget = $(basename $(notdir $@)) · line 35

Quoted 3 lines
scripts/Kbuild.include +3 -0
+               $(obj)/vmImage: $(obj)/vmlinux.gz
+                       $(call if_changed,uimage)
+                       $(kecho) 'Kernel: $@ is ready'

It seems to work correctly over here.

kecho is used in scripts too where the '@' does not fly.
I considered adding another variant for scripts but that was too much compared to the few users.

Sam

#7 lore raw

Re: [PATCH 04/26] kbuild: introduce $(kecho) convenience echo

Quoted 68 lines · Sam Ravnborg
Quoted 67 lines · Vegard Nossum

Hi,

Quoted 45 lines · Sam Ravnborg

From: Mike Frysinger <[email protected]>

There is a bunch of places in the build system where we do 'echo' to show some nice status lines. This means we still get output when running in silent mode. So declare a new KECHO variable that only does 'echo' when we are in a suitable verbose build mode.

[sam: added Documentation]
---
 Documentation/kbuild/makefiles.txt |   14 ++++++++++++++
 scripts/Kbuild.include             |    7 +++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
Documentation/kbuild/makefiles.txt +14 -0
index 7a77533..51104f9 100644
@@ -383,6 +383,20 @@ more details, with real examples.
       to prerequisites are referenced with $(src) (because they are not
       generated files).
 
+    $(kecho)
+       echoing information to user in a rule is often a good practice
+       but when execution "make -s" one does not expect to see any output
+       except for warnings/errors.
+       To support this kbuild define $(kecho) which will echo out the
+       text following $(kecho) to stdout except if "make -s" is used.
+
+       Example:
+               #arch/blackfin/boot/Makefile
+               $(obj)/vmImage: $(obj)/vmlinux.gz
+                       $(call if_changed,uimage)
+                       @$(kecho) 'Kernel: $@ is ready'
+
+
 --- 3.11 $(CC) support functions
 
       The kernel may be built with several different versions of
scripts/Kbuild.include +0 -0
index 936940b..8cf87e8 100644

scripts/Kbuild.include basetarget = $(basename $(notdir $@)) · line 32

Quoted 8 lines
scripts/Kbuild.include +5 -0
@@ -25,6 +25,13 @@ basetarget = $(basename $(notdir $@))
 escsq = $(subst $(squote),'\$(squote)',$1)
 
 ###
+# Easy method for doing a status message
+       kecho := :
+ quiet_kecho := echo
+silent_kecho := :
+kecho := $($(quiet)kecho)

Hm, why don't we put

  +kecho := @$($(quiet)kecho)

instead, so each caller can omit the @? And the example would then be:

Quoted 3 lines
scripts/Kbuild.include +3 -0
+               $(obj)/vmImage: $(obj)/vmlinux.gz
+                       $(call if_changed,uimage)
+                       $(kecho) 'Kernel: $@ is ready'
Quoted 5 lines
Quoted 1 line

It seems to work correctly over here.

kecho is used in scripts too where the '@' does not fly.
I considered adding another variant for scripts but that was too much compared to the few users.

Ah, that's true. I'm sorry, I did not read the follow-up patch. Adding another variant would also not make any difference from just adding the @ where it is necessary :-)

Vegard

Signature · 4 lines
"The animistic metaphor of the bug that maliciously sneaked in while
the programmer was not looking is intellectually dishonest as it
disguises that the error is the programmer's own creation."
	-- E. W. Dijkstra, EWD1036
#8 lore raw

Re: [PATCH 04/26] kbuild: introduce $(kecho) convenience echo

In reply to Sam Ravnborg
Quoted 2 lines · Sam Ravnborg

So declare a new KECHO variable that only does 'echo' when we are in a suitable verbose build mode

maybe you want to change the caps on KECHO in the changelog since it is no longer KECHO but kecho ?
-mike

#9 lore raw

Re: [PATCH 04/26] kbuild: introduce $(kecho) convenience echo

In reply to Sam Ravnborg
Quoted 10 lines · On Sat, 20 Dec 2008 15:31:15 +0100 Sam Ravnborg wrote:

From: Mike Frysinger <[email protected]>

There is a bunch of places in the build system where we do 'echo' to show some nice status lines. This means we still get output when running in silent mode. So declare a new KECHO variable that only does 'echo' when we are in a suitable verbose build mode.

[sam: added Documentation]

Hi,
Just nits/clarifications (below).

Quoted 10 lines
---
 Documentation/kbuild/makefiles.txt |   14 ++++++++++++++
 scripts/Kbuild.include             |    7 +++++++
 2 files changed, 21 insertions(+), 0 deletions(-)
Documentation/kbuild/makefiles.txt +0 -0
index 7a77533..51104f9 100644

Documentation/kbuild/makefiles.txt more details, with real examples. · line 387

Quoted 5 lines
Documentation/kbuild/makefiles.txt +2 -0
@@ -383,6 +383,20 @@ more details, with real examples.
 	to prerequisites are referenced with $(src) (because they are not
 	generated files).
 
+    $(kecho)
+	echoing information to user in a rule is often a good practice

to users

Documentation/kbuild/makefiles.txt more details, with real examples. · line 388

Quoted 1 line
Documentation/kbuild/makefiles.txt +1 -0
+	but when execution "make -s" one does not expect to see any output

executing

Documentation/kbuild/makefiles.txt more details, with real examples. · line 390

Quoted 2 lines
Documentation/kbuild/makefiles.txt +2 -0
+	except for warnings/errors.
+	To support this kbuild define $(kecho) which will echo out the

defines

Documentation/kbuild/makefiles.txt more details, with real examples. · line 391

Quoted 1 line
Documentation/kbuild/makefiles.txt +1 -0
+	text following $(kecho) to stdout except if "make -s" is used.

s/except if/unless/

Documentation/kbuild/makefiles.txt more details, with real examples. · line 402

Quoted 11 lines
Documentation/kbuild/makefiles.txt +8 -0
+
+	Example:
+		#arch/blackfin/boot/Makefile
+		$(obj)/vmImage: $(obj)/vmlinux.gz
+			$(call if_changed,uimage)
+			@$(kecho) 'Kernel: $@ is ready'
+
+
 --- 3.11 $(CC) support functions
 
 	The kernel may be built with several different versions of

---
~Randy

#10 lore raw

PATCH 5/26 kbuild: use KECHO convenience echo

In reply to Sam Ravnborg

From: Mike Frysinger <[email protected]>

Convert a few echos in the build system to new $(kecho) so we get correct output according to build verbosity.

[sam: added kecho in a few more places for O=... builds]
---
 Makefile                    |    8 ++++----
 arch/blackfin/boot/Makefile |    2 +-
 scripts/Kbuild.include      |   11 ++---------
 3 files changed, 7 insertions(+), 14 deletions(-)
Makefile +4 -4
index 3075586..3a6ac68 100644
@@ -926,7 +926,7 @@ PHONY += prepare archprepare prepare0 prepare1 prepare2 prepare3
 # 2) Create the include2 directory, used for the second asm symlink
 prepare3: include/config/kernel.release
 ifneq ($(KBUILD_SRC),)
-	@echo '  Using $(srctree) as source for kernel'
+	@$(kecho) '  Using $(srctree) as source for kernel'
 	$(Q)if [ -f $(srctree)/.config -o -d $(srctree)/include/config ]; then \
 		echo "  $(srctree) is not clean, please run 'make mrproper'";\
 		echo "  in the '$(srctree)' directory.";\
@@ -983,7 +983,7 @@ endef
 # directory for generated filesas used by some architectures.
 define create-symlink
 	if [ ! -L include/asm ]; then                                      \
-			echo '  SYMLINK $@ -> include/asm-$(SRCARCH)';     \
+			$(kecho) '  SYMLINK $@ -> include/asm-$(SRCARCH)'; \
 			if [ ! -d include/asm-$(SRCARCH) ]; then           \
 				mkdir -p include/asm-$(SRCARCH);           \
 			fi;                                                \
@@ -1096,7 +1096,7 @@ all: modules
 PHONY += modules
 modules: $(vmlinux-dirs) $(if $(KBUILD_BUILTIN),vmlinux)
 	$(Q)$(AWK) '!x[$$0]++' $(vmlinux-dirs:%=$(objtree)/%/modules.order) > $(objtree)/modules.order
-	@echo '  Building modules, stage 2.';
+	@$(kecho) '  Building modules, stage 2.';
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.fwinst obj=firmware __fw_modbuild
 
@@ -1360,7 +1360,7 @@ $(module-dirs): crmodverdir $(objtree)/Module.symvers
 	$(Q)$(MAKE) $(build)=$(patsubst _module_%,%,$@)
 
 modules: $(module-dirs)
-	@echo '  Building modules, stage 2.';
+	@$(kecho) '  Building modules, stage 2.';
 	$(Q)$(MAKE) -f $(srctree)/scripts/Makefile.modpost
 
 PHONY += modules_install
arch/blackfin/boot/Makefile +1 -1
index 522f3c1..e028d13 100644
@@ -25,7 +25,7 @@ $(obj)/vmlinux.gz: $(obj)/vmlinux.bin FORCE
 
 $(obj)/vmImage: $(obj)/vmlinux.gz
 	$(call if_changed,uimage)
-	@echo 'Kernel: $@ is ready'
+	@$(kecho) 'Kernel: $@ is ready'
 
 install:
 	sh $(srctree)/$(src)/install.sh $(KERNELRELEASE) $(BOOTIMAGE) System.map "$(INSTALL_PATH)"
scripts/Kbuild.include +2 -9
index 8cf87e8..c29be8f 100644
@@ -46,22 +46,15 @@ kecho := $($(quiet)kecho)
 # - If they are equal no change, and no timestamp update
 # - stdin is piped in from the first prerequisite ($<) so one has
 #   to specify a valid file as first prerequisite (often the kbuild file)
-       chk_filechk = :
- quiet_chk_filechk = echo '  CHK     $@'
-silent_chk_filechk = :
-       upd_filechk = :
- quiet_upd_filechk = echo '  UPD     $@'
-silent_upd_filechk = :
-
 define filechk
 	$(Q)set -e;				\
-	$($(quiet)chk_filechk);			\
+	$(kecho) '  CHK     $@';		\
 	mkdir -p $(dir $@);			\
 	$(filechk_$(1)) < $< > [email protected];		\
 	if [ -r $@ ] && cmp -s $@ [email protected]; then	\
 		rm -f [email protected];			\
 	else					\
-		$($(quiet)upd_filechk);		\
+		$(kecho) '  UPD     $@';	\
 		mv -f [email protected] $@;		\
 	fi
 endef
Signature · 1 line
1.6.0.2.GIT
#11 lore raw

PATCH 6/26 kbuild: teach mkmakfile to be silent

In reply to Sam Ravnborg

With this fix a "make -s" is now really silent

---
 scripts/mkmakefile |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)
scripts/mkmakefile +3 -1
index e65d8b3..67d59c7 100644
@@ -17,7 +17,9 @@ if test -e $2/Makefile && ! grep -q Automatically $2/Makefile
 then
 	exit 0
 fi
-echo "  GEN     $2/Makefile"
+if [ "${quiet}" != "silent_" ]; then
+	echo "  GEN     $2/Makefile"
+fi
 
 cat << EOF > $2/Makefile
 # Automatically generated by $0: don't edit
Signature · 1 line
1.6.0.2.GIT
#12 lore raw

PATCH 7/26 remove bashisms from scripts/extract-ikconfig

In reply to Sam Ravnborg

From: Werner Almesberger <[email protected]>

unbashify-extract-ikconfig.patch

scripts/extract-ikconfig contains a lot of gratuituous bashisms, which make it fail if /bin/sh isn't bash. This patch replaces them with regular Bourne shell constructs.

---
 scripts/extract-ikconfig |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)
scripts/extract-ikconfig +4 -4
index 8187e6f..72997c3 100755
@@ -8,8 +8,8 @@ test -e $binoffset || cc -o $binoffset ./scripts/binoffset.c || exit 1
 
 IKCFG_ST="0x49 0x4b 0x43 0x46 0x47 0x5f 0x53 0x54"
 IKCFG_ED="0x49 0x4b 0x43 0x46 0x47 0x5f 0x45 0x44"
-function dump_config {
-    typeset file="$1"
+dump_config() {
+    file="$1"
 
     start=`$binoffset $file $IKCFG_ST 2>/dev/null`
     [ "$?" != "0" ] && start="-1"
@@ -18,8 +18,8 @@ function dump_config {
     fi
     end=`$binoffset $file $IKCFG_ED 2>/dev/null`
 
-    let start="$start + 8"
-    let size="$end - $start"
+    start=`expr $start + 8`
+    size=`expr $end - $start`
 
     dd if="$file" ibs=1 skip="$start" count="$size" 2>/dev/null | zcat
 
Signature · 1 line
1.6.0.2.GIT
#13 lore raw

PATCH 8/26 kbuild: gen_init_cpio expands shell variables in file names

In reply to Sam Ravnborg

From: Sally, Gene <[email protected]>

Modify gen_init_cpio so that lines that specify files can contain what looks like a shell variable that's expanded during processing.

For example:

   file /sbin/kinit ${RFS_BASE}/usr/src/klibc/kinit/kinit 0755 0 0

given RFS_BASE is "/some/directory" in the environment

would be expanded to

file /sbin/kinit /some/directory/usr/src/klibc/kinit/kinit 0755 0 0

If several environment variables appear in a line, they are all expanded with processing happening from left to right.
Undefined variables expand to a null string.
Syntax errors stop processing, letting the existing error handling show the user offending line.

This patch helps embedded folks who frequently create several RFS directories and then switch between them as they're tuning an initramfs.

---
 usr/gen_init_cpio.c |   28 +++++++++++++++++++++++++++-
 1 files changed, 27 insertions(+), 1 deletions(-)
usr/gen_init_cpio.c +27 -1
index 7abc07f..f1d3fe3 100644
@@ -370,6 +370,30 @@ error:
 	return rc;
 }
 
+static char *cpio_replace_env(char *new_location)
+{
+       char expanded[PATH_MAX + 1];
+       char env_var[PATH_MAX + 1];
+       char *start;
+       char *end;
+
+       for (start = NULL; (start = strstr(new_location, "${")); ) {
+               end = strchr(start, '}');
+               if (start < end) {
+                       *env_var = *expanded = '\0';
+                       strncat(env_var, start + 2, end - start - 2);
+                       strncat(expanded, new_location, start - new_location);
+                       strncat(expanded, getenv(env_var), PATH_MAX);
+                       strncat(expanded, end + 1, PATH_MAX);
+                       strncpy(new_location, expanded, PATH_MAX);
+               } else
+                       break;
+       }
+
+       return new_location;
+}
+
+
 static int cpio_mkfile_line(const char *line)
 {
 	char name[PATH_MAX + 1];
@@ -415,7 +439,8 @@ static int cpio_mkfile_line(const char *line)
 	} else {
 		dname = name;
 	}
-	rc = cpio_mkfile(dname, location, mode, uid, gid, nlinks);
+	rc = cpio_mkfile(dname, cpio_replace_env(location),
+	                 mode, uid, gid, nlinks);
  fail:
 	if (dname_len) free(dname);
 	return rc;
@@ -439,6 +464,7 @@ void usage(const char *prog)
 		"\n"
 		"<name>       name of the file/dir/nod/etc in the archive\n"
 		"<location>   location of the file in the current filesystem\n"
+		"             expands shell variables quoted with ${}\n"
 		"<target>     link target\n"
 		"<mode>       mode/permissions of the file\n"
 		"<uid>        user id (0=root)\n"
Signature · 1 line
1.6.0.2.GIT
#14 lore raw

PATCH 9/26 kconfig: fix options to check-lxdialog.sh

In reply to Sam Ravnborg

As noted by Bernhard - fix it up.

Cc Bernhard Reutner-Fischer <[email protected]>
---
 scripts/kconfig/lxdialog/check-lxdialog.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/kconfig/lxdialog/check-lxdialog.sh +1 -1
index 5552154..fcef0f5 100644
@@ -52,7 +52,7 @@ EOF
 }
 
 usage() {
-	printf "Usage: $0 [-check compiler options|-header|-library]\n"
+	printf "Usage: $0 [-check compiler options|-ccflags|-ldflags compiler options]\n"
 }
 
 if [ $# -eq 0 ]; then
Signature · 1 line
1.6.0.2.GIT
#15 lore raw

PATCH 10/26 tags and cscope support really belongs in a shell script

In reply to Sam Ravnborg

Moving the support to a shell script has several benefits:
- The readability of the code has increased a lot
- More people is able to extend the tags support
- We see less changes to the top-level Makefile

The shell script version includes improvements from:
Alexey Dobriyan <[email protected]> (jump to kconfig symbols) Alexey Dobriyan <[email protected]> (drop ./ in paths) Ian Campbell <[email protected]> (simplified find algorithms)

This version has a few caveats:
=> It does not support ALLSOURCE_ARCHS
- it is easy to add if it is really used
=> It assumes all archs have moved to arch/$ARCH/include
- until that happens we have a few additional hits in the archs

---
 Makefile        |  117 +---------------------------------------
 scripts/tags.sh |  160 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 163 insertions(+), 114 deletions(-)
 create mode 100755 scripts/tags.sh
Makefile +3 -114
index 3a6ac68..be462cf 100644
@@ -1409,123 +1409,12 @@ endif # KBUILD_EXTMOD
 
 # Generate tags for editors
 # ---------------------------------------------------------------------------
+quiet_cmd_tags = GEN     $@
+      cmd_tags = $(CONFIG_SHELL) $(srctree)/scripts/tags.sh $@
 
-#We want __srctree to totally vanish out when KBUILD_OUTPUT is not set
-#(which is the most common case IMHO) to avoid unneeded clutter in the big tags file.
-#Adding $(srctree) adds about 20M on i386 to the size of the output file!
-
-ifeq ($(src),$(obj))
-__srctree =
-else
-__srctree = $(srctree)/
-endif
-
-ifeq ($(ALLSOURCE_ARCHS),)
-ifeq ($(ARCH),um)
-ALLINCLUDE_ARCHS := $(ARCH) $(SUBARCH)
-else
-ALLINCLUDE_ARCHS := $(SRCARCH)
-endif
-else
-#Allow user to specify only ALLSOURCE_PATHS on the command line, keeping existing behaviour.
-ALLINCLUDE_ARCHS := $(ALLSOURCE_ARCHS)
-endif
-
-ALLSOURCE_ARCHS := $(SRCARCH)
-
-define find-sources
-        ( for arch in $(ALLSOURCE_ARCHS) ; do \
-	       find $(__srctree)arch/$${arch} $(RCS_FIND_IGNORE) \
-		    -wholename $(__srctree)arch/$${arch}/include/asm -type d -prune \
-	            -o -name $1 -print; \
-	  done ; \
-	  find $(__srctree)security/selinux/include $(RCS_FIND_IGNORE) \
-	       -name $1 -print; \
-	  find $(__srctree)include $(RCS_FIND_IGNORE) \
-	       \( -name config -o -name 'asm-*' \) -prune \
-	       -o -name $1 -print; \
-	  for arch in $(ALLINCLUDE_ARCHS) ; do \
-	       test -e $(__srctree)include/asm-$${arch} && \
-                 find $(__srctree)include/asm-$${arch} $(RCS_FIND_IGNORE) \
-	            -name $1 -print; \
-	       test -e $(__srctree)arch/$${arch}/include/asm && \
-	         find $(__srctree)arch/$${arch}/include/asm $(RCS_FIND_IGNORE) \
-	            -name $1 -print; \
-	  done ; \
-	  find $(__srctree)include/asm-generic $(RCS_FIND_IGNORE) \
-	       -name $1 -print; \
-	  find $(__srctree) $(RCS_FIND_IGNORE) \
-	       \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
-	       -name $1 -print; \
-	  )
-endef
-
-define all-sources
-	$(call find-sources,'*.[chS]')
-endef
-define all-kconfigs
-	$(call find-sources,'Kconfig*')
-endef
-define all-defconfigs
-	$(call find-sources,'defconfig')
-endef
-
-define xtags
-	if $1 --version 2>&1 | grep -iq exuberant; then \
-	    $(all-sources) | xargs $1 -a \
-		-I __initdata,__exitdata,__acquires,__releases \
-		-I __read_mostly,____cacheline_aligned,____cacheline_aligned_in_smp,____cacheline_internodealigned_in_smp \
-		-I EXPORT_SYMBOL,EXPORT_SYMBOL_GPL \
-		--extra=+f --c-kinds=+px \
-		--regex-asm='/^ENTRY\(([^)]*)\).*/\1/'; \
-	    $(all-kconfigs) | xargs $1 -a \
-		--langdef=kconfig \
-		--language-force=kconfig \
-		--regex-kconfig='/^[[:blank:]]*(menu|)config[[:blank:]]+([[:alnum:]_]+)/\2/'; \
-	    $(all-defconfigs) | xargs -r $1 -a \
-		--langdef=dotconfig \
-		--language-force=dotconfig \
-		--regex-dotconfig='/^#?[[:blank:]]*(CONFIG_[[:alnum:]_]+)/\1/'; \
-	elif $1 --version 2>&1 | grep -iq emacs; then \
-	    $(all-sources) | xargs $1 -a; \
-	    $(all-kconfigs) | xargs $1 -a \
-		--regex='/^[ \t]*\(\(menu\)*config\)[ \t]+\([a-zA-Z0-9_]+\)/\3/'; \
-	    $(all-defconfigs) | xargs -r $1 -a \
-		--regex='/^#?[ \t]?\(CONFIG_[a-zA-Z0-9_]+\)/\1/'; \
-	else \
-	    $(all-sources) | xargs $1 -a; \
-	fi
-endef
-
-quiet_cmd_cscope-file = FILELST cscope.files
-      cmd_cscope-file = (echo \-k; echo \-q; $(all-sources)) > cscope.files
-
-quiet_cmd_cscope = MAKE    cscope.out
-      cmd_cscope = cscope -b -f cscope.out
-
-cscope: FORCE
-	$(call cmd,cscope-file)
-	$(call cmd,cscope)
-
-quiet_cmd_TAGS = MAKE   $@
-define cmd_TAGS
-	rm -f $@; \
-	$(call xtags,etags)
-endef
-
-TAGS: FORCE
-	$(call cmd,TAGS)
-
-quiet_cmd_tags = MAKE   $@
-define cmd_tags
-	rm -f $@; \
-	$(call xtags,ctags)
-endef
-
-tags: FORCE
+tags TAGS cscope: FORCE
 	$(call cmd,tags)
 
-
 # Scripts to check various things for consistency
 # ---------------------------------------------------------------------------
 
scripts/tags.sh new file +160 -0

160 lines not on this page · raw message

Signature · 1 line
1.6.0.2.GIT
#16 lore raw

PATCH 11/26 genksyms: track symbol checksum changes

In reply to Sam Ravnborg

From: Andreas Gruenbacher <[email protected]>

Sometimes it is preferable to avoid changes of exported symbol checksums (to avoid breaking externally provided modules). When a checksum change occurs, it can be hard to figure out what caused this change: underlying types may have changed, or additional type information may simply have become available at the point where a symbol is exported.

Add a new --reference option to genksyms which allows it to report why checksums change, based on the type information dumps it creates with the --dump-types flag. Genksyms will read in such a dump from a previous run, and report which symbols have changed (and why).

The behavior can be controlled for an entire build as follows: If KBUILD_SYMTYPES is set, genksyms uses --dump-types to produce *.symtypes dump files. If any *.symref files exist, those will be used as the reference to check against. If KBUILD_PRESERVE is set, checksum changes will fail the build.

---
 scripts/Makefile.build      |   16 +++-
 scripts/genksyms/genksyms.c |  236 ++++++++++++++++++++++++++++++++++++++++---
 scripts/genksyms/genksyms.h |    6 +
 3 files changed, 239 insertions(+), 19 deletions(-)
scripts/Makefile.build +13 -3
index 468fbc9..d21f0ea 100644
@@ -153,12 +153,18 @@ $(obj)/%.i: $(src)/%.c FORCE
 
 quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
 cmd_cc_symtypes_c	   = \
+		set -e;							\
 		$(CPP) -D__GENKSYMS__ $(c_flags) $<			\
-		| $(GENKSYMS) -T $@ >/dev/null;				\
+		| $(GENKSYMS) -T $@					\
+			      -r $(firstword $(wildcard			\
+				     $(@:.symtypes=.symref) /dev/null))	\
+			      $(if $(KBUILD_PRESERVE),-p)		\
+			      -a $(ARCH)				\
+		  >/dev/null;						\
 		test -s $@ || rm -f $@
 
 $(obj)/%.symtypes : $(src)/%.c FORCE
-	$(call if_changed_dep,cc_symtypes_c)
+	$(call cmd,cc_symtypes_c)
 
 # C (.c) files
 # The C file is compiled and updated dependency information is generated.
@@ -187,7 +193,11 @@ cmd_modversions =							\
 	if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then	\
 		$(CPP) -D__GENKSYMS__ $(c_flags) $<			\
 		| $(GENKSYMS) $(if $(KBUILD_SYMTYPES),			\
-			      -T $(@D)/$(@F:.o=.symtypes)) -a $(ARCH)	\
+			           -T $(@:.o=.symtypes))		\
+			      -r $(firstword $(wildcard			\
+				     $(@:.o=.symref) /dev/null))	\
+			      $(if $(KBUILD_PRESERVE),-p)		\
+			      -a $(ARCH)				\
 		> $(@D)/.tmp_$(@F:.o=.ver);				\
 									\
 		$(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) 		\
scripts/genksyms/genksyms.c +220 -16

381 lines not on this page · raw message

scripts/genksyms/genksyms.h +6 -0
index 2668287..2831158 100644
@@ -29,6 +29,10 @@ enum symbol_type {
 	SYM_NORMAL, SYM_TYPEDEF, SYM_ENUM, SYM_STRUCT, SYM_UNION
 };
 
+enum symbol_status {
+	STATUS_UNCHANGED, STATUS_DEFINED, STATUS_MODIFIED
+};
+
 struct string_list {
 	struct string_list *next;
 	enum symbol_type tag;
@@ -43,6 +47,8 @@ struct symbol {
 	struct symbol *expansion_trail;
 	struct symbol *visited;
 	int is_extern;
+	int is_declared;
+	enum symbol_status status;
 };
 
 typedef struct string_list **yystype;
Signature · 1 line
1.6.0.2.GIT
#17 lore raw

PATCH 12/26 genksyms: allow to ignore symbol checksum changes

In reply to Sam Ravnborg

From: Andreas Gruenbacher <[email protected]>

This adds an "override" keyword for use in *.symvers / *.symref files. When a symbol is overridden, the symbol's old definition will be used for computing checksums instead of the new one, preserving the previous checksum. (Genksyms will still warn about the change.)

This is meant to allow distributions to hide minor actual as well as fake ABI changes. (For example, when extra type information becomes available because additional headers are included, this may change checksums even though none of the types used have actully changed.)

This approach also allows to get rid of "#ifdef __GENKSYMS__" hacks in the code, which are currently used in some vendor kernels to work around checksum changes.

---
 scripts/genksyms/genksyms.c |   34 ++++++++++++++++++++++++++++++----
 scripts/genksyms/genksyms.h |    1 +
 2 files changed, 31 insertions(+), 4 deletions(-)
scripts/genksyms/genksyms.c +30 -4
index ddac174..3a8297b 100644
@@ -191,11 +191,26 @@ struct symbol *__add_symbol(const char *name, enum symbol_type type,
 				/* fall through */ ;
 			else if (sym->type == type &&
 				 equal_list(sym->defn, defn)) {
+				if (!sym->is_declared && sym->is_override) {
+					print_location();
+					print_type_name(type, name);
+					fprintf(stderr, " modversion is "
+						"unchanged\n");
+				}
 				sym->is_declared = 1;
 				return sym;
 			} else if (!sym->is_declared) {
-				status = is_unknown_symbol(sym) ?
-					STATUS_DEFINED : STATUS_MODIFIED;
+				if (sym->is_override && flag_preserve) {
+					print_location();
+					fprintf(stderr, "ignoring ");
+					print_type_name(type, name);
+					fprintf(stderr, " modversion change\n");
+					sym->is_declared = 1;
+					return sym;
+				} else {
+					status = is_unknown_symbol(sym) ?
+						STATUS_DEFINED : STATUS_MODIFIED;
+				}
 			} else {
 				error_with_pos("redefinition of %s", name);
 				return sym;
@@ -229,6 +244,7 @@ struct symbol *__add_symbol(const char *name, enum symbol_type type,
 
 	sym->is_declared = !is_reference;
 	sym->status = status;
+	sym->is_override = 0;
 
 	if (flag_debug) {
 		fprintf(debugfile, "Defn for %s %s == <",
@@ -348,9 +364,16 @@ static void read_reference(FILE *f)
 	while (!feof(f)) {
 		struct string_list *defn = NULL;
 		struct string_list *sym, *def;
-		int is_extern = 0;
+		int is_extern = 0, is_override = 0;
+		struct symbol *subsym;
 
 		sym = read_node(f);
+		if (sym && sym->tag == SYM_NORMAL &&
+		    !strcmp(sym->string, "override")) {
+			is_override = 1;
+			free_node(sym);
+			sym = read_node(f);
+		}
 		if (!sym)
 			continue;
 		def = read_node(f);
@@ -365,8 +388,9 @@ static void read_reference(FILE *f)
 			defn = def;
 			def = read_node(f);
 		}
-		add_reference_symbol(xstrdup(sym->string), sym->tag,
+		subsym = add_reference_symbol(xstrdup(sym->string), sym->tag,
 					      defn, is_extern);
+		subsym->is_override = is_override;
 		free_node(sym);
 	}
 }
@@ -743,6 +767,8 @@ int main(int argc, char **argv)
 		while (visited_symbols != (struct symbol *)-1L) {
 			struct symbol *sym = visited_symbols;
 
+			if (sym->is_override)
+				fputs("override ", dumpfile);
 			if (sym->type != SYM_NORMAL) {
 				putc(symbol_type_name[sym->type][0], dumpfile);
 				putc('#', dumpfile);
scripts/genksyms/genksyms.h +1 -0
index 2831158..25c4d40 100644
@@ -49,6 +49,7 @@ struct symbol {
 	int is_extern;
 	int is_declared;
 	enum symbol_status status;
+	int is_override;
 };
 
 typedef struct string_list **yystype;
Signature · 1 line
1.6.0.2.GIT
#18 lore raw

PATCH 13/26 scripts/package: allow custom options to rpm

In reply to Sam Ravnborg

From: Jeremy Kerr <[email protected]>

Add a RPMOPTS make variable to allow arbitrary options to be passed to rpm during 'make rpm-pkg'. For example:

make RPMOPTS="--define '_topdir /home/jk/rpm'" rpm-pkg

---
 scripts/package/Makefile |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)
scripts/package/Makefile +3 -2
index 5e32607..c162409 100644
@@ -47,7 +47,7 @@ rpm-pkg rpm: $(objtree)/kernel.spec FORCE
 	set -e; \
 	mv -f $(objtree)/.tmp_version $(objtree)/.version
 
-	$(RPM) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz
+	$(RPM) $(RPMOPTS) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz
 	rm ../$(KERNELPATH).tar.gz
 
 clean-files := $(objtree)/kernel.spec
@@ -64,7 +64,8 @@ binrpm-pkg: $(objtree)/binkernel.spec FORCE
 	set -e; \
 	mv -f $(objtree)/.tmp_version $(objtree)/.version
 
-	$(RPM) --define "_builddir $(srctree)" --target $(UTS_MACHINE) -bb $<
+	$(RPM) $(RPMOPTS) --define "_builddir $(srctree)" --target \
+		$(UTS_MACHINE) -bb $<
 
 clean-files += $(objtree)/binkernel.spec
 
Signature · 1 line
1.6.0.2.GIT
#19 lore raw

PATCH 14/26 scripts: improve the decodecode script

In reply to Sam Ravnborg

From: Arjan van de Ven <[email protected]>

kerneloops.org has been using an improved "decodecode" script, specifically it has a special marker that shows which line in the assembly the oops happened at, like this:

  20:	83 e0 03             	and    $0x3,%eax
  23:	09 d8                	or     %ebx,%eax
  25:	85 db                	test   %ebx,%ebx
  27:	89 02                	mov    %eax,(%edx)
  29:	74 0f                	je     0x3a
  2b:*	3b 73 04             	cmp    0x4(%ebx),%esi     <-- trapping instruction
  2e:	75 05                	jne    0x35
  30:	89 53 04             	mov    %edx,0x4(%ebx)
  33:	eb 07                	jmp    0x3c
  35:	89 53 08             	mov    %edx,0x8(%ebx)

this patch updates the kernel copy to also have this functionality.

---
 scripts/decodecode |   32 ++++++++++++++++++++++----------
 1 files changed, 22 insertions(+), 10 deletions(-)
scripts/decodecode +22 -10
index 235d393..4b00647 100755
@@ -7,7 +7,7 @@
 # AFLAGS=--32 decodecode < 386.oops
 
 cleanup() {
-	rm -f $T $T.s $T.o
+	rm -f $T $T.s $T.o $T.oo $T.aa  $T.aaa
 	exit 1
 }
 
@@ -44,21 +44,33 @@ if [ $marker -eq 0 ]; then
 	marker=`expr index "$code" "\("`
 fi
 
+touch $T.oo
 if [ $marker -ne 0 ]; then
-	beforemark=`echo "$code" | cut -c-$((${marker} - 1))`
+	echo All code >> $T.oo
+	echo ======== >> $T.oo
+	beforemark=`echo "$code"`
 	echo -n "	.byte 0x" > $T.s
-	echo $beforemark | sed -e 's/ /,0x/g' >> $T.s
-	as $AFLAGS -o $T.o $T.s
-	objdump -S $T.o
-	rm $T.o $T.s
+	echo $beforemark | sed -e 's/ /,0x/g' | sed -e 's/<//g' | sed -e 's/>//g' >> $T.s
+	as $AFLAGS -o $T.o $T.s &> /dev/null
+	objdump -S $T.o | grep -v "/tmp" | grep -v "Disassembly" | grep -v "\.text" | grep -v "^$" &> $T.ooo
+	cat $T.ooo >> $T.oo
+	rm -f $T.o $T.s  $T.ooo
 
 # and fix code at-and-after marker
 	code=`echo "$code" | cut -c$((${marker} + 1))-`
 fi
-
+echo Code starting with the faulting instruction  > $T.aa
+echo =========================================== >> $T.aa
 code=`echo $code | sed -e 's/ [<(]/ /;s/[>)] / /;s/ /,0x/g'`
 echo -n "	.byte 0x" > $T.s
 echo $code >> $T.s
-as $AFLAGS -o $T.o $T.s
-objdump -S $T.o
-rm $T $T.s $T.o
+as $AFLAGS -o $T.o $T.s &> /dev/null
+objdump -S $T.o | grep -v "Disassembly" | grep -v "/tmp" | grep -v "\.text" | grep -v "^$" &> $T.aaa
+cat $T.aaa >> $T.aa
+
+faultline=`cat $T.aaa | head -1 | cut -d":" -f2`
+
+cat $T.oo | sed -e "s/\($faultline\)/\*\1     <-- trapping instruction/g"
+echo
+cat $T.aa
+cleanup
Signature · 1 line
1.6.0.2.GIT
#20 lore raw

PATCH 15/26 setlocalversion: print correct subversion revision

In reply to Sam Ravnborg

From: Peter Korsgaard <[email protected]>

Output svn revision of latest change, instead of repo revision as thats what we're interested in (especially when working on a branch/tag).

---
 scripts/setlocalversion |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
scripts/setlocalversion +1 -1
index 72d2335..81d984b 100755
@@ -51,7 +51,7 @@ if hgid=`hg id 2>/dev/null`; then
 fi
 
 # Check for svn and a svn repo.
-if rev=`svn info 2>/dev/null | grep '^Revision'`; then
+if rev=`svn info 2>/dev/null | grep '^Last Changed Rev'`; then
 	rev=`echo $rev | awk '{print $NF}'`
 	changes=`svn status 2>/dev/null | grep '^[AMD]' | wc -l`
 
Signature · 1 line
1.6.0.2.GIT
#21 lore raw

PATCH 16/26 setlocalversion: add git-svn support

In reply to Sam Ravnborg

From: Peter Korsgaard <[email protected]>

Print svn revision in addition to git info on git-svn repos.

---
 scripts/setlocalversion |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
scripts/setlocalversion +5 -0
index 81d984b..f6946cf 100755
@@ -19,6 +19,11 @@ if head=`git rev-parse --verify --short HEAD 2>/dev/null`; then
 		fi
 	fi
 
+	# Is this git on svn?
+	if git config --get svn-remote.svn.url >/dev/null; then
+	        printf -- '-svn%s' "`git-svn find-rev $head`"
+	fi
+
 	# Are there uncommitted changes?
 	git update-index --refresh --unmerged > /dev/null
 	if git diff-index --name-only HEAD | grep -v "^scripts/package" \
Signature · 1 line
1.6.0.2.GIT
#22 lore raw

PATCH 17/26 kbuild: remove TAR_IGNORE

In reply to Sam Ravnborg

From: Robert P. J. Day <[email protected]>

Given that there is no usage of a TAR_IGNORE variable remove it

---
 scripts/package/Makefile |    4 ----
 1 files changed, 0 insertions(+), 4 deletions(-)
scripts/package/Makefile +0 -4
index c162409..8c6b7b0 100644
@@ -1,10 +1,6 @@
 # Makefile for the different targets used to generate full packages of a kernel
 # It uses the generic clean infrastructure of kbuild
 
-# Ignore the following files/directories during tar operation
-TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
-
-
 # RPM target
 # ---------------------------------------------------------------------------
 # The rpm target generates two rpm files:
Signature · 1 line
1.6.0.2.GIT
#23 lore raw

PATCH 18/26 kbuild: fix make incompatibility

In reply to Sam Ravnborg

"Paul Smith" <[email protected]> reported that we would fail to build with a new check that may be enabled in an upcoming version of make.

The error was:

Makefile:442: *** mixed implicit and normal rules. Stop.

The problem is that we did stuff like this:

config %config: ...

The solution was simple - the above was split into two with identical prerequisites and commands.
With only three lines it was not worth to try to avoid the duplication.

---
 Makefile |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)
Makefile +10 -2
index be462cf..95160e5 100644
@@ -439,7 +439,11 @@ ifeq ($(config-targets),1)
 include $(srctree)/arch/$(SRCARCH)/Makefile
 export KBUILD_DEFCONFIG KBUILD_KCONFIG
 
-config %config: scripts_basic outputmakefile FORCE
+config: scripts_basic outputmakefile FORCE
+	$(Q)mkdir -p include/linux include/config
+	$(Q)$(MAKE) $(build)=scripts/kconfig $@
+
+%config: scripts_basic outputmakefile FORCE
 	$(Q)mkdir -p include/linux include/config
 	$(Q)$(MAKE) $(build)=scripts/kconfig $@
 
@@ -1493,7 +1497,11 @@ endif
 	$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 
 # Modules
-/ %/: prepare scripts FORCE
+/: prepare scripts FORCE
+	$(cmd_crmodverdir)
+	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
+	$(build)=$(build-dir)
+%/: prepare scripts FORCE
 	$(cmd_crmodverdir)
 	$(Q)$(MAKE) KBUILD_MODULES=$(if $(CONFIG_MODULES),1) \
 	$(build)=$(build-dir)
Signature · 1 line
1.6.0.2.GIT
#24 lore raw

PATCH 19/26 kbuild: fix make tags/cscope

In reply to Sam Ravnborg

From: Jiri Slaby <[email protected]>

- fix combining O=... and tags
- don't allow * expansion during sh function calls

[sam: use KBUILD_SRC to check if we use O=...]
---
 scripts/tags.sh |   24 ++++++++++++------------
 1 files changed, 12 insertions(+), 12 deletions(-)
scripts/tags.sh +12 -12
index 47274dc..3c814ba 100755
@@ -18,28 +18,28 @@ ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \
           -prune -o"
 
 # Do not use full path is we do not use O=.. builds
-if [ ${src} == ${obj} ]; then
+if [ "${KBUILD_SRC}" == "" ]; then
 	tree=
 else
-	tree=${srctree}
+	tree=${srctree}/
 fi
 
 # find sources in arch/$ARCH
 find_arch_sources()
 {
-	find ${tree}arch/$1 $ignore -name $2 -print;
+	find ${tree}arch/$1 $ignore -name "$2" -print;
 }
 
 # find sources in arch/$1/include
 find_arch_include_sources()
 {
-	find ${tree}arch/$1/include $ignore -name $2 -print;
+	find ${tree}arch/$1/include $ignore -name "$2" -print;
 }
 
 # find sources in include/
 find_include_sources()
 {
-	find ${tree}include $ignore -name config -prune -o -name $1 -print;
+	find ${tree}include $ignore -name config -prune -o -name "$1" -print;
 }
 
 # find sources in rest of tree
@@ -48,27 +48,27 @@ find_other_sources()
 {
 	find ${tree}* $ignore \
 	     \( -name include -o -name arch -o -name '.tmp_*' \) -prune -o \
-	       -name $1 -print;
+	       -name "$1" -print;
 }
 
 find_sources()
 {
-	find_arch_sources $1 $2
-	find_include_sources $2
-	find_other_sources $2
+	find_arch_sources $1 "$2"
+	find_include_sources "$2"
+	find_other_sources "$2"
 }
 
 all_sources()
 {
-	find_sources $SRCARCH *.[chS]
+	find_sources $SRCARCH '*.[chS]'
 	if [ ! -z "$archinclude" ]; then
-		find_arch_include_sources $archinclude *.[chS]
+		find_arch_include_sources $archinclude '*.[chS]'
 	fi
 }
 
 all_kconfigs()
 {
-	find_sources $SRCARCH "Kconfig*"
+	find_sources $SRCARCH 'Kconfig*'
 }
 
 all_defconfigs()
Signature · 1 line
1.6.0.2.GIT
#25 lore raw

PATCH 20/26 kbuild: fix string equality testing in tags.sh

In reply to Sam Ravnborg

From: Jiri Slaby <[email protected]>

Test of string equality in shells is =, not C-like ==.

---
 scripts/tags.sh |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
scripts/tags.sh +5 -5
index 3c814ba..4e75472 100755
@@ -7,7 +7,7 @@
 # Uses the following environment variables:
 # ARCH, SUBARCH, srctree, src, obj
 
-if [ $KBUILD_VERBOSE == 1 ]; then
+if [ "$KBUILD_VERBOSE" = "1" ]; then
 	set -x
 fi
 
@@ -18,7 +18,7 @@ ignore="( -name SCCS -o -name BitKeeper -o -name .svn -o \
           -prune -o"
 
 # Do not use full path is we do not use O=.. builds
-if [ "${KBUILD_SRC}" == "" ]; then
+if [ "${KBUILD_SRC}" = "" ]; then
 	tree=
 else
 	tree=${srctree}/
@@ -135,10 +135,10 @@ xtags()
 
 
 # Support um (which uses SUBARCH)
-if [ ${ARCH} == um ]; then
-	if [ $SUBARCH == i386 ]; then
+if [ "${ARCH}" = "um" ]; then
+	if [ "$SUBARCH" = "i386" ]; then
 		archinclude=x86
-	elif [ $SUBARCH == x86_64 ]; then
+	elif [ "$SUBARCH" = "x86_64" ]; then
 		archinclude=x86
 	else
 		archinclude=${SUBARCH}
Signature · 1 line
1.6.0.2.GIT
#26 lore raw

PATCH 21/26 kbuild: add headerdep used to detect inclusion cycles in header files

In reply to Sam Ravnborg

From: Vegard Nossum <[email protected]>

---
 Makefile             |    7 ++-
 scripts/headerdep.pl |  193 ++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 199 insertions(+), 1 deletions(-)
 create mode 100755 scripts/headerdep.pl
Makefile +6 -1
index 95160e5..e1c5ae8 100644
@@ -1026,6 +1026,10 @@ include/linux/version.h: $(srctree)/Makefile FORCE
 include/linux/utsrelease.h: include/config/kernel.release FORCE
 	$(call filechk,utsrelease.h)
 
+PHONY += headerdep
+headerdep:
+	$(Q)find include/ -name '*.h' | xargs --max-args 1 scripts/headerdep.pl
+
 # ---------------------------------------------------------------------------
 
 PHONY += depend dep
@@ -1274,7 +1278,8 @@ help:
 	@echo  '  versioncheck    - Sanity check on version.h usage'
 	@echo  '  includecheck    - Check for duplicate included header files'
 	@echo  '  export_report   - List the usages of all exported symbols'
-	@echo  '  headers_check   - Sanity check on exported headers'; \
+	@echo  '  headers_check   - Sanity check on exported headers'
+	@echo  '  headerdep       - Detect inclusion cycles in headers'; \
 	 echo  ''
 	@echo  'Kernel packaging:'
 	@$(MAKE) $(build)=$(package-dir) help
scripts/headerdep.pl new file +193 -0

193 lines not on this page · raw message

Signature · 1 line
1.6.0.2.GIT
#27 lore raw

PATCH 22/26 kernel-doc: check for extra kernel-doc notations

In reply to Sam Ravnborg

From: Randy Dunlap <[email protected]>

Add functionality to check for function parameters or structure (or union/typedef/enum) field members that are described in kernel-doc but are not part of the expected (declared) parameters or structure. These generate warnings that are called "Excess" descriptions.

---
 scripts/kernel-doc |   67 +++++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 66 insertions(+), 1 deletions(-)
scripts/kernel-doc +66 -1
index d27aad7..8bb83a1 100755
@@ -289,6 +289,8 @@ my %parameterdescs;
 my @parameterlist;
 my %sections;
 my @sectionlist;
+my $sectcheck;
+my $struct_actual;
 
 my $contents = "";
 my $section_default = "Description";	# default section
@@ -378,10 +380,12 @@ sub dump_section {
 #	print STDERR "parameter def '$1' = '$contents'\n";
 	$name = $1;
 	$parameterdescs{$name} = $contents;
+	$sectcheck = $sectcheck . $name . " ";
     } elsif ($name eq "@\.\.\.") {
 #	print STDERR "parameter def '...' = '$contents'\n";
 	$name = "...";
 	$parameterdescs{$name} = $contents;
+	$sectcheck = $sectcheck . $name . " ";
     } else {
 #	print STDERR "other section '$name' = '$contents'\n";
 	if (defined($sections{$name}) && ($sections{$name} ne "")) {
@@ -1405,21 +1409,25 @@ sub dump_union($$) {
 sub dump_struct($$) {
     my $x = shift;
     my $file = shift;
+    my $nested;
 
     if ($x =~/(struct|union)\s+(\w+)\s*{(.*)}/) {
 	$declaration_name = $2;
 	my $members = $3;
 
 	# ignore embedded structs or unions
-	$members =~ s/{.*}//g;
+	$members =~ s/({.*})//g;
+	$nested = $1;
 
 	# ignore members marked private:
 	$members =~ s/\/\*.*?private:.*?public:.*?\*\///gos;
 	$members =~ s/\/\*.*?private:.*//gos;
 	# strip comments:
 	$members =~ s/\/\*.*?\*\///gos;
+	$nested =~ s/\/\*.*?\*\///gos;
 
 	create_parameterlist($members, ';', $file);
+	check_sections($file, $declaration_name, "struct", $sectcheck, $struct_actual, $nested);
 
 	output_declaration($declaration_name,
 			   'struct',
@@ -1505,6 +1513,14 @@ sub dump_typedef($$) {
     }
 }
 
+sub save_struct_actual($) {
+    my $actual = shift;
+
+    # strip all spaces from the actual param so that it looks like one string item
+    $actual =~ s/\s*//g;
+    $struct_actual = $struct_actual . $actual . " ";
+}
+
 sub create_parameterlist($$$) {
     my $args = shift;
     my $splitter = shift;
@@ -1537,6 +1553,7 @@ sub create_parameterlist($$$) {
 	    $param = $1;
 	    $type = $arg;
 	    $type =~ s/([^\(]+\(\*?)\s*$param/$1/;
+	    save_struct_actual($param);
 	    push_parameter($param, $type, $file);
 	} elsif ($arg) {
 	    $arg =~ s/\s*:\s*/:/g;
@@ -1561,14 +1578,17 @@ sub create_parameterlist($$$) {
 
 	    foreach $param (@args) {
 		if ($param =~ m/^(\*+)\s*(.*)/) {
+		    save_struct_actual($2);
 		    push_parameter($2, "$type $1", $file);
 		}
 		elsif ($param =~ m/(.*?):(\d+)/) {
 		    if ($type ne "") { # skip unnamed bit-fields
+			save_struct_actual($1);
 			push_parameter($1, "$type:$2", $file)
 		    }
 		}
 		else {
+		    save_struct_actual($param);
 		    push_parameter($param, $type, $file);
 		}
 	    }
@@ -1634,6 +1654,46 @@ sub push_parameter($$$) {
 	$parametertypes{$param} = $type;
 }
 
+sub check_sections($$$$$$) {
+	my ($file, $decl_name, $decl_type, $sectcheck, $prmscheck, $nested) = @_;
+	my @sects = split ' ', $sectcheck;
+	my @prms = split ' ', $prmscheck;
+	my $err;
+	my ($px, $sx);
+	my $prm_clean;		# strip trailing "[array size]" and/or beginning "*"
+
+	foreach $sx (0 .. $#sects) {
+		$err = 1;
+		foreach $px (0 .. $#prms) {
+			$prm_clean = $prms[$px];
+			$prm_clean =~ s/\[.*\]//;
+			$prm_clean =~ s/__attribute__\s*\(\([a-z,_\*\s\(\)]*\)\)//;
+			##$prm_clean =~ s/^\**//;
+			if ($prm_clean eq $sects[$sx]) {
+				$err = 0;
+				last;
+			}
+		}
+		if ($err) {
+			if ($decl_type eq "function") {
+				print STDERR "Warning(${file}:$.): " .
+					"Excess function parameter " .
+					"'$sects[$sx]' " .
+					"description in '$decl_name'\n";
+				++$warnings;
+			} else {
+				if ($nested !~ m/\Q$sects[$sx]\E/) {
+				    print STDERR "Warning(${file}:$.): " .
+					"Excess struct/union/enum/typedef member " .
+					"'$sects[$sx]' " .
+					"description in '$decl_name'\n";
+				    ++$warnings;
+				}
+			}
+		}
+	}
+}
+
 ##
 # takes a function prototype and the name of the current file being
 # processed and spits out all the details stored in the global
@@ -1699,6 +1759,9 @@ sub dump_function($$) {
 	return;
     }
 
+	my $prms = join " ", @parameterlist;
+	check_sections($file, $declaration_name, "function", $sectcheck, $prms, "");
+
     output_declaration($declaration_name,
 		       'function',
 		       {'function' => $declaration_name,
@@ -1757,6 +1820,8 @@ sub reset_state {
     @parameterlist = ();
     %sections = ();
     @sectionlist = ();
+    $sectcheck = "";
+    $struct_actual = "";
     $prototype = "";
 
     $state = 0;
Signature · 1 line
1.6.0.2.GIT
#28 lore raw

PATCH 23/26 kbuild: simplify use of genksyms

In reply to Sam Ravnborg

Avoid duplicating long list of options in two places

---
 scripts/Makefile.build |   30 ++++++++++++------------------
 1 files changed, 12 insertions(+), 18 deletions(-)
scripts/Makefile.build +12 -18
index d21f0ea..c1da14b 100644
@@ -151,17 +151,17 @@ cmd_cc_i_c       = $(CPP) $(c_flags)   -o $@ $<
 $(obj)/%.i: $(src)/%.c FORCE
 	$(call if_changed_dep,cc_i_c)
 
+cmd_gensymtypes =                                                           \
+    $(CPP) -D__GENKSYMS__ $(c_flags) $< |                                   \
+    $(GENKSYMS) -T $@ -a $(ARCH)                                            \
+     $(if $(KBUILD_PRESERVE),-p)                                            \
+     $(if $(1),-r $(firstword $(wildcard $(@:.symtypes=.symref) /dev/null)))
+
 quiet_cmd_cc_symtypes_c = SYM $(quiet_modtag) $@
-cmd_cc_symtypes_c	   = \
-		set -e;							\
-		$(CPP) -D__GENKSYMS__ $(c_flags) $<			\
-		| $(GENKSYMS) -T $@					\
-			      -r $(firstword $(wildcard			\
-				     $(@:.symtypes=.symref) /dev/null))	\
-			      $(if $(KBUILD_PRESERVE),-p)		\
-			      -a $(ARCH)				\
-		  >/dev/null;						\
-		test -s $@ || rm -f $@
+cmd_cc_symtypes_c =                                                         \
+    set -e;                                                                 \
+    $(call cmd_gensymtypes, true) >/dev/null;                               \
+    test -s $@ || rm -f $@
 
 $(obj)/%.symtypes : $(src)/%.c FORCE
 	$(call cmd,cc_symtypes_c)
@@ -191,14 +191,8 @@ else
 cmd_cc_o_c = $(CC) $(c_flags) -c -o $(@D)/.tmp_$(@F) $<
 cmd_modversions =							\
 	if $(OBJDUMP) -h $(@D)/.tmp_$(@F) | grep -q __ksymtab; then	\
-		$(CPP) -D__GENKSYMS__ $(c_flags) $<			\
-		| $(GENKSYMS) $(if $(KBUILD_SYMTYPES),			\
-			           -T $(@:.o=.symtypes))		\
-			      -r $(firstword $(wildcard			\
-				     $(@:.o=.symref) /dev/null))	\
-			      $(if $(KBUILD_PRESERVE),-p)		\
-			      -a $(ARCH)				\
-		> $(@D)/.tmp_$(@F:.o=.ver);				\
+		$(call cmd_gensymtypes, $(KBUILD_SYMTYPES))		\
+		    > $(@D)/.tmp_$(@F:.o=.ver);				\
 									\
 		$(LD) $(LDFLAGS) -r -o $@ $(@D)/.tmp_$(@F) 		\
 			-T $(@D)/.tmp_$(@F:.o=.ver);			\
Signature · 1 line
1.6.0.2.GIT
#29 lore raw

PATCH 24/26 kbuild: strip generated symbols from *.ko

In reply to Sam Ravnborg

From: Jan Beulich <[email protected]>

This patch changes the way __crc_ symbols are being resolved from using ld to do so to using the assembler, thus allowing these symbols to be marked local (the linker creates then as global ones) and hence allow stripping (for modules) or ignoring (for vmlinux) them. While at this, also strip other generated symbols during module installation.

One potentially debatable point is the handling of the flags passeed to gcc when translating the intermediate assembly file into an object:
passing $(c_flags) unchanged doesn't work as gcc passes --gdwarf2 to gas whenever is sees any -g* option, even for -g0, and despite the fact that the compiler would have already produced all necessary debug info in the C->assembly translation phase. I took the approach of just filtering out all -g* options, but an alternative to such negative filtering might be to have a positive filter which might, in the ideal case allow just all the -Wa,* options to pass through.

---
 Makefile                    |   16 ++++++------
 scripts/Makefile.build      |   55 +++++++++++++++++++++++++++---------------
 scripts/Makefile.modinst    |    3 +-
 scripts/genksyms/genksyms.c |   21 +++++++++++----
 scripts/mksysmap            |    7 +----
 scripts/strip-symbols       |   22 +++++++++++++++++
 6 files changed, 84 insertions(+), 40 deletions(-)
 create mode 100644 scripts/strip-symbols
Makefile +8 -8
index e1c5ae8..5dd0ed3 100644
@@ -605,19 +605,19 @@ MODLIB	= $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
 export MODLIB
 
 #
-#  INSTALL_MOD_STRIP, if defined, will cause modules to be
-#  stripped after they are installed.  If INSTALL_MOD_STRIP is '1', then
-#  the default option --strip-debug will be used.  Otherwise,
-#  INSTALL_MOD_STRIP will used as the options to the strip command.
-
+# INSTALL_MOD_STRIP, if defined, will cause modules to be stripped while
+# they get installed.  If INSTALL_MOD_STRIP is '1', then the default
+# options (see below) will be used.  Otherwise, INSTALL_MOD_STRIP will
+# be used as the option(s) to the objcopy command.
 ifdef INSTALL_MOD_STRIP
 ifeq ($(INSTALL_MOD_STRIP),1)
-mod_strip_cmd = $(STRIP) --strip-debug
+mod_strip_cmd = $(OBJCOPY) --strip-debug --strip-symbols \
+		$(srctree)/scripts/strip-symbols --wildcard
 else
-mod_strip_cmd = $(STRIP) $(INSTALL_MOD_STRIP)
+mod_strip_cmd = $(OBJCOPY) $(INSTALL_MOD_STRIP)
 endif # INSTALL_MOD_STRIP=1
 else
-mod_strip_cmd = true
+mod_strip_cmd = false
 endif # INSTALL_MOD_STRIP
 export mod_strip_cmd
 
scripts/Makefile.build +35 -20

86 lines not on this page · raw message

scripts/Makefile.modinst +2 -1
index efa5d94..a5122dc 100644
@@ -17,7 +17,8 @@ __modinst: $(modules)
 	@:
 
 quiet_cmd_modules_install = INSTALL $@
-      cmd_modules_install = mkdir -p $(2); cp $@ $(2) ; $(mod_strip_cmd) $(2)/$(notdir $@)
+      cmd_modules_install = mkdir -p $(2); \
+			    $(mod_strip_cmd) $@ $(2)/$(notdir $@) || cp $@ $(2)
 
 # Modules built outside the kernel source tree go into extra by default
 INSTALL_MOD_DIR ?= extra
scripts/genksyms/genksyms.c +15 -6
index 3a8297b..f8bb4ca 100644
@@ -43,7 +43,7 @@ int cur_line = 1;
 char *cur_filename;
 
 static int flag_debug, flag_dump_defs, flag_reference, flag_dump_types,
-	   flag_preserve, flag_warnings;
+	   flag_preserve, flag_warnings, flag_asm;
 static const char *arch = "";
 static const char *mod_prefix = "";
 
@@ -610,8 +610,11 @@ void export_symbol(const char *name)
 		if (flag_dump_defs)
 			fputs(">\n", debugfile);
 
-		/* Used as a linker script. */
-		printf("%s__crc_%s = 0x%08lx ;\n", mod_prefix, name, crc);
+		/* Used as assembly source or a linker script. */
+		printf(flag_asm
+		       ? ".equiv %s__crc_%s, %#08lx\n"
+		       : "%s__crc_%s = %#08lx ;\n",
+		       mod_prefix, name, crc);
 	}
 }
 
@@ -648,9 +651,10 @@ void error_with_pos(const char *fmt, ...)
 
 static void genksyms_usage(void)
 {
-	fputs("Usage:\n" "genksyms [-adDTwqhV] > /path/to/.tmp_obj.ver\n" "\n"
+	fputs("Usage:\n" "genksyms [-aAdDTwqhV] > /path/to/.tmp_obj.ver\n" "\n"
 #ifdef __GNU_LIBRARY__
 	      "  -a, --arch            Select architecture\n"
+	      "  -A, --asm             Generate assembly rather than linker script\n"
 	      "  -d, --debug           Increment the debug level (repeatable)\n"
 	      "  -D, --dump            Dump expanded symbol defs (for debugging only)\n"
 	      "  -r, --reference file  Read reference symbols from a file\n"
@@ -662,6 +666,7 @@ static void genksyms_usage(void)
 	      "  -V, --version         Print the release version\n"
 #else				/* __GNU_LIBRARY__ */
 	      "  -a                    Select architecture\n"
+	      "  -A                    Generate assembly rather than linker script\n"
 	      "  -d                    Increment the debug level (repeatable)\n"
 	      "  -D                    Dump expanded symbol defs (for debugging only)\n"
 	      "  -r file               Read reference symbols from a file\n"
@@ -683,6 +688,7 @@ int main(int argc, char **argv)
 #ifdef __GNU_LIBRARY__
 	struct option long_opts[] = {
 		{"arch", 1, 0, 'a'},
+		{"asm", 0, 0, 'A'},
 		{"debug", 0, 0, 'd'},
 		{"warnings", 0, 0, 'w'},
 		{"quiet", 0, 0, 'q'},
@@ -695,10 +701,10 @@ int main(int argc, char **argv)
 		{0, 0, 0, 0}
 	};
 
-	while ((o = getopt_long(argc, argv, "a:dwqVDr:T:ph",
+	while ((o = getopt_long(argc, argv, "a:dwqVADr:T:ph",
 				&long_opts[0], NULL)) != EOF)
 #else				/* __GNU_LIBRARY__ */
-	while ((o = getopt(argc, argv, "a:dwqVDr:T:ph")) != EOF)
+	while ((o = getopt(argc, argv, "a:dwqVADr:T:ph")) != EOF)
 #endif				/* __GNU_LIBRARY__ */
 		switch (o) {
 		case 'a':
@@ -716,6 +722,9 @@ int main(int argc, char **argv)
 		case 'V':
 			fputs("genksyms version 2.5.60\n", stderr);
 			break;
+		case 'A':
+			flag_asm = 1;
+			break;
 		case 'D':
 			flag_dump_defs = 1;
 			break;
scripts/mksysmap +2 -5
index 6e133a0..1db316a 100644
@@ -37,9 +37,6 @@
 
 # readprofile starts reading symbols when _stext is found, and
 # continue until it finds a symbol which is not either of 'T', 't',
-# 'W' or 'w'. __crc_ are 'A' and placed in the middle
-# so we just ignore them to let readprofile continue to work.
-# (At least sparc64 has __crc_ in the middle).
-
-$NM -n $1 | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $2
+# 'W' or 'w'.
 
+$NM -n $1 | grep -v '\( [aNUw] \)\|\( \$[adt]\)' > $2
scripts/strip-symbols new file +22 -0
new file mode 100644
index 0000000..29ee8c1
@@ -0,0 +1,22 @@
+<*>
+*.h
+__compound_literal[$.][0-9]*
+__crc_[a-zA-Z_]*
+__exitcall_[a-zA-Z_]*
+__func__[$.][0-9]*
+__FUNCTION__[$.][0-9]*
+gcc[0-9]_compiled[$.]
+__initcall_[a-zA-Z_]*
+__kcrctab_[a-zA-Z_]*
+__kstrtab_[a-zA-Z_]*
+__ksymtab_[a-zA-Z_]*
+__mod_[a-zA-Z_]*[0-9]
+__module_depends
+__param_[a-zA-Z_]*
+__pci_fixup_*PCI_ANY_IDPCI_ANY_ID*
+__pci_fixup_*PCI_ANY_IDPCI_DEVICE_ID_*
+__pci_fixup_*PCI_VENDOR_ID_*PCI_ANY_ID*
+__pci_fixup_*PCI_VENDOR_ID_*PCI_DEVICE_ID_*
+__PRETTY_FUNCTION__[$.][0-9]*
+__setup_[a-zA-Z_]*
+____versions
Signature · 1 line
1.6.0.2.GIT
#30 lore raw

PATCH 25/26 allow stripping of generated symbols under CONFIG_KALLSYMS_ALL

In reply to Sam Ravnborg

From: Jan Beulich <[email protected]>

Building upon parts of the module stripping patch, this patch introduces similar stripping for vmlinux when CONFIG_KALLSYMS_ALL=y. Using CONFIG_KALLSYMS_STRIP_GENERATED reduces the overhead of CONFIG_KALLSYMS_ALL from 245k/310k to 65k/80k for the (i386/x86-64) kernels I tested with.

The patch also does away with the need to special case the kallsyms- internal symbols by making them available even in the first linking stage.

While it is a generated file, the patch includes the changes to scripts/genksyms/keywords.c_shipped, as I'm unsure what the procedure here is.

---
 Makefile                            |   47 +++++++--
 arch/x86/scripts/strip-symbols      |    1 +
 init/Kconfig                        |    7 ++
 kernel/kallsyms.c                   |   16 +--
 scripts/genksyms/keywords.c_shipped |  189 ++++++++++++++++++-----------------
 scripts/genksyms/keywords.gperf     |    2 +
 scripts/kallsyms.c                  |   21 ++---
 7 files changed, 155 insertions(+), 128 deletions(-)
 create mode 100644 arch/x86/scripts/strip-symbols
Makefile +35 -12
index 5dd0ed3..b3d1c8f 100644
@@ -604,6 +604,9 @@ export	INSTALL_PATH ?= /boot
 MODLIB	= $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)
 export MODLIB
 
+strip-symbols := $(srctree)/scripts/strip-symbols \
+		 $(wildcard $(srctree)/arch/$(ARCH)/scripts/strip-symbols)
+
 #
 # INSTALL_MOD_STRIP, if defined, will cause modules to be stripped while
 # they get installed.  If INSTALL_MOD_STRIP is '1', then the default
@@ -611,8 +614,10 @@ export MODLIB
 # be used as the option(s) to the objcopy command.
 ifdef INSTALL_MOD_STRIP
 ifeq ($(INSTALL_MOD_STRIP),1)
-mod_strip_cmd = $(OBJCOPY) --strip-debug --strip-symbols \
-		$(srctree)/scripts/strip-symbols --wildcard
+mod_strip_cmd = $(OBJCOPY) --strip-debug
+ifeq ($(CONFIG_KALLSYMS_ALL),$(CONFIG_KALLSYMS_STRIP_GENERATED))
+mod_strip_cmd += --wildcard $(addprefix --strip-symbols ,$(strip-symbols))
+endif
 else
 mod_strip_cmd = $(OBJCOPY) $(INSTALL_MOD_STRIP)
 endif # INSTALL_MOD_STRIP=1
@@ -747,6 +752,7 @@ last_kallsyms := 2
 endif
 
 kallsyms.o := .tmp_kallsyms$(last_kallsyms).o
+kallsyms.h := $(wildcard include/config/kallsyms/*.h) $(wildcard include/config/kallsyms/*/*.h)
 
 define verify_kallsyms
 	$(Q)$(if $($(quiet)cmd_sysmap),                                      \
@@ -771,24 +777,41 @@ endef
 
 # Generate .S file with all kernel symbols
 quiet_cmd_kallsyms = KSYM    $@
-      cmd_kallsyms = $(NM) -n $< | $(KALLSYMS) \
-                     $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) > $@
+      cmd_kallsyms = { test $* -eq 0 || $(NM) -n $<; } \
+		     | $(KALLSYMS) $(if $(CONFIG_KALLSYMS_ALL),--all-symbols) >$@
 
-.tmp_kallsyms1.o .tmp_kallsyms2.o .tmp_kallsyms3.o: %.o: %.S scripts FORCE
+quiet_cmd_kstrip = STRIP   $@
+      cmd_kstrip = $(OBJCOPY) --wildcard $(addprefix --strip$(if $(CONFIG_RELOCATABLE),-unneeded)-symbols ,$(filter %/scripts/strip-symbols,$^)) $< $@
+
+$(foreach n,0 1 2 3,.tmp_kallsyms$(n).o): KBUILD_AFLAGS += -Wa,--strip-local-absolute
+$(foreach n,0 1 2 3,.tmp_kallsyms$(n).o): %.o: %.S scripts FORCE
 	$(call if_changed_dep,as_o_S)
 
-.tmp_kallsyms%.S: .tmp_vmlinux% $(KALLSYMS)
+ifeq ($(CONFIG_KALLSYMS_STRIP_GENERATED),y)
+strip-ext := .stripped
+endif
+
+.tmp_kallsyms%.S: .tmp_vmlinux%$(strip-ext) $(KALLSYMS) $(kallsyms.h)
 	$(call cmd,kallsyms)
 
+# make -jN seems to have problems with intermediate files, see bug #3330.
+.SECONDARY: $(foreach n,1 2 3,.tmp_vmlinux$(n).stripped)
+.tmp_vmlinux%.stripped: .tmp_vmlinux% $(strip-symbols) $(kallsyms.h)
+	$(call cmd,kstrip)
+
+ifneq ($(CONFIG_DEBUG_INFO),y)
+.tmp_vmlinux%: LDFLAGS_vmlinux += -S
+endif
 # .tmp_vmlinux1 must be complete except kallsyms, so update vmlinux version
-.tmp_vmlinux1: $(vmlinux-lds) $(vmlinux-all) FORCE
-	$(call if_changed_rule,ksym_ld)
+.tmp_vmlinux%: $(vmlinux-lds) $(vmlinux-all) FORCE
+	$(if $(filter 1,$*),$(call if_changed_rule,ksym_ld),$(call if_changed,vmlinux__))
 
-.tmp_vmlinux2: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms1.o FORCE
-	$(call if_changed,vmlinux__)
+.tmp_vmlinux0$(strip-ext):
+	$(Q)echo "placeholder" >$@
 
-.tmp_vmlinux3: $(vmlinux-lds) $(vmlinux-all) .tmp_kallsyms2.o FORCE
-	$(call if_changed,vmlinux__)
+.tmp_vmlinux1: .tmp_kallsyms0.o
+.tmp_vmlinux2: .tmp_kallsyms1.o
+.tmp_vmlinux3: .tmp_kallsyms2.o
 
 # Needs to visit scripts/ before $(KALLSYMS) can be used.
 $(KALLSYMS): scripts ;
arch/x86/scripts/strip-symbols new file +1 -0
new file mode 100644
index 0000000..a2f1ccb
@@ -0,0 +1 @@
+__cpu_vendor_dev_X86_VENDOR_*
init/Kconfig +7 -0
index f763762..0f5af40 100644
@@ -588,6 +588,13 @@ config KALLSYMS_ALL
 
 	   Say N.
 
+config KALLSYMS_STRIP_GENERATED
+	bool "Strip machine generated symbols from kallsyms"
+	depends on KALLSYMS_ALL
+	default y
+	help
+	  Say N if you want kallsyms to retain even machine generated symbols.
+
 config KALLSYMS_EXTRA_PASS
 	bool "Do an extra kallsyms pass"
 	depends on KALLSYMS
kernel/kallsyms.c +6 -10
index 7b8b0f2..e694afa 100644
@@ -30,20 +30,19 @@
 #define all_var 0
 #endif
 
-/* These will be re-linked against their real values during the second link stage */
-extern const unsigned long kallsyms_addresses[] __attribute__((weak));
-extern const u8 kallsyms_names[] __attribute__((weak));
+extern const unsigned long kallsyms_addresses[];
+extern const u8 kallsyms_names[];
 
 /* tell the compiler that the count isn't in the small data section if the arch
  * has one (eg: FRV)
  */
 extern const unsigned long kallsyms_num_syms
-__attribute__((weak, section(".rodata")));
+	__attribute__((__section__(".rodata")));
 
-extern const u8 kallsyms_token_table[] __attribute__((weak));
-extern const u16 kallsyms_token_index[] __attribute__((weak));
+extern const u8 kallsyms_token_table[];
+extern const u16 kallsyms_token_index[];
 
-extern const unsigned long kallsyms_markers[] __attribute__((weak));
+extern const unsigned long kallsyms_markers[];
 
 static inline int is_kernel_inittext(unsigned long addr)
 {
@@ -168,9 +167,6 @@ static unsigned long get_symbol_pos(unsigned long addr,
 	unsigned long symbol_start = 0, symbol_end = 0;
 	unsigned long i, low, high, mid;
 
-	/* This kernel should never had been booted. */
-	BUG_ON(!kallsyms_addresses);
-
 	/* do a binary search on the sorted kallsyms_addresses array */
 	low = 0;
 	high = kallsyms_num_syms;
scripts/genksyms/keywords.c_shipped +96 -93

255 lines not on this page · raw message

scripts/genksyms/keywords.gperf +2 -0
index 5ef3733..8abe7ab 100644
@@ -5,6 +5,8 @@ struct resword { const char *name; int token; }
 EXPORT_SYMBOL, EXPORT_SYMBOL_KEYW
 EXPORT_SYMBOL_GPL, EXPORT_SYMBOL_KEYW
 EXPORT_SYMBOL_GPL_FUTURE, EXPORT_SYMBOL_KEYW
+EXPORT_UNUSED_SYMBOL, EXPORT_SYMBOL_KEYW
+EXPORT_UNUSED_SYMBOL_GPL, EXPORT_SYMBOL_KEYW
 __asm, ASM_KEYW
 __asm__, ASM_KEYW
 __attribute, ATTRIBUTE_KEYW
scripts/kallsyms.c +8 -13
index ad2434b..9275812 100644
@@ -130,18 +130,9 @@ static int read_symbol(FILE *in, struct sym_entry *s)
 static int symbol_valid(struct sym_entry *s)
 {
 	/* Symbols which vary between passes.  Passes 1 and 2 must have
-	 * identical symbol lists.  The kallsyms_* symbols below are only added
-	 * after pass 1, they would be included in pass 2 when --all-symbols is
-	 * specified so exclude them to get a stable symbol list.
+	 * identical symbol lists.
 	 */
 	static char *special_symbols[] = {
-		"kallsyms_addresses",
-		"kallsyms_num_syms",
-		"kallsyms_names",
-		"kallsyms_markers",
-		"kallsyms_token_table",
-		"kallsyms_token_index",
-
 	/* Exclude linker generated symbols which vary between passes */
 		"_SDA_BASE_",		/* ppc */
 		"_SDA2_BASE_",		/* ppc */
@@ -173,7 +164,9 @@ static int symbol_valid(struct sym_entry *s)
 	}
 
 	/* Exclude symbols which vary between passes. */
-	if (strstr((char *)s->sym + offset, "_compiled."))
+	if (strstr((char *)s->sym + offset, "_compiled.") ||
+	    strncmp((char*)s->sym + offset, "__compound_literal.", 19) == 0 ||
+	    strncmp((char*)s->sym + offset, "__compound_literal$", 19) == 0)
 		return 0;
 
 	for (i = 0; special_symbols[i]; i++)
@@ -550,8 +543,10 @@ int main(int argc, char **argv)
 		usage();
 
 	read_map(stdin);
-	sort_symbols();
-	optimize_token_table();
+	if (table_cnt) {
+		sort_symbols();
+		optimize_token_table();
+	}
 	write_src();
 
 	return 0;
Signature · 1 line
1.6.0.2.GIT
#31 lore raw

PATCH 26/26 kbuild: support switching source directories with O=.. builds

In reply to Sam Ravnborg

It was not possible to use the same output directory for two different source repositories becuase the asm symlink in include2/asm would point to the first repository.

We now create the symlink each time thus allowing switch between different source repositories.

This feature was requested by Andi Kleen.

---
 Makefile |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
Makefile +1 -1
index b3d1c8f..2da055c 100644
@@ -961,8 +961,8 @@ ifneq ($(KBUILD_SRC),)
 	fi;
 	$(Q)if [ ! -d include2 ]; then                                  \
 	    mkdir -p include2;                                          \
-	    ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm;     \
 	fi
+	$(Q)ln -fsn $(srctree)/include/asm-$(SRCARCH) include2/asm
 endif
 
 # prepare2 creates a makefile if using a separate output directory
Signature · 1 line
1.6.0.2.GIT
#32 lore raw

Re: [PATCH 26/26] kbuild: support switching source directories with O=.. builds

Quoted 8 lines · Sam Ravnborg

It was not possible to use the same output directory for two different source repositories becuase the asm symlink in include2/asm would point to the first repository.

We now create the symlink each time thus allowing switch between different source repositories.

This feature was requested by Andi Kleen.

Thanks. But it's not really a new feature, this used to work and just broke at some point. I would consider it a regression fix.

-Andi

#33 lore raw

Re: [PATCH 26/26] kbuild: support switching source directories with O=.. builds

Quoted 5 lines · Andi Kleen
Quoted 4 lines · Sam Ravnborg

It was not possible to use the same output directory for two different source repositories becuase the asm symlink in include2/asm would point to the first repository.

Quoted 7 lines
Quoted 4 lines

We now create the symlink each time thus allowing switch between different source repositories.

This feature was requested by Andi Kleen.

Thanks. But it's not really a new feature, this used to work and just broke at some point. I would consider it a regression fix.

I will reword if I need to rebase anyway.

But that said it has never been a planned feature and with a single report of broken behaviour so far it is not widely used. In other words not stable material etc.

Sam