[xmonad] Re: darcs patch: XMonad.Core: rw recompilation

Jan Vornberger Jan.Vornberger at Informatik.Uni-Oldenburg.DE
Fri Jun 11 19:42:58 EDT 2010

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
> <allbery at ece.cmu.edu> 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
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

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?

-------------- next part --------------
Sat Jun 12 01:23:43 CEST 2010  Jan Vornberger <jan.vornberger at informatik.uni-oldenburg.de>
  * Redirect GHC's intermediate files to ~/.xmonad/.ghc_temporary_outputdir and clean up later

New patches:

[Redirect GHC's intermediate files to ~/.xmonad/.ghc_temporary_outputdir and clean up later
Jan Vornberger <jan.vornberger at informatik.uni-oldenburg.de>**20100611232343
 Ignore-this: b96ca55eb58e63b2f03cdb10a2c8fbb8
] {
hunk ./XMonad/Core.hs 452
         err  = base ++ ".errors"
         src  = base ++ ".hs"
         lib  = dir </> "lib"
+        tmp = dir </> ".ghc_temporary_outputdir"
     libTs <- mapM getModTime . Prelude.filter isSource =<< allFiles lib
     srcT <- getModTime src
     binT <- getModTime bin
hunk ./XMonad/Core.hs 458
     if force || any (binT <) (srcT : libTs)
       then do
+        -- create tmp directory
+        createDirectoryIfMissing False tmp
         -- temporarily disable SIGCHLD ignoring:
         status <- bracket (openFile err WriteMode) hClose $ \h ->
hunk ./XMonad/Core.hs 464
-            waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-v0", "-o",binn] (Just dir)
+            waitForProcess =<< runProcess "ghc" ["--make", "xmonad.hs", "-i", "-ilib", "-fforce-recomp", "-outputdir", tmp, "-v0", "-o",binn] (Just dir)
                                     Nothing Nothing Nothing (Just h)
         -- re-enable SIGCHLD:
hunk ./XMonad/Core.hs 470
+        -- remove tmp directory
+        (try :: IO a -> IO (Either SomeException a)) $ removeDirectoryRecursive tmp
         -- now, if it fails, run xmessage to let the user know:
         when (status /= ExitSuccess) $ do
             ghcErr <- readFile err


[fix haddock comment being assigned to constructor instead of field
Tomas Janousek <tomi at nomi.cz>**20100415173936
 Ignore-this: 55ac1c5dadc88a0d7635d8952feb40a0
[HCAr.tex: update with additions and versions
gwern0 at gmail.com**20100502201321
 Ignore-this: 5724b4d52ce0e748ef36c4a6f343dcfd
[+original HCAR entry
gwern0 at gmail.com**20100502200252
 Ignore-this: 9b13691977a4e96d14ebf79c8d98cfd6
[Less refreshing in mouse-2 binding (thanks aavogt)
Spencer Janssen <spencerjanssen at gmail.com>**20100503155017
 Ignore-this: 5d61d6fd9a7663d0a7a1c8e2526230f7
[Replaced custom forever_ by library function
Daniel Schoepe <asgaroth_ at gmx.de>**20090114215556] 
[reveal: don't insert non-clients into the set of mapped windows
Tomas Janousek <tomi at nomi.cz>**20100327214243
 Ignore-this: 68c0a43d761e626cb9544ca386f4846d
 In xmonad-core, this fixes a small bug that caused doIgnored windows to get
 into `mapped' and never being removed from there.
 In the context of xmonad-contrib, this fixes a tremendous memory leak that
 could be triggered by using MouseResizableTile and UrgencyHook at the same
 time. MRT would create dummy windows that would get added to `mapped' by the
 reveal call in `windows'. As these were not removed (removal from `mapped' is
 filtered by `isClient'), they'd stay there forever and due to an inefficiency
 in UrgencyHook would eat up all memory sooner or later.
[loc.hs: hlintify
gwern0 at gmail.com**20100213231537
 Ignore-this: c447928ce68d0a968b55af3539c979fa
[Various clean-ups suggested by HLint
Spencer Janssen <spencerjanssen at gmail.com>**20100214025750
 Ignore-this: ccaa6e774f2f8169e6083eddcffe31b6
[Make the --replace docs consistent
Spencer Janssen <spencerjanssen at gmail.com>**20100213002647
 Ignore-this: c99526bce66ae1154fbf5713622f035d
[Add --replace flag with documentation (issue 99).
Adam Vogt <vogt.adam at gmail.com>**20091220183529
 Ignore-this: c56000295b75c66309913e29e1671d88
[Fix compile error when using base-3 (thanks bogner).
Adam Vogt <vogt.adam at gmail.com>**20100211063938
 Ignore-this: 60ba65613bc746e7e88f11a7e30b050f
[Broadcast PropertyChange events (needed for layouts with decoration)
Daniel Schoepe <daniel.schoepe at gmail.com>**20100113204017
 Ignore-this: c8315f438fed66b12282c9bfe70a4d0b
[Rename numlockMask to numberlockMask to help users of the template config.
Adam Vogt <vogt.adam at gmail.com>**20100118162256
 Ignore-this: 4050ed2d1ad373386c2e2b44145f07d9
 Without the change, the errors are like:
 >     [ unrelated error messages ]
 >     No constructor has all these fields: `numlockMask',
 >       `terminal', [every other field set]
 With the change:
 >     `numlockMask' is not a record selector
 >     [ context where numlockMask is named ]
[Correct warnings with ghc-6.12
Adam Vogt <vogt.adam at gmail.com>**20100118181532
 Ignore-this: a48ed095b72aedec9eeb88781ace66dc
 Changes include:
   - compatibility with base-4 or 3 (base-2 untested) by using
     extensible-exceptions. This adds an additional dependency for users of
   - list all dependencies again when -ftesting (change in Cabal-
   - remove unnecessary imports
   - suppress -fwarn-unused-do-bind, with appropriate Cabal-1.8 workaround,
     described here:
[Add xfork: a forkProcess that works around process global state
Spencer Janssen <spencerjanssen at gmail.com>**20091223061623
 Ignore-this: 3f968260d8c1b6710c82566520c47c43
[TAG 0.9.1
Spencer Janssen <spencerjanssen at gmail.com>**20091216233643
 Ignore-this: 856abdca8283155bbb8bdf003797ba34
[extra-source-files for the new manpage
Spencer Janssen <spencerjanssen at gmail.com>**20091216232005
 Ignore-this: 919d964238198dd56d96a5052c2419c7
[Bump to 0.9.1
Spencer Janssen <spencerjanssen at gmail.com>**20091216231110
 Ignore-this: 8a03850d758e1e4030d930cd8bf08ba9
[Determine numlockMask automatically, fixes #120
Spencer Janssen <spencerjanssen at gmail.com>**20091216012140
 Ignore-this: d80c82dd0a23dc7a77fdc32fd2792130
[Update for X11
Spencer Janssen <spencerjanssen at gmail.com>**20091216011700
 Ignore-this: 669c764c4c0ca516c8bdc1dfa35cd66
[Safer X11 version dependency
Spencer Janssen <spencerjanssen at gmail.com>**20091216010330
 Ignore-this: 8297f7a6a65c5c97f83f860f642fc25
[man/xmonad.hs: remove reference to deprecated 'dynamicLogDzen' function
Brent Yorgey <byorgey at cis.upenn.edu>**20091126053908
 Ignore-this: 7aeeac9791ffd3e6ac22bf158ea86536
[A few tweaks to --verbose-version
Spencer Janssen <spencerjanssen at gmail.com>**20091208040729
 Ignore-this: cf3d6a904d23891829c10f4966974673
[Generalize the type of (<+>). It can be used for keybindings too.
Adam Vogt <vogt.adam at gmail.com>**20091205233611
 Ignore-this: af15248be5e483d1a6e924f786fcc1c4
[Main.hs +--verbose-version flag
gwern0 at gmail.com**20091128144840
 Ignore-this: 61a081f33adb460ea459950a750dd93f
 This resolves http://code.google.com/p/xmonad/issues/detail?id=320 by adding a
 --verbose-version option yielding output like "xmonad 0.9 compiled by ghc 6.10 for linux/i386"
[Swap the order that windows are mapped/unmapped.  Addresses #322
Spencer Janssen <spencerjanssen at gmail.com>**20091119025440
 Ignore-this: 22087204f1b84dae98a3cf2b7f116d3f
[Add GPL warning to GenerateManpage
Spencer Janssen <spencerjanssen at gmail.com>**20091111000106
 Ignore-this: ea24691b8198976a4088a2708e0b4c94
[Add a basic header to the html manpage output
Adam Vogt <vogt.adam at gmail.com>**20091028033042
 Ignore-this: 2641e0fb3179616075fa7549b57740f3
[Use pandoc to convert a markdown manpage tranlation to html and man.
Adam Vogt <vogt.adam at gmail.com>**20091028030639
 Ignore-this: cdf7cdc8e44b21de8fc7725bde299792
[Support for extensible state in contrib modules.
Daniel Schoepe <daniel.schoepe at gmail.com>**20091106115050
 Ignore-this: d04ee1989313ed5710c94f9d7fda3f2a
[Set SIGPIPE to default in forked processes
Spencer Janssen <spencerjanssen at gmail.com>**20091106223743
 Ignore-this: f73943e4fe6c5f08967ddb82afad3eaa
[TAG 0.9
Spencer Janssen <spencerjanssen at gmail.com>**20091026004641
 Ignore-this: 80347d432f3b606c8d722536d0d729aa
Patch bundle hash:

More information about the xmonad mailing list