bugmake - Bugs: bug #8297, Add a non-posix feature for...

 
 

bug #8297: Add a non-posix feature for parallel mode.

Submitted by:  Fred Bleuzet <fbleuzet4>
Submitted on:  Thu 25 Mar 2004 04:05:39 PM UTC  
Votes:  100  
 
Severity: 3 - NormalItem Group: Enhancement
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: NoneOperating System: Any
Fixed Release: NoneTriage Status: None

Add a New Comment (Rich MarkupRich Markup):
   

You are not logged in

Please log in, so followups can be emailed to you.

 

(Jump to the original submission Jump to the original submission)

Wed 05 Nov 2008 02:05:48 AM UTC, comment #6:

How about adding a new special target such as '.MULTIPLE_OUTPUTS'? Usage would be something like:

.MULTIPLE_OUTPUTS cmdparser.cpp cmdparser.h: cmdparser.y
bison -d -o cmdparser.cpp cmdparser.y

Tom Honermann <tahonermann>
Mon 03 Nov 2008 08:25:24 PM UTC, comment #5:

At the very least, the documentation needs to be revised to discuss the situation of multiple targets being produced by a rule action and to offer the pattern workaround.

Dave Yost <yost>
Sun 02 Apr 2006 05:10:29 AM UTC, comment #4:

I can answer this question wrt Solaris make and Sun Studio dmake.

foo + bar baz boz + biz:

What does this mean?

It means there are 2 groups:
1. foo + bar
2. boz + biz

Here is an example.
-------------------
volga2% cat Makefile
T = foo bar baz boz biz
all: ${T}
# Two groups
foo + bar baz boz + biz:
@echo $@
touch ${T}

If I run GNU make, it treats "+" as a target,
and repeats the same command 5 times:
-------------------------------------
volga2% rm -f foo bar baz boz biz
volga2% gmake -j 8
Makefile:7: target `+' given more than once in the same rule.
foo
touch foo bar baz boz biz
bar
baz
boz
biz
touch foo bar baz boz biz
touch foo bar baz boz biz
touch foo bar baz boz biz
touch foo bar baz boz biz

If I run Sun Studio dmake, it treats "+" as a group sign,
and repeats the same command 3 times:
-------------------------------------
volga2% rm -f foo bar baz boz biz
volga2% dmake -j 8
echo baz
baz
touch foo bar baz boz biz
echo boz
boz
touch foo bar baz boz biz
echo foo
foo
touch foo bar baz boz biz

Nikolay Molchanov <nikm>
Sun 02 Apr 2006 03:04:55 AM UTC, comment #3:

Yes, but I don't like that syntax because it seems to allow both kinds of "rules" to be defined at the same time; consider:

foo + bar baz boz + biz:

What does this mean? In discussions on the GNU make developers' list we discussed a syntax like this:

foo bar |: biz baz
%.y %.z |: %.a

and:

foo bar &: biz baz
%.y %.z &: %.a

The "&:" separator means that all targets are built with one invocation (default today for pattern rules) and the "|:" separator means each target is built with a separate invocation (default today for explicit rules). The unadorned ":" would keep its current behavior (different depending on whether you use pattern or explicit rules).

Paul D. Smith <psmith>
Project Administrator
Sun 02 Apr 2006 12:38:48 AM UTC, comment #2:

Solaris "make" utility provides the following solution: if the
targets are connected (separated) with a "+" sign, they are
combined in a target group.

target [+ target...] : Target group. The rule in the target
entry builds all the indicated tar-
gets as a group. It is normally per-
formed only once per make run, but
is checked for command dependencies
every time a target in the group is
encountered in the dependency scan.

Here is an example:

# Dependencies
cmdparser.hpp: cmdparser.cpp
cmdparser.cpp: cmdparser.y

# Common Rule
cmdparser.hpp + cmdparser.cpp:
bison -d -o cmdparser.cpp cmdparser.y

I can be wrong, but I think POSIX standard allows this syntax.

Nikolay Molchanov <nikm>
Sat 27 Mar 2004 04:17:48 AM UTC, comment #1:

We're not going to change the syntax of multiple-target explicit rules, even with a special flag.

If you need to define explicit rules with multiple outputs today you have two choices: if the rule can be expressed as a pattern then define it with multiple patterns in the target area: this DOES mean that all those targets are created with one invocation of the command script. Your example could be written as:

%.cpp %.h : %.y
bison -d -o cmdparser.cpp cmdparser.y

and it will work as you expect. The other option, if you can't express it with implicit rules, is to use a sentinel like this:

foo.cpp bar.xyz: .sentinel
.sentinel: ; command-to-gernerate-output; touch $@

There have been patches proposed that add a new rule syntax to allow explicit rules to behave as you like and one of those may be adopted, but it will be a new and unique syntax, it won't be an option to redefine an existing, well-understood syntax.

Paul D. Smith <psmith>
Project Administrator
Thu 25 Mar 2004 04:05:39 PM UTC, original submission:

I need an additional mode where make runs under the assumption that each multiple-target rule needs to execute the rule action only once to generate all the targets.

This is to avoid file locking and build failure in parallel make for such rules:

cmdparser.cpp cmdparser.hpp: cmdparser.y
bison -d -o cmdparser.cpp cmdparser.y

If 2 other rules need the 2 targets at the same time, currently the bison comand runs twice in parallel. At best the 2 bison processes have write access to the output files, produce corrupted output files and the build doesn't fail. At worst one bison process locks the output files, the second bison process errors out because it cannot get write access to the files, and the build fails.

A possible work around is this:

cmdparser.hpp: cmdparser.cpp
cmdparser.cpp: cmdparser.y
bison -d -o cmdparser.cpp cmdparser.y

But this syntax is not as clean and less intuitive.

Thank you,
Fred

Fred Bleuzet <fbleuzet4>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by ccb23 (Voted in favor of this item)
  • -unavailable- added by tahonermann (Posted a comment)
  • -unavailable- added by yost (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 100 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Tue 16 Feb 2010 09:30:24 AM UTCccb23Carbon-Copy-=>Added ccb23
    Sun 02 Apr 2006 12:38:48 AM UTCnikmCarbon-Copy-=>Added -unavailable-

    Back to the top


    Powered by Savane 3.1-cleanup