Skip to content

Dirs created by GHC.Utils.TmpFs.newTempDir cannot be removed

GHC.Utils.TmpFs.newTempDir creates a new ghc_N subdirectory in a temp directory, but this directory cannot be removed. The result is a warning at the end of the GHC run.

It's not possible to clean this ghc_N subdirectory using addFilesToClean:

  • addFilesToClean uses removeFile and fails for directories
  • the to-clean list is kept in a Set FilePath and doesn't preserve the order in which the files were added, so a dir could potentially be removed before the files contained in it.

I've come up with two ideas to fix it

  • when removing a top-level ghc temp dir, automatically remove empty ghc_N subdirs inside it (in cleanTempDirs)
  • keep track of all created ghc_N by newTempDir and remove them as the first step in cleanTempDirs

Any preferences or other ideas?

Edited by Luite Stegeman
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information