Issue 70168 - dmake cannot handle $ in prerequisites
Summary: dmake cannot handle $ in prerequisites
Status: CLOSED FIXED
Alias: None
Product: Build Tools
Classification: Code
Component: dmake (show other issues)
Version: current
Hardware: All All
: P3 Trivial (vote)
Target Milestone: ---
Assignee: hjs
QA Contact: issues@tools
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-10-07 03:47 UTC by quetschke
Modified: 2013-08-07 15:34 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Latest Confirmation in: ---
Developer Difficulty: ---


Attachments
Patch for dmake (3.88 KB, patch)
2006-10-07 19:18 UTC, quetschke
no flags Details | Diff
Patch for dmake (12.77 KB, patch)
2006-10-08 23:47 UTC, quetschke
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this issue.
Description quetschke 2006-10-07 03:47:00 UTC
If you run the following example:

---- makefile.mk ----
SHELL*:=/bin/sh
SHELLFLAGS*:=-ce

all : my$$try1.xx
	echo all

./my$$try1.xx :
	echo try1
---- makefile.mk ----

you get:

dmake:  Error: -- `myry1.xx' not found, and can't be made

The problem lies in the dynamic macro expansion in Make(), around line 451 in
make.c. The prerequisite is expanded (to treat nested macro expressions) as
long as $'s are present. This unfortunately fails for literal $ characters:
  $$<something> -> $<something> -> ""

This bug is independent of issue 69742 but while testing the target
normalization I realized that prerequisites with $ didn't work.
Comment 1 quetschke 2006-10-07 19:18:15 UTC
Created attachment 39626 [details]
Patch for dmake
Comment 2 quetschke 2006-10-07 19:30:37 UTC
There was a problem in Make() that repeated the expansion of a prerequisite
until no $ was found anymore - nested macros don't need special treatment,
Expand() takes care of this.

This patch obsoletes the DYNAMICNESTINGLEVEL macro. It's still there but unused.

But even with this patch literal $ characters are problematic. At the Def_cell()
level it's impossible to destinquish between a dynamic prerequisite and a
literal $ in the filename, so targets with $ are not normalized. This is a new
feature anyway, but $ in target definitions should be avoided as this could also 
mean a synatx error when trying to use a late expanded macro name as a target.

Currently only a warning is issued, but maybe this should be an Error.
Comment 3 quetschke 2006-10-08 23:47:22 UTC
Created attachment 39639 [details]
Patch for dmake
Comment 4 quetschke 2006-10-08 23:49:31 UTC
Committed to dmake47.
Comment 5 quetschke 2006-10-08 23:49:57 UTC
Please verify.
Comment 6 hjs 2007-01-17 16:52:24 UTC
fetched me the makefile from the testcase:

---- makefile.mk ----
SHELL*:=/bin/sh
SHELLFLAGS*:=-ce

DYNPRQS=a$$xx1 a$$xx2

all : $$(DYNPRQS) a$$$$xx3
    echo all

a$$xx1 :
    echo a1:$@

a$$xx2 :
    echo a2:$@

a$$xx3 :
    echo a3:$@
---- makefile.mk ----

four dollar signs in a row when using it in prerequisites - ok, looks strange
but so be it.

but looking at the echo output, e.g.

a3:ax3

instead of the expected

a3:a$xx3

it makes me wonder if there is any sense in using literal $ in targets at all.
currently you won't even be able to address the target name in the receipt...

and i never saw the warning mentioned...
Comment 7 quetschke 2007-01-17 17:22:42 UTC
The $@ gets expanded one final time when creating the recipe. I just played with
the code that creates the dynamic macros and there seems to be a small bug in it
that defines the @ macro as "not yet expanded" (M_EXPANDED is missing).

I cannot imagine a case where a target is being build but there are still
unexpanded variables in the targets name. So this will be fixed in dmake48.
Comment 8 hjs 2007-01-17 17:30:16 UTC
taking it "as is". won't hit too many people ;)
Comment 9 quetschke 2007-01-17 17:38:19 UTC
Oh, and I somehow decided not to commit the mentioned warning. If we want it
we have to replace the
	     * FIXME: Here would be the place to add a sanity check. */
line in dmake/rulparse.c with something like
	    if( strchr(tok, '$') )
	       Warning( "The use of target names containing $ [%s] characters is
discouraged.", tok );
Comment 10 hjs 2007-01-23 14:32:50 UTC
seen in MWS
Comment 11 quetschke 2007-08-04 19:44:38 UTC
Reopen because of bug discovered in issue 80352.
Comment 12 quetschke 2007-08-04 19:45:10 UTC
Change owner
Comment 13 quetschke 2007-08-05 20:03:33 UTC
The code was really intended to clear F_MARK again after the dynamic prerequisite
generation is done. I fixed that, but not clearing it didn't create any problems
because the F_MARK flag is not used again later in the code.
Comment 14 quetschke 2007-08-05 20:04:00 UTC
Please verify
Comment 15 hjs 2007-10-05 16:11:30 UTC
.
Comment 16 hjs 2007-12-21 13:35:34 UTC
dmake 4.11 is in use now