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

 
 

bug #17881: Better documentation of make rules

Submitter:  Howard Chu <hyc>
Submitted:  Thu 28 Sep 2006 08:26:51 PM UTC
   
 
Severity:  3 - Normal Item Group:  Enhancement
Status:  Fixed Privacy:  Public
Assigned to:  psmith Open/Closed:  Closed
Component Version:  3.81 Operating System:  None
Fixed Release:  None Triage Status:  None
* Mandatory Fields

Add a New Comment Rich Markup
   

Mon 02 Jan 2023 08:20:02 PM UTC, comment #3: 

GNU make 4.4 provides a shuffle feature that allows makefiles to be tested more easily for errors in parallel behavior.

I have other bugs relating to clarifying the introductory documentation here so I'll close this one.

Paul D. Smith <psmith>
Group administrator
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>
Group 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 Files:
   
   
Comment:
   

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 psmith (Posted a comment)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2023-01-02 psmith StatusNone Fixed
        Assigned toNone psmith
        Open/ClosedOpen Closed
        Component VersionNone 3.81

    Back to the top

    Powered by Savane 3.13-f8d8.
    Corresponding source code