GHC API: Problems with implementing ":reload" for "ghc --make"

Hello all, My goal is to write a program GhcRemake that works like "ghc --make." However, instead of terminating after compilation is done, I want the program to stay open and wait for me to hit <ENTER>. When I hit <ENTER>, GhcRemake rebuilds the project, just as if I had called "ghc --make" again with the same arguments. The benefit of such a program is that GhcRemake should be able to cache a lot of data in memory between invocations and hopefully be able to do the subsequent re-makes much faster. I tried to do this by using the GHC API, and doing the initial build and all subsequent builds in the same session. My program seems to work fine when run on itself and when run on Cabal. But, these two packages seem to be too small to notice any reduction of building time. So, I decided to test my program by building the GHC API with it. Unfortunately, it seems like every build after the first one in the session does the dependency analysis badly, and things get recompiled unnecessarily. In the tests below, you can tell when things get recompiled because you will see a lot of warning messages (due to the -W parameter). Probably this is due to a mistake on my part but I can't figure out what it is. I would be very grateful if somebody could point out what I am doing wrong or what the problem is. I basically copied 90% of the code for the program from GHC's Main.hs, so it should be familiar to people on the GHC team. You need to be using a recent GHC 6.5. snapshot for everything described below. Here is the test procedure: 1. I run the program and it will do the intial make, just like ghc --make does. 2. I quit the program (type "quit" <ENTER>). 3. I run the program. It notices that nothing needs to be recompiled. 4. I quit the program. 5. I run ghc --make. It notices that nothing needs to be recompiled. 6. I run the program again, and it notices that nothing needs to be recompiled. 7. Instead of quitting, I hit <ENTER> to re-make the library. But now, GhcRemake thinks that a lot of things need to be recompiled. It should notice that nothing needs to be recompiled. 8. After I let it recompile, I hit <ENTER> to re-make the library again. But, again, it things a lot of things need to be recompiled. Again, it should notice that nothing needs to be recompiled. 9. I quit the program (type "quit" <ENTER>). 10. now I run a ghc --make. But, ghc --make things things need to be recompiled too. It should have noticed that nothing needs to be recompiled. 11. If I run the program again, it notices that nothing needs to be recompiled. 12. But, if I hit <ENTER> to re-make the program, it suddenly thinks that many source files need to be compiled. It should have noticed that nothing needs to be recompiled. The ghc --make command I am using to build the GHC API is: cd ghc/compiler ghc --make GHC -package-name ghc -package base -package template-haskell -package Cabal -package Win32 -package regex-compat -O0 -W -fno-warn-unused-matches -fwarn-unused-imports -fglasgow-exts -fno-generics -DBREAKPOINT -DDEBUG -recomp -cpp -include"cutils.h" -Istage2 -I. -Iparser -keep-tmp-files -iutils -ibasicTypes -itypes -ihsSyn -iprelude -irename -itypecheck -icoreSyn -ispecialise -isimplCore -istranal -isimplStg -imain -iprofiling -iparser -icprAnalysis -indpFlatten -iiface -ighci -ideSugar -icodeGen -inativeGen -icmm -istgSyn To build my program, you just need to change the pathToGHC variable in its source code, and then use ghc --make: ghc --make -fffi GhcRemake -package ghc -package Cabal or you can use Cabal: runhaskell Setup.lhs configure runhaskell Setup.lhs build runhaskell Setup.lhs install Then, to run my program, just give it the same arguments as you gave "ghc --make" (without "--make"): cd ghc/compiler path/to/GhcRemake.exe GHC -package-name ghc -package base -package template-haskell -package Cabal -package Win32 -package regex-compat -O0 -W -fno-warn-unused-matches -fwarn-unused-imports -fglasgow-exts -fno-generics -DBREAKPOINT -DDEBUG -recomp -cpp -include"cutils.h" -Istage2 -I. -Iparser -keep-tmp-files -iutils -ibasicTypes -itypes -ihsSyn -iprelude -irename -itypecheck -icoreSyn -ispecialise -isimplCore -istranal -isimplStg -imain -iprofiling -iparser -icprAnalysis -indpFlatten -iiface -ighci -ideSugar -icodeGen -inativeGen -icmm -istgSyn BTW, I am planning to extend this program in many ways in the future, including a ":make" command for GHCi, an "--interactive --make" mode for GHC itself. Eventually, I would like to implement a "quick error checking with automatic background compilation" mode as well. Thanks, Brian Smith
participants (1)
-
Brian Smith