diff mbox

[RFC] Prevent unnecessary recompilation for trivial params.def changes

Message ID 55EEBC91.7060901@mentor.com
State New
Headers show

Commit Message

Tom de Vries Sept. 8, 2015, 10:46 a.m. UTC
Hi,

this patch adds generation of params.list, a file containing a list of 
names of all the parameters in params.def.

By including params.list in params.h, rather than params.def itself, we 
prevent recompiling the 118 c files that include params.h for trivial 
changes in params.def, such as f.i. changing the default value of a 
parameter.

I did a minimal build with the patch, and tested the behaviour by doing 
both trivial an non-trivial changes in params.def, and rebuilding.

Any comments?

Thanks,
- Tom

Comments

Andreas Schwab Sept. 8, 2015, 11 a.m. UTC | #1
Tom de Vries <Tom_deVries@mentor.com> writes:

> @@ -3236,6 +3236,10 @@ installdirs:
>  	$(mkinstalldirs) $(DESTDIR)$(man1dir)
>  	$(mkinstalldirs) $(DESTDIR)$(man7dir)
>  
> +params.list: $(srcdir)/params-list.h $(srcdir)/params.def
> +	$(CPP) $(srcdir)/params-list.h | sed 's/^#.*//;/^$$/d' > tmp-params.list
> +	$(SHELL) $(srcdir)/../move-if-change tmp-params.list params.list
> +

You need a stamp file to avoid continuous rebuilding, don't you?

Andreas.
Tom de Vries Sept. 8, 2015, 11:24 a.m. UTC | #2
On 08/09/15 13:00, Andreas Schwab wrote:
> Tom de Vries <Tom_deVries@mentor.com> writes:
>
>> @@ -3236,6 +3236,10 @@ installdirs:
>>   	$(mkinstalldirs) $(DESTDIR)$(man1dir)
>>   	$(mkinstalldirs) $(DESTDIR)$(man7dir)
>>
>> +params.list: $(srcdir)/params-list.h $(srcdir)/params.def
>> +	$(CPP) $(srcdir)/params-list.h | sed 's/^#.*//;/^$$/d' > tmp-params.list
>> +	$(SHELL) $(srcdir)/../move-if-change tmp-params.list params.list
>> +
>
> You need a stamp file to avoid continuous rebuilding, don't you?
>

After a trivial change and a rebuild, I see the files being rebuild:
...
/usr/bin/gcc-4.6 -E src/gcc/params-list.h | sed 's/^#.*//;/^$/d' > 
tmp-params.list
/bin/bash src/gcc/../move-if-change tmp-params.list params.list
...

After a subsequent rebuild I don't see anything being rebuild. So I 
don't observe 'continuous rebuilding'.

Thanks,
- Tom
Andreas Schwab Sept. 8, 2015, 12:03 p.m. UTC | #3
Tom de Vries <Tom_deVries@mentor.com> writes:

> After a subsequent rebuild I don't see anything being rebuild. So I don't
> observe 'continuous rebuilding'.

What happens when you just touch params-list.h or params.def?
move-if-change will leave the target untouched when unchanged (that's
the whole point of it), so it will remain older than the dependencies.

Andreas.
diff mbox

Patch

Add params.list

---
 gcc/Makefile.in   | 6 +++++-
 gcc/params-list.h | 4 ++++
 gcc/params.h      | 5 +----
 3 files changed, 10 insertions(+), 5 deletions(-)
 create mode 100644 gcc/params-list.h

diff --git a/gcc/Makefile.in b/gcc/Makefile.in
index 3d1c1e5..f1ce154 100644
--- a/gcc/Makefile.in
+++ b/gcc/Makefile.in
@@ -2415,7 +2415,7 @@  generated_files = config.h tm.h $(TM_P_H) $(TM_H) multilib.h \
        $(ALL_GTFILES_H) gtype-desc.c gtype-desc.h gcov-iov.h \
        options.h target-hooks-def.h insn-opinit.h \
        common/common-target-hooks-def.h pass-instances.def \
-       c-family/c-target-hooks-def.h
+       c-family/c-target-hooks-def.h params.list
 
 #
 # How to compile object files to run on the build machine.
@@ -3236,6 +3236,10 @@  installdirs:
 	$(mkinstalldirs) $(DESTDIR)$(man1dir)
 	$(mkinstalldirs) $(DESTDIR)$(man7dir)
 
+params.list: $(srcdir)/params-list.h $(srcdir)/params.def
+	$(CPP) $(srcdir)/params-list.h | sed 's/^#.*//;/^$$/d' > tmp-params.list
+	$(SHELL) $(srcdir)/../move-if-change tmp-params.list params.list
+
 PLUGIN_HEADERS = $(TREE_H) $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
   toplev.h $(DIAGNOSTIC_CORE_H) $(BASIC_BLOCK_H) $(HASH_TABLE_H) \
   tree-ssa-alias.h $(INTERNAL_FN_H) gimple-fold.h tree-eh.h gimple-expr.h \
diff --git a/gcc/params-list.h b/gcc/params-list.h
new file mode 100644
index 0000000..49301d2
--- /dev/null
+++ b/gcc/params-list.h
@@ -0,0 +1,4 @@ 
+#define DEFPARAM(enumerator, option, nocmsgid, default, min, max) \
+  enumerator,
+#include "params.def"
+#undef DEFPARAM
diff --git a/gcc/params.h b/gcc/params.h
index f53426d..9f7618a 100644
--- a/gcc/params.h
+++ b/gcc/params.h
@@ -81,10 +81,7 @@  extern void set_param_value (const char *name, int value,
 
 enum compiler_param
 {
-#define DEFPARAM(enumerator, option, nocmsgid, default, min, max) \
-  enumerator,
-#include "params.def"
-#undef DEFPARAM
+#include "params.list"
   LAST_PARAM
 };
 
-- 
1.9.1