3

I'm working on a team project using Haskell and whenever I compile our project using 'cabal install' I start seeing the following:

$ cabal clean && cabal install
cleaning...
Resolving dependencies...
Configuring hackathon-0.1...
Building hackathon-0.1...
Preprocessing executable 'hackathon' for hackathon-0.1...
[ 1 of 65] Compiling Data.MaybeUtil   ( src/Data/MaybeUtil.hs, dist/dist-sandbox-52369b17/build/hackathon/hackathon-tmp/Data/MaybeUtil.o )
[ 2 of 65] Compiling Data.JQL         ( src/Data/JQL.hs, dist/dist-sandbox-52369b17/build/hackathon/hackathon-tmp/Data/JQL.o )
[ 3 of 65] Compiling Data.Tuples      ( src/Data/Tuples.hs, dist/dist-sandbox-52369b17/build/hackathon/hackathon-tmp/Data/Tuples.o )
...
$

However, my team members see:

$ cabal clean && cabal install
cleaning...
Resolving dependencies...
Configuring hackathon-0.1...
Building hackathon-0.1...
Installed hackathon-0.1

What is different in their configuration that they don't see all of the "Progress" messages that start with [X of N] My.Module?

I would really like them to be able to see the progress of the compilation as it is happening as our project is quite large and currently has 65 modules and growing. Cheers!

Robert Massaioli
  • 13,379
  • 7
  • 57
  • 73
  • 3
    A guess: perhaps they have `-j` or similar and you don't; or you have `-j1` or similar and they don't. – Daniel Wagner Jun 06 '15 at 04:34
  • Probably they did the compile already and repeating it again ? – Sibi Jun 06 '15 at 08:38
  • This is doing a cabal clean first just like I have shown above. So no, this is not an issue of incremental compilation. The -j flag idea seems to be the most likely at the moment. It's a shame Tuesday is likely the first time I can get them to try again. – Robert Massaioli Jun 06 '15 at 12:55
  • I'm beginning to think that Daniel's suggestion is the right one. Will test out on Tuesday. – Robert Massaioli Jun 06 '15 at 23:42

2 Answers2

3

When you run cabal install multithreaded (-j2 and up), single file compilation does not appear on stdout, but should still be written to the log file.

Arnon
  • 2,237
  • 15
  • 23
  • Okay, I don't see the [X of Y] My.Module lines appearing in any of the log files in .cabal-sandbox/logs when I compile with -jx where x >= 2. I see nothing appear in the app-name.log file and the builds.log file does not have much useful information either. Are you sure that the modules are logged to the log file when multi-processor compilation is on? – Robert Massaioli Jun 06 '15 at 12:55
1

Okay, I decided to just look at the source code and answer my own question. After diving through the cabal-install source code and ending up inside the GHC source I eventually found what I was looking for at the bottom of compiler/main/HscMain.hs:

showModuleIndex :: (Int, Int) -> String
showModuleIndex (i,n) = "[" ++ padded ++ " of " ++ n_str ++ "] "
  where
    n_str = show n
    i_str = show i
    padded = replicate (length n_str - length i_str) ' ' ++ i_str

This is the method that prints the Module Index. It is used inside a function called batchMsg which wraps it with a method called compilationProgressMessage:

compilationProgressMsg :: DynFlags -> String -> IO ()
compilationProgressMsg dflags msg
  = ifVerbose dflags 1 $
    logOutput dflags defaultUserStyle (text msg)

As you can see this method only prints things to the log output filestream if the verbosity is one or higher.

So I have just tried to do this in my terminal:

cabal install -j4 -v1

And then if I tail -f the .cabal-sandbox/logs/package-name.log file then I can see the module indexed compilation messages happening. I think that this solves this problem. Then, when the compilation finishes (or errors out) all of the module messages get printed to stdout. It seems that something is blocking print calls to stdout in parallel compilation in GHC. There is also something that sets the verbosity to 0 when you turn on parallel compilation. I think that both of these are bugs and should be fixed so I may go and try and raise feature requests now.

At any rate I hope that this investigation helps somebody else too. Cheers and thanks for the pointers everybody!

Robert Massaioli
  • 13,379
  • 7
  • 57
  • 73