bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Endless loop in Make 3.80 (Cygwin)


From: Paul D. Smith
Subject: Re: Endless loop in Make 3.80 (Cygwin)
Date: Tue, 20 Apr 2004 07:15:59 -0400

%% Peter Keitler <address@hidden> writes:

  pk> the following Makefile enters an endless loop on our Cygwin installation 
  pk> (Win2k, SP3) with GNU Make 3.80.

  pk> ### begin
  pk> dep : env
  pk>   @echo Target: dep
  pk>   touch dep

  pk> env:
  pk>   @echo Target: environment

  pk> include dep
  pk> ### end

  pk> I call it with the 'make' command only, without any parameters. On
  pk> our Linux box (SuSE 8.1, 'uname -r: 2.4.21-168-default') with GNU
  pk> Make Version 3.79.1, both targets are built only twice each. This
  pk> is the behaviour I would expect, since the included Makefile has
  pk> changed after the first run.

Actually you're just lucky that it only builds twice on Linux; it
probably is due to the coarseness of the timestamp and how fast Linux is
at re-execing.  It should build over and over on Linux as well.

Your problem is that you never create the "env" file.  Because that file
is never created, it's always considered out-of-date and its command is
always invoked.  Because env is always out-of-date, dep (which depends
on env) is always considered out of date out-of-date as well.  Because
dep is always out-of-date, it's always rebuilt, and because it's always
rebuilt, make always re-execs.


On Linux, the re-exec and re-parsing of the makefile are so fast that
even after it re-execs, re-reads the makefile, and re-runs the dep rule,
the timestamp on the file is _STILL_ identical (to the second) to the
last time make ran it.  Since make relies solely on timestamps it thinks
you didn't actually update the dep file and doesn't consider it
modified, so it doesn't re-exec.

If you time it just right you could get it to run three times, since the
second would tick over between the first and second invocations.  Or, if
you move to any filesystem that supports sub-second timestamps you'll
see this go into an infinite loop.


The only solution is to create the env file:

  dep : env
      @echo Target: dep
      touch dep

  env:
      @echo Target: environment
      touch env

  include dep


Note this will run "env" only once, not twice.

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.paulandlesley.org
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]