How can I prevent Xcode 4.2 from filling my boot drive with preamble.pch files?
Asked Answered
T

2

7

There's an issue in Xcode 4.2, where Xcode will fill my boot drive with tens of GB of preamble.pch-****** files, someplace within /private/var/folders/.

Does anybody know how to prevent this from happening?

This means I have to manually empty these files every few hours (quitting/restarting Xcode if necessary), to prevent my boot drive from filling up. I'd (likely) rather revert to the old behavior than create some script or program to systematically remove these every hour, if possible.

Misc:

  • My builds do not use precompiled headers (it looks like these are being generated by Xcode's text editors, using Clang's code sense indexing).
  • Tens of GB is a lot for my boot partitions; I use several small partitions.

Thanks

Terpene answered 15/10, 2011 at 5:47 Comment(4)
@Bavarious Yes, I have considered it, and I don't share my machines so it is something I could do if that seems like the lesser evil when I want to reenable indexing (worth a +1 if you want to leave it as an answer). I keep the the bootable partitions/volumes small, but I have other partitions/volumes with plenty of free space.Terpene
@Bavarious excellent detective work :) that works to move that 138MB per minute growth to a larger volume.Terpene
And this is worth filing a radarKoniology
Related more generic on clang side: github.com/clangd/clangd/issues/1007Boony
K
2

I’m no clang expert, but a quick glance at lib/Frontend/ASUnit.cpp reveals that GetPreamblePCHPath() will use the value of three environment variables — in order: TMPDIR, TEMP and TMP — before defaulting to /tmp as the location of preamble PCH files. One (not really ideal) solution is to set one of those variables to a directory residing in another volume.

Koniology answered 16/10, 2011 at 8:10 Comment(1)
thanks for getting to the bottom of this. I agree that it's not ideal (especially for people who work on shared systems), but it's better than linking (which crossed my mind) when disabling code sense is not an option.Terpene
T
0

Disabling Xcode's code sense indexing is one way to work around this. Still, this is not always ideal, and I am open to other solutions.

Terpene answered 16/10, 2011 at 5:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.