help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Compiling Link dependent targets in parallel


From: Brian Cowan
Subject: RE: Compiling Link dependent targets in parallel
Date: Mon, 17 Oct 2022 12:29:35 +0000

Breaking the recipes into compile and link phases is the best bet. You could do 
something convoluted to enforce the link order, like have A's link phase 
explicitly wait on a flag file created at the end of B's build... But that 
wastes cycles and likely will have negative impacts on build performance.

Rearchitecting serial makefiles for parallel builds is a wonderful "learning 
opportunity" -- you get to learn how your stuff REALLY builds. You may also 
find yourself discovering previously unknown implicit dependencies in your 
builds...

-------- Original Message --------
From: Help-make <help-make-bounces+cowanb22=us.ibm.com@gnu.org> on behalf of 
Paul Smith <psmith@gnu.org>
Date: Sat, October 15, 2022 11:03 AM -0400
To: shubham sharma <shubhamsharma4060@gmail.com>, help-make@gnu.org
Subject: [EXTERNAL] Re: Compiling Link dependent targets in parallel

On Fri, 2022-10-14 at 17:50 +0530, shubham sharma wrote:
> Currently for link dependent targets, say if A depends on B, for A to
> start compiling the compilation and linking of B has to be completed
> first.  But given that compilation of both the targets is independent
> of each other, isn't there a way where A and B compile in parallel
> and this wait happens only at Link Time. i.e
>
> -> A's compilation starts
> -> B's compilation starts (in parallel)
> -> if A finishes first it waits for B to finish(for linking), but if
> B finishes first A doesn't have to wait

Sorry but I don't understand the question.  You say "for A to start
compiling ... B has to be completed" but then you say "the compilation
of both targets is independent".  Both of those cannot be true.

It seems you might be confusing compiling and linking, which are two
different steps.  If you create A by linking a bunch of object files
plus B (say B is a shared library or whatever), and you create B by
linking a bunch of object files, then of course you can (and make will)
compile all the object files in parallel before linking B, then A.
That's the whole point of parallel builds.

Are you perhaps doing all the compiling and linking in a single rule?
That cannot work well if you want to create a parallel environment.

Perhaps if you provided an example of a makefile that does not do what
you want we can help.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]