bugmake - Bugs: bug #17881, Better documentation of make rules

 
 

bug #17881: Better documentation of make rules

Submitted by:  Howard Chu <hyc>
Submitted on:  Thu 28 Sep 2006 08:26:51 PM UTC  
 
Severity: 3 - NormalItem Group: Enhancement
Status: NonePrivacy: Public
Assigned to: NoneOpen/Closed: Open
Component Version: NoneOperating System: None
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.

 

Mon 20 Nov 2006 11:03:10 PM UTC, comment #2:

Actually, make does guarantee that rules will be processed in left-to-right order. If you never use parallelism, you can be sure your rules will always run in that order.

If you do use parallelism, though, obviously more than one of these rules will run at the same time. Even though make still starts them in left-to-right order in the makefile, it's up to your operating system to schedule the programs. In this case it's almost certain that commands to build the second target will start before the commands to build the first have completed.

I'm sure you're aware of this. However, saying the order is "insignificant" is not exactly correct. Saying that it is unreliable during parallel builds is better.

As for Howard's suggestion, that suggestion has been made before and I think it's a good one. However, it's not completely trivial to implement. For one thing, we can't afford to change the values of variables such as $<, or even $^ in some cases, so make would have to keep a separate list of "prereqs to run" vs. "prereqs used in automatic variables".

Paul D. Smith <psmith>
Project Administrator
Thu 28 Sep 2006 08:32:24 PM UTC, comment #1:

It might be worthwhile to add some kind of makefile validation flag, which processes all prerequisites in random or right-to-left order, specifically to expose occurrences of incorrect prerequisites.

Howard Chu <hyc>
Thu 28 Sep 2006 08:26:51 PM UTC, original submission:

The GNU make manual should state explicitly in section 4.2, Rule Syntax, something to this effect:

When multiple prerequisites are listed for a rule, their order is insignificant. In particular, you should not assume that prerequisites will be processed in left-to-right order. Rules that list prerequisites that depend on other prerequisites in the same rule are invalid and will break when processed by a parallel make.

For example, given a rule

targetA: reqOne reqTwo reqThree

if "reqThree" cannot be built successfully until "reqOne" already exists, then this rule does not specify the actual dependencies of targetA. The correct rules would be:

reqThree: reqOne

targetA: reqTwo reqThree

Howard Chu <hyc>

 

(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

 

CC list is empty

 

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

Only logged-in users can vote.

 

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

 

 

No Changes Have Been Made to This Item

Back to the top


Powered by Savane 3.1-cleanup