
On Wed, Jun 02, 2010 at 05:40:50PM -0400, Gwern Branwen wrote:
On Sat, May 8, 2010 at 3:42 PM, Brandon S. Allbery KF8NH
wrote: No; and in any case, I don't think you could get away with it because ghc is using those .hi and .o files internally (including passing the .o files to ld), so they have to go *somewhere*. And Unix doesn't have the notion of a temporary directory that goes away when the creating process exits, as it has for files (the open-and-unlink idiom); and there are problems with providing one.
I think what you really want is for ghc to have a treat-intermediate-files-in-this-session-as-ephemeral flag, such that the .hi and .o files created during a ghc invocation are removed after the link step.
Yes, I'm giving up on this one and punting it to GHC HQ. There just doesn't seem to be any satisfactory way for us to do it, short of shelling out to 'find'.
The bug report is http://hackage.haskell.org/trac/ghc/ticket/4114 if anyone wants to cc themselves (remember, CCs are like votes! except they count even less).
Another stab at this: Indeed putting stuff into /tmp can be a security risk. I think one solution is to use something like mkdtemp to create a temporary directory in a secure way and pass that to GHC. But according to this thread http://www.mail-archive.com/darcs-devel@darcs.net/msg03101.html even mkdtemp can be a problem in combination with tmp cleaners. On top of that, there doesn't seem to be an easily available mkdtemp implementation for Haskell. Maybe Unixutils on Hackage would fit the bill, but I guess we don't really want another package just for that. Because of all the security headache, it seems to me that most people just give up on /tmp and instead put stuff into directories somewhere below the user's home directory. So my suggestion: Redirect the intermediate files to ~/.xmonad/.ghc_temporary_outputdir and just delete that directory afterwards. This achieves: * less ways for GHC to break (after a GHC upgrade), Joachim's initial reason for the patch * less clutter in ~/.xmonad, as mentioned before as well * should work for modular configs too * has non of the /tmp security concerns Patch is attached! :-) Comments? Regards, Jan