bug-make
[Top][All Lists]
Advanced

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

[bug #27609] Stupid inference rule for yacc files can clobber C sources!


From: Kaz Kylheku
Subject: [bug #27609] Stupid inference rule for yacc files can clobber C sources!
Date: Mon, 05 Oct 2009 20:59:27 +0000
User-agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)

Follow-up Comment #4, bug #27609 (project make):

By the way, this is quite bad. The behavior happens even if I have an
explicit rule like this:

  foo.o: foo.c

If there is a foo.y, foo.c is clobbered, even though foo.c exists.

This is so retarded.

The search for the prerequisite of foo.o must stop when foo.c is found.

I can understand that the search, upon not finding foo.c, might go on to try
other suffixes like foo.y.

That is to say, the rule should be about making a foo.o from a foo.y, not
making a foo.c from a foo.y!!!

Yes, sure. Okay. If I have a Makefile like this:

  program: foo.o

and the only file in the directory is foo.y (and no foo.c), then go ahead and
run yacc to make foo.c from foo.y, and compile foo.c to foo.o.

Actually we don't need foo.c in that case. We just need some temporary name.
The rule has to handle the complete job of translating .y to .o:

   $(YACC) $(YACCFLAGS) foo.y
   mv y.tab.c <temporary_name>
   $(CC) $(CFLAGS) -c <temporary_name> -o foo.o

Now this actually makes sense. If there is no .c file, why not infer that .y
is the prerequisite for a .o?

Just don't involve a foo.c file in the inference chain.

<temporary_name> can be based on foo.y somehow (just not in a naive way like
foo.c!)  Even if it was foo.y.tab.c, or foo.y.out, or whatever.

There could even be an implicit rule which, given a foo.o, finds the
prerequisite foo.y.tab.c.

It's less likely that someone would write a file by hand called foo.y.tab.c,
than foo.c.










    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?27609>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/





reply via email to

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