[PATCH][gcc-4.9.0] gcc/Makefile.in: fix parallel building failure

Andrew Pinski pinskia@gmail.com
Thu Jul 24 06:21:00 GMT 2014


On Wed, Jul 23, 2014 at 9:10 PM, Hongxu Jia <hongxu.jia@windriver.com> wrote:
> 1. How to reproduce the issue:
>
> 1) manually modify gcc/Makefile.in to delay the generation of config.h:
> ...
> diff --git gcc-4.9.0/gcc/Makefile.in gcc-4.9.0/gcc/Makefile.in
> --- gcc-4.9.0/gcc/Makefile.in
> +++ gcc-4.9.0/gcc/Makefile.in
> @@ -1622,9 +1622,12 @@ tm.h: cs-tm.h ; @true
>  tm_p.h: cs-tm_p.h ; @true
>
>  cs-config.h: Makefile
> +   @echo "start to generate config.h `date`"
> +   sleep 10
>     TARGET_CPU_DEFAULT="" \
>     HEADERS="$(host_xm_include_list)" DEFINES="$(host_xm_defines)" \
>     $(SHELL) $(srcdir)/mkconfig.sh config.h
> +   @echo "config.h generated `date`"
>
>  cs-bconfig.h: Makefile
>     TARGET_CPU_DEFAULT="" \
> ...
>
> 2) compiling gcc
>
> 2. Analysis
>
> Most C source files included config.h which was generated by a rule.
> But no related prerequisites was added to the C source compiling rule.
> There was potential building failure while makefile enabled parallel.


Why not update the dependencies instead of this hack?
For 4.10/5.0 is this already fixed by changing how dependencies work.

Thanks,
Andrew

>
> The C source compiling rule used suffix rule '.c.o', but the suffix
> rule doesn't support prerequisites.
> https://www.gnu.org/software/make/manual/html_node/Suffix-Rules.html
>
> We used the pattern rule '%.o : %.c' to instead, and add the config.h
> as its prerequisite
>
> We also moved the '%.o : %.c' rule down to the 'build/%.o :' rule, which
> makes '%.o : %.c' rule doesn't override 'build/%.o :'.
>
> For more detail:
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=6568
>
> Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
> ---
>  gcc/Makefile.in | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git gcc-4.9.0/gcc/Makefile.in gcc-4.9.0/gcc/Makefile.in
> index 6475cba..04889fe 100644
> --- gcc-4.9.0/gcc/Makefile.in
> +++ gcc-4.9.0/gcc/Makefile.in
> @@ -1054,10 +1054,6 @@ COMPILE = source='$<' object='$@' libtool=no \
>  POSTCOMPILE =
>  endif
>
> -.cc.o .c.o:
> -       $(COMPILE) $<
> -       $(POSTCOMPILE)
> -
>  #
>  # Support for additional languages (other than C).
>  # C can be supported this way too (leave for later).
> @@ -2342,6 +2338,14 @@ build/%.o :  # dependencies provided by explicit rule later
>         $(COMPILER_FOR_BUILD) -c $(BUILD_COMPILERFLAGS) $(BUILD_CPPFLAGS) \
>                 -o $@ $<
>
> +%.o: %.c $(CONFIG_H)
> +       $(COMPILE) $<
> +       $(POSTCOMPILE)
> +
> +%.o: %.cc $(CONFIG_H)
> +       $(COMPILE) $<
> +       $(POSTCOMPILE)
> +
>  ## build/version.o is compiled by the $(COMPILER_FOR_BUILD) but needs
>  ## several C macro definitions, just like version.o
>  build/version.o:  version.c version.h \
> --
> 1.8.1.2
>



More information about the Gcc-patches mailing list