RFA: avoid circular dependency (using doc/../doc) (Was: Re: copying a timestamp)
diff mbox

Message ID 20101114132829.05yt062q8cg8swwo-nzlynne@webmail.spamcop.net
State New
Headers show

Commit Message

Joern Rennecke Nov. 14, 2010, 6:28 p.m. UTC
Quoting Ralf Wildenhues <Ralf.Wildenhues@gmx.de>:

> * Joern Rennecke wrote on Sun, Nov 14, 2010 at 04:35:02PM CET:
>> I just realized there is a third alternative: we could exploit the fact
>> that the same file is handled by make as different targets if named
>> with different pathnames, i.e.
>> [$(srcdir)/doc/]tm.texi and $(srcdir)/doc/../doc/tm.texi are
>> different make targets.
>> I'm not sure if that would be exploiting a stable feature or a   
>> bug/limitation
>> that might disappear from GNU make before the FSF GPL/GFDL problems
>> are resolved.
>
> It's not likely that this will disappear, but code like that will jump
> out at the casual reader months from now as likely-buggy.  So that would
> definitely deserve a comment.

OK, I've added some.

Bootstrapped on i686-pc-linux-gnu.

> Maybe also a make-time (or
> configure-time) test that this feature/bug has not changed?

That sounds hard to get right, and hopefully it will be moot when we
get a proper resolution of the GPL / GFDL issues.
At any rate, the expected failure mode is that make will go back to complain
about a circular dependency.
2010-11-14  Joern Rennecke  <amylaar@spamcop.net>

	* Makefile.in (tm.texi): Replace with rule for:
	($(srcdir)/doc/tm.texi).
	(s-tm-texi): Depend on $(srcdir)/doc/../doc/tm.texi instead of on
	$(srcdir)/doc/tm.texi .
	(TEXI_GCCINT_FILES): Depend on $(srcdir)/doc/tm.texi instead of on
	tm.texi .

Comments

Ralf Wildenhues Nov. 15, 2010, 9:39 p.m. UTC | #1
* Joern Rennecke wrote on Sun, Nov 14, 2010 at 07:28:29PM CET:
> Quoting Ralf Wildenhues:
> >
> >It's not likely that this will disappear, but code like that will jump
> >out at the casual reader months from now as likely-buggy.  So that would
> >definitely deserve a comment.
> 
> OK, I've added some.

Thanks.

> >Maybe also a make-time (or
> >configure-time) test that this feature/bug has not changed?
> 
> That sounds hard to get right, and hopefully it will be moot when we
> get a proper resolution of the GPL / GFDL issues.
> At any rate, the expected failure mode is that make will go back to complain
> about a circular dependency.

Ah, that sounds good enough then.

Thanks,
Ralf

Patch
diff mbox

Index: Makefile.in
===================================================================
--- Makefile.in	(revision 166609)
+++ Makefile.in	(working copy)
@@ -3688,7 +3688,8 @@  s-constrs-h: $(MD_DEPS) build/genpreds$(
 	$(STAMP) s-constrs-h
 
 target-hooks-def.h: s-target-hooks-def-h; @true
-tm.texi: s-tm-texi; @true
+# make sure that when we build info files, the used tm.texi is up to date.
+$(srcdir)/doc/tm.texi: s-tm-texi; @true
 
 s-target-hooks-def-h: build/genhooks$(build_exeext)
 	$(RUN_GEN) build/genhooks$(build_exeext) > tmp-target-hooks-def.h
@@ -3697,7 +3698,8 @@  s-target-hooks-def-h: build/genhooks$(bu
 	$(STAMP) s-target-hooks-def-h
 
 # check if someone mistakenly only changed tm.texi.
-s-tm-texi: $(srcdir)/doc/tm.texi
+# We use a different pathname here to avoid a circular dependency.
+s-tm-texi: $(srcdir)/doc/../doc/tm.texi
 
 s-tm-texi: build/genhooks$(build_exeext) $(srcdir)/doc/tm.texi.in
 	$(RUN_GEN) build/genhooks$(build_exeext) \
@@ -4198,10 +4200,14 @@  TEXI_GCC_FILES = gcc.texi gcc-common.tex
 	 fdl.texi contrib.texi cppenv.texi cppopts.texi			\
 	 implement-c.texi implement-cxx.texi arm-neon-intrinsics.texi
 
+# we explicitly use $(srcdir)/doc/tm.texi here to avoid confusion with
+# the generated tm.texi; the latter might have a more recent timestamp,
+# but we don't want to rebuild the info files unless the contents of
+# the *.texi files have changed.
 TEXI_GCCINT_FILES = gccint.texi gcc-common.texi gcc-vers.texi		\
 	 contribute.texi makefile.texi configterms.texi options.texi	\
-	 portability.texi interface.texi passes.texi	\
-	 rtl.texi md.texi tm.texi hostconfig.texi fragments.texi	\
+	 portability.texi interface.texi passes.texi rtl.texi md.texi	\
+	 $(srcdir)/doc/tm.texi hostconfig.texi fragments.texi	\
 	 configfiles.texi collect2.texi headerdirs.texi funding.texi	\
 	 gnu.texi gpl_v3.texi fdl.texi contrib.texi languages.texi	\
 	 sourcebuild.texi gty.texi libgcc.texi cfg.texi tree-ssa.texi	\