NetBSD Problem Report #53136

From www@NetBSD.org  Tue Mar 27 21:27:57 2018
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id 240297A16B
	for <gnats-bugs@gnats.NetBSD.org>; Tue, 27 Mar 2018 21:27:57 +0000 (UTC)
Message-Id: <20180327212756.0CAC67A21A@mollari.NetBSD.org>
Date: Tue, 27 Mar 2018 21:27:56 +0000 (UTC)
From: steffen@sdaoden.eu
Reply-To: steffen@sdaoden.eu
To: gnats-bugs@NetBSD.org
Subject: bmake evaluates MAKEFLAGS like command line argument
X-Send-Pr-Version: www-1.0

>Number:         53136
>Notify-List:    bsiegert@NetBSD.org
>Category:       bin
>Synopsis:       bmake evaluates MAKEFLAGS like command line argument
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    bin-bug-people
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Mar 27 21:30:00 +0000 2018
>Closed-Date:    Mon Apr 08 18:42:37 +0000 2019
>Last-Modified:  Mon Apr 08 18:42:37 +0000 2019
>Originator:     Steffen
>Release:        any
>Organization:
>Environment:
n.r.
>Description:
POSIX says for MAKEFLAGS

  The difference between the contents of MAKEFLAGS and the make utility command line is that the contents of the variable shall not be subjected to the word expansions

but the following fails with BSD, not with GNU make:

#?1[steffen@essex tmp]$ cat xxx.mk
all: setup
        $(MAKE) -f xxx.mk stage2
setup:
        @echo 'MAKEFLAGS=" .MAKE.LEVEL.ENV=MAKELEVEL VAL_RANDOM=ssl\ arc4\ builtin";export MAKEFLAGS;' > xxx.dat
stage2:
        @$(_prestop); LC_ALL=C $(MAKE) -f xxx.mk stage3
stage3:
        @$(_prestop); LC_ALL=C; echo "stage 3: $${MAKEFLAGS},VAL_RANDOM=$${VAL_RANDOM}"; rm -f xxx.dat
__prestop = true
_prestop = $(__prestop);\
        < ./xxx.dat read __ev__; eval $${__ev__}; unset __ev__
#?0[steffen@essex tmp]$ MAKE=bmake bmake -f xxx.mk 
bmake -f xxx.mk stage2
bmake[2]: don't know how to make arc4. Stop

bmake[2]: stopped in /home/steffen/tmp
*** Error code 2

Stop.
bmake[1]: stopped in /home/steffen/tmp
*** Error code 1

Stop.
bmake: stopped in /home/steffen/tmp
>How-To-Repeat:
As above.
>Fix:

>Release-Note:

>Audit-Trail:
From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/53136: bmake evaluates MAKEFLAGS like command line argument
Date: Wed, 28 Mar 2018 16:43:12 +0300

 On Tue, Mar 27, 2018 at 21:30:00 +0000, steffen@sdaoden.eu wrote:

 > POSIX says for MAKEFLAGS
 > 
 > The difference between the contents of MAKEFLAGS and the make
 > utility command line is that the contents of the variable shall not
 > be subjected to the word expansions

 This paragraph is probably not pertinent here.  See below.


 > #?1[steffen@essex tmp]$ cat xxx.mk
 > all: setup
 >         $(MAKE) -f xxx.mk stage2
 > setup:
 >         @echo 'MAKEFLAGS=" .MAKE.LEVEL.ENV=MAKELEVEL VAL_RANDOM=ssl\ arc4\ builtin";export MAKEFLAGS;' > xxx.dat
 > stage2:
 >         @$(_prestop); LC_ALL=C $(MAKE) -f xxx.mk stage3
 > stage3:
 >         @$(_prestop); LC_ALL=C; echo "stage 3: $${MAKEFLAGS},VAL_RANDOM=$${VAL_RANDOM}"; rm -f xxx.dat
 > __prestop = true
 > _prestop = $(__prestop);\
 >         < ./xxx.dat read __ev__; eval $${__ev__}; unset __ev__
 > #?0[steffen@essex tmp]$ MAKE=bmake bmake -f xxx.mk 
 > bmake -f xxx.mk stage2
 > bmake[2]: don't know how to make arc4. Stop

 I wonder if you realize that your backslashes do not survive

     read __ev__

 so you end up with MAKEFLAGS that contains

     .MAKE.LEVEL.ENV=MAKELEVEL VAL_RANDOM=ssl arc4 builtin

 it's just gmake treats those "arc4" and "builtin" differently, not
 VAL_RANDOM assignment.

 As an experiment, try adding --debug=a to what you consider to be
 VAL_RANDOM assignment and then run it with gmake to observe gmake
 obeying that --debug flag.

 setup:
 	echo 'MAKEFLAGS=" .MAKE.LEVEL.ENV=MAKELEVEL VAL_RANDOM=ssl\ --debug=a\ arc4\ builtin";export MAKEFLAGS;' > xxx.dat


 -uwe

From: Steffen Nurpmeso <steffen@sdaoden.eu>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/53136: bmake evaluates MAKEFLAGS like command line
 argument
Date: Wed, 28 Mar 2018 18:20:55 +0200

 Hi.

 Valery Ushakov <uwe@stderr.spb.ru> wrote:
  |The following reply was made to PR bin/53136; it has been noted by GNATS.
  |
  |From: Valery Ushakov <uwe@stderr.spb.ru>
  |To: gnats-bugs@NetBSD.org
  |Cc: 
  |Subject: Re: bin/53136: bmake evaluates MAKEFLAGS like command line argument
  |Date: Wed, 28 Mar 2018 16:43:12 +0300
  |
  | On Tue, Mar 27, 2018 at 21:30:00 +0000, steffen@sdaoden.eu wrote:
  | 
  |> POSIX says for MAKEFLAGS
  |> 
  |> The difference between the contents of MAKEFLAGS and the make
  |> utility command line is that the contents of the variable shall not
  |> be subjected to the word expansions
  | 
  | This paragraph is probably not pertinent here.  See below.
  | 
  |> #?1[steffen@essex tmp]$ cat xxx.mk
  |> all: setup
  |>         $(MAKE) -f xxx.mk stage2
  |> setup:
  |>         @echo 'MAKEFLAGS=" .MAKE.LEVEL.ENV=MAKELEVEL VAL_RANDOM=ssl\ \
  |>         arc4\ builtin";export MAKEFLAGS;' > xxx.dat
  |> stage2:
  |>         @$(_prestop); LC_ALL=C $(MAKE) -f xxx.mk stage3
  |> stage3:
  |>         @$(_prestop); LC_ALL=C; echo "stage 3: $${MAKEFLAGS},VAL_RANDOM=$$\
  |>         {VAL_RANDOM}"; rm -f xxx.dat
  |> __prestop = true
  |> _prestop = $(__prestop);\
  |>         < ./xxx.dat read __ev__; eval $${__ev__}; unset __ev__
  |> #?0[steffen@essex tmp]$ MAKE=bmake bmake -f xxx.mk 
  |> bmake -f xxx.mk stage2
  |> bmake[2]: don't know how to make arc4. Stop
  | 
  | I wonder if you realize that your backslashes do not survive
  | 
  |     read __ev__

 They do not survive the eval, yes.  I have committed a fix to
 where this comes from, we now simply ". FILE" dot include that.

  | so you end up with MAKEFLAGS that contains
  | 
  |     .MAKE.LEVEL.ENV=MAKELEVEL VAL_RANDOM=ssl arc4 builtin
  | 
  | it's just gmake treats those "arc4" and "builtin" differently, not
  | VAL_RANDOM assignment.

 That is the point, right.  gmake honours POSIX, bmake does not.
 With reproducer this time.  ^_^
 Ciao,

 --steffen
 |
 |Der Kragenbaer,                The moon bear,
 |der holt sich munter           he cheerfully and one by one
 |einen nach dem anderen runter  wa.ks himself off
 |(By Robert Gernhardt)

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/53136: bmake evaluates MAKEFLAGS like command line argument
Date: Thu, 29 Mar 2018 15:13:08 +0300

 On Wed, Mar 28, 2018 at 17:40:01 +0000, Steffen Nurpmeso wrote:

 >   | On Tue, Mar 27, 2018 at 21:30:00 +0000, steffen@sdaoden.eu wrote:
 >   | 
 >   |> POSIX says for MAKEFLAGS
 >   |> 
 >   |> The difference between the contents of MAKEFLAGS and the make
 >   |> utility command line is that the contents of the variable shall not
 >   |> be subjected to the word expansions
 >   | 
 [...]
 >   | 
 >   |     read __ev__
 >  
 >  They do not survive the eval, yes.  I have committed a fix to
 >  where this comes from, we now simply ". FILE" dot include that.
 >  
 >   | so you end up with MAKEFLAGS that contains
 >   | 
 >   |     .MAKE.LEVEL.ENV=MAKELEVEL VAL_RANDOM=ssl arc4 builtin
 >   | 
 >   | it's just gmake treats those "arc4" and "builtin" differently, not
 >   | VAL_RANDOM assignment.
 >  
 >  That is the point, right.  gmake honours POSIX, bmake does not.
 >  With reproducer this time.  ^_^

 *What* is the point?  I can't see you making any.  Also, if i replace
 read+eval in your original example with dot-including the xxx.dat, I
 get

     VAL_RANDOM=ssl arc4 builtin

 in the output from stage3.  Do you expected something else?  Do you
 observe something else?

 -uwe

From: Steffen Nurpmeso <steffen@sdaoden.eu>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/53136: bmake evaluates MAKEFLAGS like command line
 argument
Date: Thu, 29 Mar 2018 15:01:55 +0200

 Valery Ushakov <uwe@stderr.spb.ru> wrote:
  |The following reply was made to PR bin/53136; it has been noted by GNATS.
  |From: Valery Ushakov <uwe@stderr.spb.ru>
  |To: gnats-bugs@NetBSD.org
  |Cc: 
  |Subject: Re: bin/53136: bmake evaluates MAKEFLAGS like command line argument
  |Date: Thu, 29 Mar 2018 15:13:08 +0300
  | On Wed, Mar 28, 2018 at 17:40:01 +0000, Steffen Nurpmeso wrote:
  |>| On Tue, Mar 27, 2018 at 21:30:00 +0000, steffen@sdaoden.eu wrote:
  |>| 
  |>|> POSIX says for MAKEFLAGS
  |>|> 
  |>|> The difference between the contents of MAKEFLAGS and the make
  |>|> utility command line is that the contents of the variable shall not
  |>|> be subjected to the word expansions
  ...
  | *What* is the point?  I can't see you making any.  Also, if i replace

 Then you need to look better.

   #?0[steffen@essex tmp]$ cat z.mk 
   all:
           echo all
   ciao:
           echo this is false I thinks.  uwe, got it?
   #?0[steffen@essex tmp]$ MAKEFLAGS=" ciao" make -f z.mk all
   echo all
   all
   #?0[steffen@essex tmp]$ MAKEFLAGS=" ciao" smake -f z.mk all
   ...echo all
   all
   #?0[steffen@essex tmp]$ MAKEFLAGS=" ciao" bmake -f z.mk all
   echo this is false uwe got it
   this is false I thinks.  uwe, got it?
   echo all
   all

 And, btw.:

   #?0[steffen@essex tmp]$ MAKEFLAGS=ciao bmake -f z.mk all
   usage: bmake [-BeikNnqrstWwX]
   ...

 This time with smaller reproducer.
 Ciao.

 --steffen
 |
 |Der Kragenbaer,                The moon bear,
 |der holt sich munter           he cheerfully and one by one
 |einen nach dem anderen runter  wa.ks himself off
 |(By Robert Gernhardt)

From: Valery Ushakov <uwe@stderr.spb.ru>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/53136: bmake evaluates MAKEFLAGS like command line argument
Date: Fri, 30 Mar 2018 01:38:27 +0300

 On Thu, Mar 29, 2018 at 13:05:01 +0000, Steffen Nurpmeso wrote:

 >  Valery Ushakov <uwe@stderr.spb.ru> wrote:
 >   |The following reply was made to PR bin/53136; it has been noted by GNATS.
 >   |From: Valery Ushakov <uwe@stderr.spb.ru>
 >   |To: gnats-bugs@NetBSD.org
 >   |Cc: 
 >   |Subject: Re: bin/53136: bmake evaluates MAKEFLAGS like command line argument
 >   |Date: Thu, 29 Mar 2018 15:13:08 +0300
 >   | On Wed, Mar 28, 2018 at 17:40:01 +0000, Steffen Nurpmeso wrote:
 >   |>| On Tue, Mar 27, 2018 at 21:30:00 +0000, steffen@sdaoden.eu wrote:
 >   |>| 
 >   |>|> POSIX says for MAKEFLAGS
 >   |>|> 
 >   |>|> The difference between the contents of MAKEFLAGS and the make
 >   |>|> utility command line is that the contents of the variable shall not
 >   |>|> be subjected to the word expansions
 >   ...
 >   | *What* is the point?  I can't see you making any.  Also, if i replace
 >  
 >  Then you need to look better.
 >  
 >    #?0[steffen@essex tmp]$ cat z.mk 
 >    all:
 >            echo all
 >    ciao:
 >            echo this is false I thinks.  uwe, got it?
 >    #?0[steffen@essex tmp]$ MAKEFLAGS=" ciao" make -f z.mk all
 >    echo all
 >    all
 >    #?0[steffen@essex tmp]$ MAKEFLAGS=" ciao" smake -f z.mk all
 >    ...echo all
 >    all
 >    #?0[steffen@essex tmp]$ MAKEFLAGS=" ciao" bmake -f z.mk all
 >    echo this is false uwe got it
 >    this is false I thinks.  uwe, got it?
 >    echo all
 >    all

 I guess that this is supposed to demonstrate something, but, you know,
 two can play at that game, so I'm going to claim that no, I don't get
 it.  You don't state what you expect to happen and the quoted passage
 about word expansions in the variable assignments is clearly not
 relevant here.  I don't really want to second guess you.


 >  And, btw.:
 >  
 >    #?0[steffen@essex tmp]$ MAKEFLAGS=ciao bmake -f z.mk all
 >    usage: bmake [-BeikNnqrstWwX]
 >    ...

 And what is the problem with the above?


 Unless you can clearly state a problem I'll just close this bug.

 -uwe

State-Changed-From-To: open->closed
State-Changed-By: bsiegert@NetBSD.org
State-Changed-When: Mon, 08 Apr 2019 18:42:37 +0000
State-Changed-Why:
Not reproducible.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.43 2018/01/16 07:36:43 maya Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2017 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.