Patchwork ccache aware romcc

login
register
about
Submitter Patrick Georgi
Date 2010-03-25 17:03:28
Message ID <4BAB9760.3030704@georgi-clan.de>
Download mbox | patch
Permalink /patch/1153/
State Superseded
Headers show

Comments

Patrick Georgi - 2010-03-25 17:03:28
Am 25.03.2010 18:02, schrieb Patrick Georgi:
> Hi,
> 
> most of the tree was already ccache aware, with one exception: romcc.
> This hurt, as on the non-CAR boards, this is a large non-parallelizable
> part of the total build time.
> 
> This patch changes romcc to:
> - accept -c and -S (and ignores them as that's already the only mode it
> knows)
> - send -E output (preprocessor only) to stdout except if a filename is
> given (by testing if it's set to the current default of auto.inc)
> 
> With these, ccache3.0pre0 (the version I tried) is capable of cache
> romcc output.
> 
> The Makefile changes in this patch make use of that, if "ccache" is
> found in $PATH (necessary as we use various paths for our romcc), and
> runs ccache $(obj)/romcc, using the "content" compiler version
> verification (which hashes the compiler executable) for romcc.
> 
> Thus when romcc is changed, ccache doesn't use cached files but requests
> new builds.
> 
> On my test system, abuild of a romcc board (thomson/ip1000) goes down
> from 9 to 3 seconds when using 4 parallel build jobs.
> 
> 
> Signed-off-by: Patrick Georgi <patrick.georgi@coresystems.de>
> 
This time with patch

Patch

Index: src/arch/i386/Makefile.bootblock.inc
===================================================================
--- src/arch/i386/Makefile.bootblock.inc	(Revision 5290)
+++ src/arch/i386/Makefile.bootblock.inc	(Arbeitskopie)
@@ -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	(Arbeitskopie)
@@ -9,6 +9,12 @@ 
 
 ifdef POST_EVALUATION
 
+ROMCC:=$(obj)/romcc
+CCACHE:=CCACHE_COMPILERCHECK=content $(wildcard $(addsuffix /ccache,$(subst :, ,$(PATH))))
+ifneq ($(CCACHE),)
+ROMCC:=$(CCACHE) $(ROMCC)
+endif
+
 #######################################################################
 # Build the final rom image
 COREBOOT_ROM_DEPENDENCIES:=
@@ -195,7 +201,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/romcc/romcc.c
===================================================================
--- util/romcc/romcc.c	(Revision 5290)
+++ util/romcc/romcc.c	(Arbeitskopie)
@@ -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));