23Skidoo / ghc-parmake

A parallel wrapper for 'ghc --make'.
BSD 3-Clause "New" or "Revised" License
10 stars 2 forks source link

Detecting whether a file contains module Main #14

Open nh2 opened 11 years ago

nh2 commented 11 years ago

As noted in the code already:

TODO: To fully emulate GHC's behaviour, we must know whether the input module
set contains a module Main.

Consider these two invocations:

$ ghc --make Module.hs Module0.hs
[1 of 2] Compiling Module           ( Module.hs, t/Module.o )
[2 of 2] Compiling Module0          ( Module0.hs, t/Module0.o )

$ ghc --make Module.hs Main.hs
[1 of 2] Compiling Module           ( Module.hs, t/Module.o )
[2 of 2] Compiling Main             ( Main.hs, t/Main.o )
Linking Main ...

In the first case, the linking step is not performed since there is no module
called 'Main'.

Additionally, the module 'Main' can have an arbitrary source file name, not
necessary 'Main.hs'. This changes the name of the output executable:

$ ghc --make Module.hs MyProg.hs
[1 of 2] Compiling Module           ( Module.hs, t/Module.o )
[2 of 2] Compiling Main             ( MyProg.hs, t/Main.o )
Linking MyProg ...

Let's use this issue for discussion.

nh2 commented 11 years ago

As far as I understand, only GHC can detect whether a module ends up as module Main because you can e.g. switch the module name using CPP.

nh2 commented 11 years ago

I just realized that this is not a problem any more, since the final ghc pass we do now will detect this correctly.

I addressed it in https://github.com/23Skidoo/ghc-parmake/pull/15.