help-make
[Top][All Lists]
Advanced

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

Re: makefile error output


From: Paul D. Smith
Subject: Re: makefile error output
Date: Fri, 26 Mar 2004 16:39:22 -0500

I got your email about the error message issue so I'll remove my reply
to that part :).


%% "Mike Maxwell" <address@hidden> writes:

  >> Given your description of what happened, the
  >> error message make printed would have been some form of:
  >> 
  >> No rule to make target `XXX'.
  >> 
  >> IMO that message is much clearer than what you wrote above.

  mm> I'll agree with that last statement.  Unfortunately, that's not
  mm> what 'make' did, and that's the point of my original msg.

It would have printed that, if your rule had been an explicit rule like
the example you showed in your email.

Since your _real_ makefile used a completely different implementation
than the example in your email, it's not surprising that you won't get
the same messages.

  >> As Noel pointed out, if this is _REALLY_ what your makefile said then
  >> make would have told you that it didn't know how to build foo.ReadMe.

  mm> Again, I agree.  For the record, here's the line in my makefile (minus a
  mm> comment at the end that makes it wrap in email):

  mm>    tarsets/%.stage2.tgz: stage2/%  %.mchist %.ID %.ReadMe

Right, just as I said:

  >> From your description of what happened, I believe that you really had
  >> defined an implicit rule here, rather than an explicit rule as your
  >> example shows.

In your original email you showed an explicit rule:

  >  foo.bar: foo.baz foo.ReadMe

Now we see, in this mail, that you didn't have an explicit rule in your
makefile at all, you had an _implicit_ (pattern) rule:

  >  tarsets/%.stage2.tgz: stage2/%  %.mchist %.ID %.ReadMe

The way these resolve is very different, so that change between what you
actually did and what you told us you did makes all the difference in
the world.

Thus, my request to not paraphrase your errors and your makefile and
instead post the _real_ text of the error and the _real_ rule in your
makefile.  Paraphrasing just leads to confusion.

An explicit rule says "here make, this is how you build foo.bar".  If
make can't solve _that exact rule_, it will fail.  Make knows that it
_MUST_ build foo.ReadMe since it's a prerequisite of an explicit rule.
If make can't build foo.ReadMe, it will say:

  No rule to make target 'foo.ReadMe', needed by 'foo.bar'.


But, you had an implicit rule.  An implicit rule shows _one possible
way_ that a target could be built.  More than one implicit rule can and
usually will match that target.  Make can't know that _this_ particular
explicit rule is the one that should have matched, and it can't print
errors about each rule that doesn't match: you'd get dozens of error
messages printed before it found one that matched!

At the end, if none of the rules matched, the best it can say is "I
looked, but I can't find any instructions on how to build this", which
is what "No rule to build ..."  means.  How can make know which of the
many ways it tried to build the target was the one that you think should
have worked?

  >> Make output doesn't print "failed", but you know it failed because
  >> it went on to continue looking for another rule to match.

  mm> Yes, but that requires a lot of sifting through and interpreting
  mm> of output to figure out; whereas if it output 'failed' when it
  mm> failed, I could look for a top-level failure (presumably indented
  mm> less than lower-level success/failures, which might even allow me
  mm> to grep it out), which would be the .ReadMe prereq; then I could
  mm> go about looking for why that prereq failed (which might take me
  mm> into the second-level success/failures which contain '.ReadMe',
  mm> which I could again grep out, etc.)

No you couldn't.

Make could have, and probably did, try a large number of patterns before
it got to the one you care about.  Not only did it try patterns for the
prerequisites you listed, but it tries patterns to create any
prerequisite that might enable it to use that pattern, but which doesn't
exist yet.  Etc.

If make printed "failed" after every single implicit rule that didn't
match there would be hundreds if not thousands of "failed" messages in
the debug output.  That would not help you find the "right" one in any
way, certainly you couldn't just go to "the first one".  The first
"failed" message will be at about line 4 of the debug output.


What you want to do with the debug output is, find the name of the
target that didn't get built.  From there watch make checking implicit
rules until it tries the one you care about.  Then from there see why it
couldn't use that rule for that target.

-- 
-------------------------------------------------------------------------------
 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]