Bug 144388 - [patch] different behavior of make(1) between command line argument and .MAKEFLAGS special target
Summary: [patch] different behavior of make(1) between command line argument and .MAKE...
Status: Open
Alias: None
Product: Base System
Classification: Unclassified
Component: bin (show other bugs)
Version: 8.0-RELEASE
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2010-03-01 12:10 UTC by Jui-Nan Lin
Modified: 2022-10-17 12:36 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jui-Nan Lin 2010-03-01 12:10:04 UTC
There's different behavior of specifying -j1 in command line argument and special target ".MAKEFLAGS"

Fix: 

The behavior should be the same. (running for 10 seconds)
How-To-Repeat: 
# cat Makefile
.MAKEFLAGS: -j1

all:
	@/bin/sleep 10 &
	@/bin/sleep 10 &
	@wait
# time make
0.000u 0.006s 0:00.01 0.0%      0+0k 0+0io 0pf+0w
# time make -j1
0.000u 0.006s 0:10.00 0.0%      0+0k 0+0io 0pf+0w
Comment 1 Garrett Cooper 2010-03-01 13:14:20 UTC
On Mar 1, 2010, at 4:09 AM, Jui-Nan Lin <jnlin@csie.nctu.edu.tw> wrote:

>
>> Number:         144388
>> Category:       bin
>> Synopsis:       different behavior of make(1) between command line  
>> argument and .MAKEFLAGS special target
>> Confidential:   no
>> Severity:       non-critical
>> Priority:       low
>> Responsible:    freebsd-bugs
>> State:          open
>> Quarter:
>> Keywords:
>> Date-Required:
>> Class:          sw-bug
>> Submitter-Id:   current-users
>> Arrival-Date:   Mon Mar 01 12:10:04 UTC 2010
>> Closed-Date:
>> Last-Modified:
>> Originator:     Jui-Nan Lin
>> Release:        FreeBSD 8.0-RELEASE-p2 amd64
>> Organization:
> FreeBSD Taiwan
>> Environment:
> System: FreeBSD Florence.tamama.org 8.0-RELEASE-p2 FreeBSD 8.0- 
> RELEASE-p2 #8: Thu Jan 7 11:34:24 CST 2010 root@Florence.tamama.org:/ 
> usr/obj/usr/src/sys/KERNEL amd64
>
>> Description:
> There's different behavior of specifying -j1 in command line  
> argument and special target ".MAKEFLAGS"
>> How-To-Repeat:
>
> # cat Makefile
> .MAKEFLAGS: -j1
>
> all:
>    @/bin/sleep 10 &
>    @/bin/sleep 10 &
>    @wait
> # time make
> 0.000u 0.006s 0:00.01 0.0%      0+0k 0+0io 0pf+0w
> # time make -j1
> 0.000u 0.006s 0:10.00 0.0%      0+0k 0+0io 0pf+0w
>> Fix:
> The behavior should be the same. (running for 10 seconds)

Can you try adding a line continuation (\) to lines 1 and 2, and  
remove the @ from lines 2 and 3?

I agree that behavior should be the same, or at least in the same  
ballpark, but I think the former version (0 seconds) is correct.

Thanks,
-Garrett
Comment 2 Jui-Nan Lin 2010-03-01 13:36:56 UTC
Hi Garrett,

Following is the result:

# cat Makefile
.MAKEFLAGS: -j1

all:
        /bin/sleep 10 & \
        /bin/sleep 10 &
        @wait

# time make all
/bin/sleep 10 &  /bin/sleep 10 &
0.000u 0.006s 0:00.01 0.0%      0+0k 0+0io 0pf+0w
# time make -j1 all
/bin/sleep 10 &  /bin/sleep 10 &
0.000u 0.007s 0:10.00 0.0%      0+0k 0+0io 0pf+0w

The latter version is correct because when specifying "-j", make(1)
only forks a shell for all commands. If no "-j" specified, make forks
1 shell for each command. You can see manpage of make(1).
Comment 3 Jui-Nan Lin 2010-03-01 14:28:23 UTC
Hi,

I have make a patch:
http://www.csie.nctu.edu.tw/~jnlin/patch/usr.bin.make.c.patch
It works for me.
Comment 4 Eitan Adler freebsd_committer freebsd_triage 2017-12-31 08:00:49 UTC
For bugs matching the following criteria:

Status: In Progress Changed: (is less than) 2014-06-01

Reset to default assignee and clear in-progress tags.

Mail being skipped
Comment 5 Graham Perrin freebsd_committer freebsd_triage 2022-10-17 12:36:06 UTC
Keyword: 

    patch
or  patch-ready

– in lieu of summary line prefix: 

    [patch]

* bulk change for the keyword
* summary lines may be edited manually (not in bulk). 

Keyword descriptions and search interface: 

    <https://bugs.freebsd.org/bugzilla/describekeywords.cgi>