[bug #58056] Forced prerequisite order is not honored with pattern rules

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

[bug #58056] Forced prerequisite order is not honored with pattern rules

anonymous
URL:
  <https://savannah.gnu.org/bugs/?58056>

                 Summary: Forced prerequisite order is not honored with
pattern rules
                 Project: make
            Submitted by: None
            Submitted on: Fri 27 Mar 2020 11:14:42 AM UTC
                Severity: 3 - Normal
              Item Group: Bug
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
       Component Version: 4.3
        Operating System: None
           Fixed Release: None
           Triage Status: None

    _______________________________________________________

Details:

Given the following Makefile:


all: foo.bar

%.bar: | %_A %_B
        @

%_A:
        @echo $@
foo_B:
        @echo $@


We get:


% make
foo_B
foo_A


Instead of:


% make
foo_A
foo_B


The forced order "%_A %_B" in the prerequisites of "%.bar" is not respected.

Note that replacing "foo_B:" with "%_B" does not trigger the bug.




    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58056>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #58056] Forced prerequisite order is not honored with pattern rules

anonymous
Follow-up Comment #1, bug #58056 (project make):

This behavior is intended.

1. To figure out if a target has to be rebuilt make traverses the list of
prerequisites and finds out if any of the prerequisites, but not intermediate
prerequisites, need to be rebuilt.
During this traverse make rebuilds all prerequisites that are out of date. If,
during this traverse, make finds out that some prerequisite was out of date,
then make proceeds to rebuild intermediate prerequisites.

Intermediate prerequisites are not rebuild during this traverse along with
prerequisites because, if all prerequisites are up to date then the target is
up to date and there is no need to built intermediate prerequisites.

In your example
foo_A is an intermediary prerequisite.
foo_B is a prerequisite.

2. Another reason is to allow parallel execution. If all prerequisites had to
be built in the specified order how would you built them in parallel?

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58056>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #58056] Forced prerequisite order is not honored with pattern rules

anonymous
Follow-up Comment #2, bug #58056 (project make):

[comment #1 comment #1:]
> This behavior is intended.
> [...]
> 2. Another reason is to allow parallel execution. If all prerequisites had
to be built in the specified order how would you built them in parallel?

Did you notice the '|'? foo_A and foo_B are order-only-prerequisites, which
should disable any parallelism.

https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58056>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #58056] Forced prerequisite order is not honored with pattern rules

anonymous
Follow-up Comment #5, bug #58056 (project make):


[comment #3 comment #3:]
> make builds order only prerequisites in parallel.

How can the ordering on the rules be respected then?

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58056>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

[bug #58056] Forced prerequisite order is not honored with pattern rules

anonymous
Follow-up Comment #6, bug #58056 (project make):

[comment #4 comment #4:]
> So I claim that parallel make and order-only prerequisites are distractions
here. We should start with the documentation: what does it guarantee about the
build order of the prereqs in the example makefile variants, in a serial
make?

Wait, so order-only prerequisites does NOT mean serialized make for these
prerequisites? "a situation where you want to impose a specific ordering on
the rules to be invoked" ← That's not what this means?

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58056>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

Re: [bug #58056] Forced prerequisite order is not honored with pattern rules

Henrik Carlqvist-2
On Mon, 30 Mar 2020 12:17:24 -0400 (EDT)
anonymous <[hidden email]> wrote:

> Wait, so order-only prerequisites does NOT mean serialized make for
> these prerequisites?

Nope.

> "a situation where you want to impose a specific
> ordering on the rules to be invoked" ← That's not what this means?

Please read the rest of that sentence, and pay special attention to the
bold italic *without*:

"...*without* forcing the target to be updated if one of those rules is
executed".

Tha page has a good example explaining that order-only-prerequisites will
be created if needed but their updates will not cause your targets to be
rebuilt.

regards Henrik

Reply | Threaded
Open this post in threaded view
|

[bug #58056] Forced prerequisite order is not honored with pattern rules

anonymous
In reply to this post by anonymous
Follow-up Comment #12, bug #58056 (project make):

If this behavior is allowed, I think the documentation should clarify what the
order-only prerequisites actually means. I still haven't figured out their
purpose or how they operate based on the documentation or what has been said
here. To me, the documentation basically implies that everything after the '|'
is serialized.

Sorry if this is getting of topic, but the issue exists in the first place
because of this confusion. I usually never assume any serialization of the
prerequisites, but I needed to enforce it in a particular scenario and though
the '|' was for this.

    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?58056>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/


Reply | Threaded
Open this post in threaded view
|

Re: [bug #58056] Forced prerequisite order is not honored with pattern rules

Henrik Carlqvist-2
On Mon, 30 Mar 2020 15:35:01 -0400 (EDT)
anonymous <[hidden email]> wrote:

> If this behavior is allowed, I think the documentation should clarify
> what the order-only prerequisites actually means.

Maybe a better name than "order-only-prerequisites" would have been
"exist-only-prerequisites".

> I still haven't figured out their purpose or how they operate based on
> the documentation or what has been said here.

I thinke the example in the documentation is rather clear and exactly
shows the need of order-only-prerequisites. You have a Makefile creating
object files from source files and want these object files in a directory
of their own and that directory should also be created by the Makefile.

Before the Makefile creates any object file it will have to create the
directory, therefore the object files will depend upon the directory.

But even though the object files depend upon the directory you do not want
to rebuild the object files becuase the timestamp of the directory changes
as it will change whenever some file is added or removed from the
directory.

That is exactly what the order-only-prerequisites is for, if the
order-only-prerequisite does not exist it will be created. If the
order-only-prerequisite does exist and has a newer timestamp than the
target it will still not cause the target to be rebuilt.

>To me, the documentation basically implies that everything after the '|'
>is serialized.

What part of
https://www.gnu.org/software/make/manual/html_node/Prerequisite-Types.html
made you think that? Was it that sentence that you read only half the
sentence, stopping at the emphasized important part of the sentence? I
don't think that sentence could have been any more clear, the important
part is even emphasized as bold and italic.

> I usually never assume any serialization of the prerequisites, but I
> needed to enforce it in a particular scenario and though the '|' was for
> this.

Instead you might want to look at what the existance of the .NOTPARALLEL
target in a Makefile does.

regards Henrik