Re: [kbuild-devel] [PATCH] Precompiled headers

2007-06-05 Thread Arnd Bergmann
On Tuesday 05 June 2007, Vegard Nossum wrote:
  You also need to take some care about the gcc arguments that you pass.
  E.g. passing -DMODULE when building the precompiled header means that
  you can't use that .pch when you build a file where you don't pass
  -DMODULE.
 
 So does it make sense to build two precompiled headers (one with
 CFLAGS_KERNEL, one with CFLAGS_MODULE), and then pass -include
 kernel.h.gch and -include module.h.gch for kernel/built-in modules and
 loadable modules, respectively? I think I'll try it out and see how it
 goes.

Yes, that sounds reasonable. But you should check also the other gcc
options, e.g. KBUILD_MODNAME is defined in a different way for every
module. Consequently, you must not include any header that uses
this symbol when building your .gch files.

Arnd 

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel


Re: [kbuild-devel] [PATCH] Precompiled headers

2007-06-05 Thread Arnd Bergmann
On Tuesday 05 June 2007, Sam Ravnborg wrote:
 It's stuff like this that worries me..
 In the kernel we rely on a lot of things - more than in usual projects.
 And one thing we have established in the 2.6 kernel is a trust in the
 build system. If you change something kbuild will recompile
 everything needed to build a consistent kernel.

Right, it definitely needs to stay optional, because it can only
speed up some cases but not others. An example of where pch may
help is building rpm/deb packages.

 Whatever we do for precompiled headers shall keep the promise
 and the trust in kbuild.

Right.

Arnd 

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel


[kbuild-devel] [PATCH] Precompiled headers

2007-05-31 Thread Vegard Nossum
Hello,

I decided to try out the header precompilation feature of newer GCCs
to see if it would speed up kernel building. Following is a patch
which 1) adds headers target to top-level makefile, 2) allows and
compiles .h files into .h.gch using gcc. When gcc compiles the normal
C files, it looks for the precompiled headers by default, and no
change is needed.

I am not a kbuild expert, so I want to ask if my changes are done
correctly. It seems to me that the build in fact slows down
tremendously, and I don't know why. It seems that the last make does
nothing at all for a long time before finally starting as normal, so
most of the extra time comes from before anything is compiled at
all. For instance, just compiling the kernel/ subdir with and without
the precompiled headers:

make clean scripts/; time make kernel/
real0m27.174s
user0m23.760s
sys 0m3.003s

make clean scripts/; make headers; time make kernel/
real0m53.076s
user0m25.211s
sys 0m4.155s

By the way, according to the GCC manual [1], Only one precompiled
header can be used in a particular compilation, which, if I interpret
it correctly, might make header precompilation useless for the kernel
anyway. But here's my attempt (I hope the patch comes through okay).

Kind regards,
Vegard Nossum

[1] http://gcc.gnu.org/onlinedocs/gcc/Precompiled-Headers.html


From 41d6eeab27442cec728596123bb6f4ecb143b9a3 Mon Sep 17 00:00:00 2001
From: Vegard Nossum [EMAIL PROTECTED]
Date: Wed, 30 May 2007 19:01:10 +0200
Subject: [PATCH] [kbuild] Added support for precompiled headers

---
 Makefile   |   13 -
 scripts/Makefile.build |   18 ++
 2 files changed, 30 insertions(+), 1 deletions(-)

diff --git a/Makefile b/Makefile
index 562a909..48f2b68 100644
--- a/Makefile
+++ b/Makefile
@@ -1046,7 +1046,7 @@ clean: archclean $(clean-dirs)
@find . $(RCS_FIND_IGNORE) \
\( -name '*.[oas]' -o -name '*.ko' -o -name '.*.cmd' \
-o -name '.*.d' -o -name '.*.tmp' -o -name '*.mod.c' \
-   -o -name '*.symtypes' \) \
+   -o -name '*.symtypes' -o -name '*.h.gch' \) \
-type f -print | xargs rm -f

 # mrproper - Delete all generated files, including .config
@@ -1116,6 +1116,7 @@ help:
@echo  '  cscope  - Generate cscope index'
@echo  '  kernelrelease   - Output the release version string'
@echo  '  kernelversion   - Output the version stored in Makefile'
+   @echo  '  headers - Build precompiled headers'
@if [ -r $(srctree)/include/asm-$(ARCH)/Kbuild ]; then \
 echo  '  headers_install - Install sanitised kernel headers to
INSTALL_HDR_PATH'; \
 echo  '(default: $(INSTALL_HDR_PATH))'; \
@@ -1252,6 +1253,14 @@ prepare: ;
 scripts: ;
 endif # KBUILD_EXTMOD

+
+# Compile headers
+# ---
+
+headers: FORCE
+   $(Q)$(MAKE) -i $(build)=include
+
+
 # Generate tags for editors
 # ---

@@ -1424,6 +1433,8 @@ else
 target-dir = $(if $(KBUILD_EXTMOD),$(dir $),$(dir $@))
 endif

+%.h.gch: %.h prepare scripts FORCE
+   $(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.s: %.c prepare scripts FORCE
$(Q)$(MAKE) $(build)=$(build-dir) $(target-dir)$(notdir $@)
 %.i: %.c prepare scripts FORCE
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index a525112..b9ec464 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -78,10 +78,16 @@ ifneq ($(strip $(obj-y) $(obj-m) $(obj-n) $(obj-)
$(lib-target)),)
 builtin-target := $(obj)/built-in.o
 endif

+# Extract subdirs and header targets from header-y
+subdir-ym += $(patsubst %,$(src)/%,$(patsubst %/,%,$(filter %/,$(header-y
+cheader-y += $(patsubst %.h,$(patsubst %/,%,$(obj))/%.h.gch,$(filter
%.h,$(header-y)))
+cheader-y += $(patsubst %.h,$(patsubst %/,%,$(obj))/%.h.gch,$(filter
%.h,$(unifdef-y)))
+
 # We keep a list of all modules in $(MODVERDIR)

 __build: $(if $(KBUILD_BUILTIN),$(builtin-target) $(lib-target) $(extra-y)) \
 $(if $(KBUILD_MODULES),$(obj-m)) \
+$(cheader-y) \
 $(subdir-ym) $(always)
@:

@@ -97,6 +103,18 @@ ifneq ($(KBUILD_CHECKSRC),0)
 endif


+# Compile header files (.h)
+# ---
+
+quiet_cmd_cc_h_gch_h = CC $(quiet_modtag)  $@
+  cmd_cc_h_gch_h = $(CC) $(c_flags) -o $@ $
+
+$(obj)/%.h.gch: $(src)/%.h FORCE
+   $(call if_changed_dep,cc_h_gch_h)
+
+targets += $(cheader-y)
+
+
 # Compile C sources (.c)
 # ---

-- 
1.5.0.6

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No 

Re: [kbuild-devel] [PATCH] Precompiled headers

2007-05-31 Thread Arnd Bergmann
On Thursday 31 May 2007, Vegard Nossum wrote:
 By the way, according to the GCC manual [1], Only one precompiled
 header can be used in a particular compilation, which, if I interpret
 it correctly, might make header precompilation useless for the kernel
 anyway. But here's my attempt (I hope the patch comes through okay).

It should be possible to make it work, but not the way you tried.
One way that might be feasible is to have a single header file precompiled,
and make that include all the common files (fs.h, mm.h, module.h, autoconf.h,
sched.h, init.h). You then need to pass that header file to gcc as the
first one that is included, using the '-include' argument.

You also need to take some care about the gcc arguments that you pass.
E.g. passing -DMODULE when building the precompiled header means that
you can't use that .pch when you build a file where you don't pass
-DMODULE.

Arnd 

-
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
___
kbuild-devel mailing list
kbuild-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kbuild-devel