NetBSD-Bugs archive

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

toolchain/44844: [dM] make(1) expands variables inconsistently



>Number:         44844
>Category:       toolchain
>Synopsis:       [dM] make(1) expands variables inconsistently
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    toolchain-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Apr 08 18:45:00 +0000 2011
>Originator:     Mouse
>Release:        NetBSD 4.0.1
>Organization:
        Dis-
>Environment:
        Any 4.0.1 (or 1.4T, or probablyothers).  My principal test case:
System: NetBSD VAIO-Frank.Rodents-Montreal.ORG 4.0.1 NetBSD 4.0.1 (VAIO-MP) #0: 
Thu Apr 7 10:00:57 EDT 2011 
mouse%VAIO-CREDIL.Rodents-Montreal.ORG@localhost:/home/mouse/kbuild/VAIO-MP i386
Architecture: i386
Machine: i386
>Description:
        make(1) expands variables in dependency lists differently from
        variables in variable assignments (I haven't investigated other
        places much).  Specifically, the "setting on the command line
        overrides setting in the makefile" works in dependency lists
        but not in variable settings.
>How-To-Repeat:
        % cat test-makefile
        V = makefile
        foo: xyz-${V}
        F:= xyz-${V}
        bar: ${F}
        xyz-cmd: .PHONY
                echo building xyz-cmd
        xyz-makefile: .PHONY
                echo building xyz-makefile
        % make V=cmd -f test-makefile foo
        % make V=cmd -f test-makefile bar

        The final two commands should, I believe, each print

        echo building xyz-cmd
        building xyz-cmd

        With the bug, the second one instead prints

        echo building xyz-makefile
        building xyz-makefile

        This could, I suppose, be deliberate, but it is not documented
        as far as I can see, and GNU make (after removing the .PHONYs,
        which it doesn't support) does behave the same for the foo and
        bar cases, so I am inclined to believe the NetBSD behaviour is
        a bug.
>Fix:
        Relative to parse.c,v 1.120.2.3:

        --- a/usr.bin/make/parse.c
        +++ b/usr.bin/make/parse.c
        @@ -1573,7 +1573,7 @@ Parse_DoVar(char *line, GNode *ctxt)
                if (!Var_Exists(line, ctxt))
                    Var_Set(line, "", ctxt, 0);
         
        -       cp = Var_Subst(NULL, cp, ctxt, FALSE);
        +       cp = Var_Subst(NULL, cp, VAR_CMD, FALSE);
                oldVars = oldOldVars;
                freeCp = TRUE;
         

        "It works for me."

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

>Unformatted:
        Also seen in 1.4T's make(1)


Home | Main Index | Thread Index | Old Index