Opened 7 years ago

Last modified 7 years ago

#45274 new enhancement

Run portbuild::build_main once for each build.target

Reported by: ryandesign (Ryan Schmidt) Owned by: macports-tickets@…
Priority: Normal Milestone:
Component: base Version: 2.3.99
Keywords: Cc: cooljeanius (Eric Gallager), larryv (Lawrence Velázquez)
Port:

Description

With parallel building, there is the potential for a problem when a port sets build.target to multiple values, as was experienced for example with the faust-devel port in #45241.

One solution would be to run portbuild::build_main once for each build.target, rather than running it just a single time and passing it the entire build.target all at once.

Change History (7)

comment:1 Changed 7 years ago by larryv (Lawrence Velázquez)

Just repeating what I said on #45241:

The GNU Make documentation explicitly says that it processes each command-line goal in order:

You can also specify a different goal or goals with command line arguments to make. Use the name of the goal as an argument. If you specify several goals, make processes each of them in turn, in the order you name them.

Thus,

make A B C

satisfies target “A”, then “B”, and then “C”. I don’t know whether other Make variants behave similarly, but it’s easy enough to force GNU Make if necessary.

build.type gnu
build.target first foo bar baz last
Last edited 7 years ago by larryv (Lawrence Velázquez) (previous) (diff)

comment:2 Changed 7 years ago by larryv (Lawrence Velázquez)

Admittedly, the part of the documentation describing parallel execution is not clear on this.

comment:3 in reply to:  2 ; Changed 7 years ago by larryv (Lawrence Velázquez)

Sorry for the noise. Turns out that the documentation doesn’t describe the behavior very well: Specifying the goals on the command line simply adds them (in order) to the list of targets to be run, so parallel building behavior applies to them as usual.

% >test.makefile <<EOF
heredoc> .PHONY: foo bar baz
heredoc> 
heredoc> foo:
heredoc>        @echo foo start!
heredoc>        @sleep 10
heredoc>        @echo foo end!
heredoc> 
heredoc> bar:
heredoc>        @echo bar start!
heredoc>        @sleep 5
heredoc>        @echo bar end!
heredoc> 
heredoc> baz: 
heredoc>        @echo baz start!
heredoc>        @sleep 2
heredoc>        @echo baz end!
heredoc> EOF
% make -f test.makefile foo bar baz
foo start!
foo end!
bar start!
bar end!
baz start!
baz end!
% make -f test.makefile -j 8 foo bar baz
foo start!
bar start!
baz start!
baz end!
bar end!
foo end!
%

comment:4 in reply to:  3 ; Changed 7 years ago by ryandesign (Ryan Schmidt)

Replying to larryv@…:

Specifying the goals on the command line simply adds them (in order) to the list of targets to be run, so parallel building behavior applies to them as usual.

That's what I observed too.

So it may be that in the build failure that prompted me to file this ticket, the makefile's dependencies really are wrong. However, this may be a case where we can make a single small change to base which would have little or no effect on existing working ports but fix problems in a bunch of other ports and/or make portfile writing easier. I liken it to the small change we made to base some years ago to not run the destroot phase in parallel anymore—that should have worked too, but for many ports, it didn't, because makefile dependencies were wrong.

Last edited 7 years ago by ryandesign (Ryan Schmidt) (previous) (diff)

comment:5 Changed 7 years ago by cooljeanius (Eric Gallager)

Cc: egall@… added

Cc Me!

comment:6 in reply to:  4 Changed 7 years ago by larryv (Lawrence Velázquez)

Strictly speaking, this change would penalize ports with correctly-written makefiles that would otherwise benefit from having their command-line goals executed in parallel, but the number of ports satisfying this condition might be insignificant. And in such cases it would be trivial to patch in a new phony target, dependent on the required targets, and use that as ${build.target}.

So this seems like a good idea to me.

comment:7 Changed 7 years ago by larryv (Lawrence Velázquez)

Cc: larryv@… added

Cc Me!

Note: See TracTickets for help on using tickets.