Patchwork ccache aware romcc

login
register
about
Submitter Patrick Georgi
Date 2010-03-25 18:57:42
Message ID <4BABB226.1010304@georgi-clan.de>
Download mbox | patch
Permalink /patch/1155/
State Accepted
Headers show

Comments

Patrick Georgi - 2010-03-25 18:57:42
>> Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
>>
Updated patch: ccache defaults to "no" for CC, HOSTCC and ROMCC, and can
be configured by Kconfig.
abuild is extended to draw in ccache as well.

Complete abuild run on our build server:
without ccache: 17 minutes
first time with ccache: 16 minutes
second time with ccache (same revision): 9 minutes

Still
Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
Stefan Reinauer - 2010-03-25 21:40:01
On 3/25/10 7:57 PM, Patrick Georgi wrote:
>>> Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
>>>
>>>       
> Updated patch: ccache defaults to "no" for CC, HOSTCC and ROMCC, and can
> be configured by Kconfig.
> abuild is extended to draw in ccache as well.
>
> Complete abuild run on our build server:
> without ccache: 17 minutes
> first time with ccache: 16 minutes
> second time with ccache (same revision): 9 minutes
>
> Still
> Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
>   
Acked-by: Stefan Reinauer <stepan@coresystems.de>

Patch

Index: src/Kconfig
===================================================================
--- src/Kconfig	(revision 5290)
+++ src/Kconfig	(working copy)
@@ -62,6 +62,7 @@ 
 config SCANBUILD_ENABLE
 	bool "Build with scan-build for static analysis"
 	default n
+	depends on !CCACHE
 	help
 	  Changes the build process to scan-build is used.
 	  Requires scan-build in path.
@@ -73,6 +74,13 @@ 
 	help
 	  Where the scan-build report should be stored
 
+config CCACHE
+	bool "ccache"
+	default n
+	help
+	  Enables the use of ccache for faster builds.
+	  Requires ccache in path.
+
 endmenu
 
 source src/mainboard/Kconfig
Index: src/arch/i386/Makefile.bootblock.inc
===================================================================
--- src/arch/i386/Makefile.bootblock.inc	(revision 5290)
+++ src/arch/i386/Makefile.bootblock.inc	(working copy)
@@ -71,7 +71,7 @@ 
 	@printf "    ROMCC      $(subst $(obj)/,,$(@))\n"
 	$(CC) -MM -MT$(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc \
 		$< > $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.inc.d
-	$(obj)/romcc $(bootblock_romccflags) $(ROMCCFLAGS) $(INCLUDES) $< -o $@
+	$(ROMCC) -c -S $(bootblock_romccflags) $(ROMCCFLAGS) -I. $(INCLUDES) $< -o $@
 
 $(obj)/bootblock.elf: $(obj)/mainboard/$(MAINBOARDDIR)/bootblock.o $(obj)/bootblock/ldscript.ld
 	@printf "    LINK       $(subst $(obj)/,,$(@))\n"
Index: src/arch/i386/Makefile.inc
===================================================================
--- src/arch/i386/Makefile.inc	(revision 5290)
+++ src/arch/i386/Makefile.inc	(working copy)
@@ -195,7 +195,7 @@ 
 
 $(obj)/mainboard/$(MAINBOARDDIR)/romstage.inc: $(src)/mainboard/$(MAINBOARDDIR)/romstage.c $(obj)/romcc $(OPTION_TABLE_H) $(obj)/build.h
 	printf "    ROMCC      romstage.inc\n"
-	$(obj)/romcc $(ROMCCFLAGS) -include $(obj)/build.h $(INCLUDES) $< -o $@
+	$(ROMCC) -c -S $(ROMCCFLAGS) -include $(obj)/build.h -I. $(INCLUDES) $< -o $@
 
 else
 
Index: util/abuild/abuild
===================================================================
--- util/abuild/abuild	(revision 5290)
+++ util/abuild/abuild	(working copy)
@@ -55,6 +55,9 @@ 
 # clang mode enabled by -sb option.
 scanbuild=false
 
+# use ccache
+ccache=false
+
 # stackprotect mode enabled by -ns option.
 stackprotect=false
 
@@ -174,6 +177,11 @@ 
 			echo "CONFIG_DEFAULT_CONSOLE_LOGLEVEL=$loglevel" >> .config
 		fi
 
+		if [ "$ccache" = "true" ]; then
+			printf "(ccache enabled) "
+			echo "CONFIG_CCACHE=y" >> .config
+		fi
+
 		if [ "$scanbuild" = "true" ]; then
 			printf "(scan-build enabled) "
 			echo "CONFIG_SCANBUILD_ENABLE=y" >> .config
@@ -495,6 +503,7 @@ 
 	printf "    [-s|--silent]                 omit compiler calls in logs\n"
 	printf "    [-ns|--nostackprotect]        use gcc -fno-stack-protector option\n"
 	printf "    [-sb|--scan-build]            use clang's static analyzer\n"
+	printf "    [-y|--ccache]                 use ccache\n"
 	printf "    [-C|--config]                 configure-only mode\n"
 	printf "    [-l|--loglevel <num>]         set loglevel\n"
 	printf "    [lbroot]			  absolute path to coreboot sources\n"
@@ -530,11 +539,11 @@ 
 getoptbrand="`getopt -V`"
 if [ "${getoptbrand:0:6}" == "getopt" ]; then
 	# Detected GNU getopt that supports long options.
-	args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel: Vvhat:bp:Tc:sxCl: -- "$@"`
+	args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test,cpus:,silent,xml,config,loglevel:,ccache Vvhat:bp:Tc:sxCl:y -- "$@"`
 	eval set "$args"
 else
 	# Detected non-GNU getopt
-	args=`getopt Vvhat:bp:Tc:sxCl:o $*`
+	args=`getopt Vvhat:bp:Tc:sxCl:y $*`
 	set -- $args
 fi
 
@@ -559,6 +568,7 @@ 
 		-s|--silent)    shift; silent="-s";;
 		-ns|--nostackprotect) shift; stackprotect=true;;
 		-sb|--scan-build) shift; scanbuild=true;;
+		-y|--ccache)    shift; ccache=true;;
 		-C|--config)    shift; configureonly=1;;
 		-l|--loglevel)  shift; loglevel="$1"; shift;;
 		--)		shift; break;;
Index: util/romcc/romcc.c
===================================================================
--- util/romcc/romcc.c	(revision 5290)
+++ util/romcc/romcc.c	(working copy)
@@ -24968,10 +24968,14 @@ 
 	state.errout = stderr;
 	state.dbgout = stdout;
 	/* Remember the output filename */
-	state.output    = fopen(state.compiler->ofilename, "w");
-	if (!state.output) {
-		error(&state, 0, "Cannot open output file %s\n",
-			state.compiler->ofilename);
+	if ((state.compiler->flags & COMPILER_PP_ONLY) && (strcmp("auto.inc",state.compiler->ofilename) == 0)) {
+		state.output    = stdout;
+	} else {
+		state.output    = fopen(state.compiler->ofilename, "w");
+		if (!state.output) {
+			error(&state, 0, "Cannot open output file %s\n",
+				state.compiler->ofilename);
+		}
 	}
 	/* Make certain a good cleanup happens */
 	exit_state = &state;
@@ -25146,6 +25150,12 @@ 
 			else if (strncmp(argv[1], "-m", 2) == 0) {
 				result = arch_encode_flag(&arch, argv[1]+2);
 			}
+			else if (strncmp(argv[1], "-c", 2) == 0) {
+				result = 0;
+			}
+			else if (strncmp(argv[1], "-S", 2) == 0) {
+				result = 0;
+			}
 			else if (strncmp(argv[1], "-include", 10) == 0) {
 				struct filelist *old_head = include_filelist;
 				include_filelist = malloc(sizeof(struct filelist));
Index: Makefile
===================================================================
--- Makefile	(revision 5290)
+++ Makefile	(working copy)
@@ -61,6 +61,7 @@ 
 endif
 
 CPP:= $(CC) -x assembler-with-cpp -DASSEMBLY -E
+ROMCC:= $(obj)/romcc
 HOSTCC = gcc
 HOSTCXX = g++
 HOSTCFLAGS := -I$(srck) -I$(objk) -g
@@ -85,6 +86,17 @@ 
 endif
 endif
 
+ifeq ($(CONFIG_CCACHE),y)
+CCACHE:=CCACHE_COMPILERCHECK=content $(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH))))
+ifeq ($(CCACHE),)
+$(error ccache selected, but not found in PATH)
+endif
+CC := $(CCACHE) $(CC)
+HOSTCC := $(CCACHE) $(HOSTCC)
+HOSTCXX := $(CCACHE) $(HOSTCXX)
+ROMCC := $(CCACHE) $(ROMCC)
+endif
+
 strip_quotes = $(subst ",,$(subst \",,$(1)))
 
 ARCHDIR-$(CONFIG_ARCH_X86)    := i386