From patchwork Wed Sep 29 20:38:24 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ralf Wildenhues X-Patchwork-Id: 66095 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 55072B6F0D for ; Thu, 30 Sep 2010 06:38:39 +1000 (EST) Received: (qmail 19594 invoked by alias); 29 Sep 2010 20:38:36 -0000 Received: (qmail 19510 invoked by uid 22791); 29 Sep 2010 20:38:35 -0000 X-SWARE-Spam-Status: No, hits=-1.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, TW_GM, TW_GR, TW_NR, T_TO_NO_BRKTS_FREEMAIL X-Spam-Check-By: sourceware.org Received: from mailout-de.gmx.net (HELO mail.gmx.net) (213.165.64.22) by sourceware.org (qpsmtpd/0.43rc1) with SMTP; Wed, 29 Sep 2010 20:38:28 +0000 Received: (qmail invoked by alias); 29 Sep 2010 20:38:25 -0000 Received: from xdsl-78-34-209-223.netcologne.de (EHLO localhost.localdomain) [78.34.209.223] by mail.gmx.net (mp066) with SMTP; 29 Sep 2010 22:38:25 +0200 Received: from ralf by localhost.localdomain with local (Exim 4.69) (envelope-from ) id 1P13Q0-0006sf-Nc; Wed, 29 Sep 2010 22:38:24 +0200 Date: Wed, 29 Sep 2010 22:38:24 +0200 From: Ralf Wildenhues To: gcc-patches@gcc.gnu.org Cc: bonzini@gnu.org Subject: [PATCH build] improve dependency graph for build/gen% Message-ID: <20100929203824.GD25571@gmx.de> Mail-Followup-To: Ralf Wildenhues , gcc-patches@gcc.gnu.org, bonzini@gnu.org MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2010-08-04) X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Pattern rules foo% : bar% baz ... have a distinct disadvantage over static pattern rules foo1 foo2 foo3 foo4 : foo% : bar% baz ... in that GNU make applies the former only if /some/ prerequisite of a target actually exists or can be made. Most of the time, this is not a problem, because either the makefile has all remaining information to make a prerequisite, or the rest of the tree has been built previously anyway. However, if the rest of the tree is not built, maybe because toplevel had missing dependency edges, then this can lead to weird error messages or 'make' wrongly thinking everything is up to date. For example, in an up to date build tree, cd gcc rm -f ../libiberty/libiberty.a ../build-$build/libiberty/libiberty.a make will *not* fail, although build/genhooks and others depend on libiberty.a in one of the above places (an updated libiberty.a will however cause the needed relinks). This issue caused the weird error message in . The "downside" of static pattern rules is that all targets need to be listed explicitly. The patch does this by moving the pattern rule and adjusting the rest. Tested with a full bootstrap, with a --disable-bootstrap build, and by removing some files arbitrarily and visually checking incremental rebuild output for consistency. OK for trunk? This does not fix the PR yet, but makes the failure obvious. Thanks, Ralf build: more correct build rules for build/gen% programs. gcc/ChangeLog: 2010-09-29 Ralf Wildenhues PR bootstrap/45796 * Makefile.in (build/gen%$(build_exeext)): Move rule after all special-casing for generators and turn into ... ((genprog:%=build/gen%$(build_exeext))): ... this static pattern rule, for better error messages in case of toplevel dependency errors. (genprog): Add hooks, rename to ... (genprogerr): ... this, and let genprog also contain check, checksum, condmd. ((genprog:%=build/gen%$(build_exeext))): Rename to ... ((genprogerr:%=build/gen%$(build_exeext))): ... this. (build/genhooks$(build_exeext)): Remove now-unneeded dependency. diff --git a/gcc/Makefile.in b/gcc/Makefile.in index 0c78323..36b6349 100644 --- a/gcc/Makefile.in +++ b/gcc/Makefile.in @@ -3904,11 +3904,6 @@ build/genhooks.o : genhooks.c target.def $(BCONFIG_H) $(SYSTEM_H) errors.h # since they need to run on this machine # even if GCC is being compiled to run on some other machine. -# As a general rule... -build/gen%$(build_exeext): build/gen%.o $(BUILD_LIBDEPS) - $(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ \ - $(filter-out $(BUILD_LIBDEPS), $^) $(BUILD_LIBS) - # All these programs use the RTL reader ($(BUILD_RTL)). genprogrtl = attr attrtab automata codes conditions config emit \ extract flags opinit output peep preds recog @@ -3918,16 +3913,23 @@ $(genprogrtl:%=build/gen%$(build_exeext)): $(BUILD_RTL) genprogmd = $(genprogrtl) mddeps constants enums $(genprogmd:%=build/gen%$(build_exeext)): $(BUILD_MD) -# All generator programs need to report errors -genprog = $(genprogmd) genrtl modes gtype -$(genprog:%=build/gen%$(build_exeext)): $(BUILD_ERRORS) +# All these programs need to report errors. +genprogerr = $(genprogmd) genrtl modes gtype hooks +$(genprogerr:%=build/gen%$(build_exeext)): $(BUILD_ERRORS) + +# Remaining build programs. +genprog = $(genprogerr) check checksum condmd # These programs need libs over and above what they get from the above list. build/genautomata$(build_exeext) : BUILD_LIBS += -lm # These programs are not linked with the MD reader. build/gengtype$(build_exeext) : build/gengtype-lex.o build/gengtype-parse.o -build/genhooks$(build_exeext) : $(BUILD_ERRORS) + +# Rule for the generator programs: +$(genprog:%=build/gen%$(build_exeext)): build/gen%$(build_exeext): build/gen%.o $(BUILD_LIBDEPS) + $(LINKER_FOR_BUILD) $(BUILD_LINKERFLAGS) $(BUILD_LDFLAGS) -o $@ \ + $(filter-out $(BUILD_LIBDEPS), $^) $(BUILD_LIBS) # Generated source files for gengtype. gengtype-lex.c : gengtype-lex.l