<div dir="ltr">(FYI, I expect I'm the source of the suggestion that ghc -M is broken)<div><br></div><div>First, just to clarify, I don't think ghc -M is obviously broken.  Rather, I think it's broken in subtle, unobvious ways, such that trying to develop a make-based project with ghc -M will fail at various times in a non-obvious fashion, at least without substantial additional rules.  For an example of some of the extra steps necessary to make something like this work, see e.g. <a href="https://github.com/nh2/multishake">https://github.com/nh2/multishake</a> (which is admittedly for a more complicated setup, and also has some issues).  The especially frustrating part is, just when you think you have everything working, someone wants to add some other tool to a workflow (hsc2hs, .cmm files, etc), and your build system doesn't support it.</div>
<div><br></div><div>ghc --make doesn't allow building several binaries in one run, however if you use cabal all the separate runs will use a shared build directory, so subsequent builds will be able to take advantage of the intermediate output of the first build.  Of course you could do the same without cabal, but it's a convenient way to create a common build directory and manage multiple targets.  This is the approach I would take to building multiple executables from the same source files.</div>
<div><br></div><div>ghc doesn't do any locking of build files AFAIK.  Running parallel ghc commands for two main modules that have the same import, using the same working directory, is not safe.  In pathological cases the two different main modules may even generate different code *for the imported module*.  This sort of situation can arise with the IncoherentInstances extension, for example.</div>
<div><br></div><div>The obvious approach is of course to make a library out of your common files.  This has the downsides of requiring a bit more work on the developer's part, but if the common files are relatively stable it'll probably lead to the fastest builds of your executables.  Also in this case you could run multiple `ghc --make`s in parallel, using different build directories, since they won't be rebuilding any common code.</div>
<div><br></div><div>John L.</div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Jan 5, 2014 at 1:47 PM, Sami Liedes <span dir="ltr"><<a href="mailto:sami.liedes@iki.fi" target="_blank">sami.liedes@iki.fi</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Hi,<br>
<br>
I have a Haskell project where a number of executables are produced<br>
from mostly the same modules. I'm using a Makefile to enable parallel<br>
builds. I received advice[1] that ghc -M is broken, but that there<br>
is parallel ghc --make in HEAD.<br>
<br>
As far as I can tell, ghc --make does not allow building several<br>
binaries in one run, so I think it may not still be a full replacement<br>
for Makefiles.<br>
<br>
However I have a question about ghc --make that is also relevant<br>
without parallel ghc --make:<br>
<br>
If I have two main modules, prog1.hs and prog2.hs, which have mutual<br>
dependencies (for example, both import A from A.hs), is it safe to run<br>
"ghc --make prog1" in parallel with "ghc --make prog2"? IOW, is there<br>
some kind of locking to prevent both from building module A at the<br>
same time and interfering with each other?<br>
<br>
Is there a good way (either in current releases or HEAD) to build<br>
multiple binaries partially from the same sources in parallel?<br>
<br>
        Sami<br>
<br>
<br>
[1] <a href="http://stackoverflow.com/questions/20938894/generating-correct-link-dependencies-for-ghc-and-makefile-style-builds" target="_blank">http://stackoverflow.com/questions/20938894/generating-correct-link-dependencies-for-ghc-and-makefile-style-builds</a><br>

<br>_______________________________________________<br>
Glasgow-haskell-users mailing list<br>
<a href="mailto:Glasgow-haskell-users@haskell.org">Glasgow-haskell-users@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/glasgow-haskell-users" target="_blank">http://www.haskell.org/mailman/listinfo/glasgow-haskell-users</a><br>
<br></blockquote></div><br></div></div>