Xcode duplicates precompiled headers once per build

Originator:nathaniel
Number:rdar://12288457 Date Originated:12-Sep-2012 04:02 PM
Status:Open Resolved:
Product:Developer Tools Product Version:4.4.1
Classification:Serious Bug Reproducible:Always
 
Summary: 
Xcode duplicates its cache of precompiled headers whenever it builds with a new value of CONFIGURATION_BUILD_DIR.

Steps to Reproduce:
1. Delete the DerivedData directory for a project, creating a baseline of zero existing precompiled headers.

2. Build the project, using a unique CONFIGURATION_BUILD_DIR, like so:

  xcodebuild -scheme 'Release (AppStore)' -configuration 'Release (AppStore)' clean build CONFIGURATION_BUILD_DIR=/tmp/ndi-1

3. Note the number of files inside DerivedData/unique-project-dir/Build/Intermediates/PrecompiledHeaders/. In my current project, it's 18.

4. Build again, using a different CONFIGURATION_BUILD_DIR parameter, like so:

  xcodebuild -scheme 'Release (AppStore)' -configuration 'Release (AppStore)' clean build CONFIGURATION_BUILD_DIR=/tmp/ndi-2

Expected Results:
Xcode should re-use the contents of PrecompiledHeaders from the previous build. If it can't re-use them, it should eventually clean up after itself.

Actual Results:
In my current project, I go from 18 subdirectories of PrecompiledHeaders to 36, and the size on disk grows by 225 MB. On the third build I've got 54. I see the same thing in other, smaller projects. This disk usage is never automatically reclaimed.

Notes:
I noticed this while configuring a continuous integration server, which uses unique values of CONFIGURATION_BUILD_DIR to avoid collecting build artifacts from earlier runs. DerivedData dirs on these build nodes now grow by 225 MB every time someone commits code to our main SCM branch. 

In the examples above, and on our CI server, we're performing clean builds, but this duplication occurs whether we clean or not. 

I'm using Xcode 4.4.1 on Mac OS X 10.7.4 and 10.8.1.

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!