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 - Normal Item Group:  Enhancement
Status:  None Privacy:  Public
Assigned to:  None Open/Closed:  Open
Component Version:  None Operating System:  Any
Fixed Release:  None Triage Status:  None

Add a New Comment(Rich Markup)

You are not logged in

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


( 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.
touch foo 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
touch foo bar baz boz biz
echo boz
touch foo bar baz boz biz
echo 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


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 Bleuzet <fbleuzet4>


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

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


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

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

    Only logged-in users can vote.




    Follow 2 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2010-02-16 ccb23 Carbon-Copy- => Added ccb23
    2006-04-02 nikm Carbon-Copy- => Added -email is unavailable-

    Back to the top

    Powered by Savane 3.4