Swift 2.3 incremental compilation doesn't work occassionally

Originator:keithbsmiley
Number:rdar://28292226 Date Originated:13-Sep-2016 06:33 PM
Status:Resolved Resolved:Xcode 9.0
Product:Developer Tools Product Version:Xcode 8 GM
Classification:UI/Usability Reproducible:Sometimes
 
Summary:

Often with our Swift 2.3 app when changing small portions of internal functions,
we notice the entire app gets recompiled. I enabled the private
`ExplainWhyBuildCommandsAreRun` flag (rdar://27516128) and the explanation is:

```
(running because command line arguments are different from the last time)
```

With a little more digging, I diffed the command line arguments before and after
and noticed this difference:

```
% diff -Nur beforeargs.txt afterargs.txt | diff-highlight | less
--- beforeargs.txt      2016-09-13 18:17:08.000000000 -0700
+++ afterargs.txt       2016-09-13 18:17:18.000000000 -0700
@@ -64,7 +64,10 @@
  -Xcc \
  -I/Users/ksmiley/dev/lyft-ios/build/Intermediates/Lyft.build/Debug-iphoneos/Lyft.build/Lyft-own-target-headers.hmap \
  -Xcc \
- -I/Users/ksmiley/dev/lyft-ios/build/Intermediates/Lyft.build/Debug-iphoneos/Lyft.build/Lyft-all-target-headers.hmap \
+ -I/Users/ksmiley/dev/lyft-ios/build/Intermediates/Lyft.build/Debug-iphoneos/Lyft.build/Lyft-all-non-framework-target-headers.hmap \
+ -Xcc \
+ -ivfsoverlay \
+ -Xcc /Users/ksmiley/dev/lyft-ios/build/Intermediates/Lyft.build/all-product-headers.yaml \
  -Xcc \
  -iquote \
  -Xcc /Users/ksmiley/dev/lyft-ios/build/Intermediates/Lyft.build/Debug-iphoneos/Lyft.build/Lyft-project-headers.hmap \
```

It seems that this `ivfsoverlay` flag is getting added without any project file
or configuration changes, only small source changes. This requires our app to
build from scratch which takes quite a few minutes.

Steps to Reproduce:

1. Create a Swift 2.3 project
2. Compile the project a few times
3. Check the build logs for why it was recompiled

Expected Results:

It should be incremental each time the app compiles.

Actual Results:

It is incrementally compiled sometimes, sometimes it recompiles from scratch with new arguments.

Notes:

Our general app layout involves a few Swift and Objective-C dynamic framworks
and static libraries, along with a few app extensions and of course our main
target.

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!