swiftc: make it support @file/-filelist

Number:rdar://35879960 Date Originated:December 6 2017
Status:open Resolved:no
Product:Developer Tools Product Version:Xcode 9.1 (9B55)
Classification: Reproducible:Yes
When Swift project is big enough, the build system generates a swiftc command that does not fit the command line length on the host system, failing to build the project. clang supports @file format to read the inputs, ld has -filelist flag to pass the list of files to link into the binary, but swiftc apparently does not support neither of these flags. Thus, it is not possible to build large swift modules.

Steps to Reproduce:
1. Checkout https://github.com/CognitiveDisson/ProjectOverflow
2. Run `bash generate_folder.sh`
3. Open ProjectOverflow.xcodeproj in Xcode and press Build
4. Observe error: 
Build operation failed without specifying any errors. Individual build tasks may have failed for unknown reasons.
One possible cause is if there are too many (possibly zombie) processes; in this case, rebooting may fix the problem.
Some individual build task failures (up to 12) may be listed below.
5. Switch the project settings to use the new build system.
6. Hit Build again. Now build will fail with the following error message: Unable to spawn the process. In the build log you will see the command that Xcode attempted to execute:
/Applications/Xcode.app/.../usr/bin/swiftc    /path/to/ProjectOverflow/test/1/2/3/3abcdefghijklmnopqrstuvwxyz384.swift /path/to/ProjectOverflow/ProjectOverflow/test/1/1abcdefghijklmnopqrstuvwxyz919.swift //path/to/ProjectOverflow/ProjectOverflow/test/1/1abcdefghijklmnopqrstuvwxyz386.swift

Expected Results:
The build finishes or fails without an error that process has failed to spawn.

Actual Results:
Buils fails and build logs (when new build system is enabled) shows that command line is too lengthy. Copy-pasting the command from Xcode build log into some bash script and attempting to execute it will print: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc: Argument list too long"

Xcode 9.1 (9B55)

macOS 10.13.1, Swift 4


Still seeing this issue on 10.2

Workaround by shortening root dir no longer working as I've already shortened it as much as I can in order to fix this issue in the past.

By brad.patras at April 22, 2019, 3:46 p.m. (reply...)

Still see the issue on Xcode 10.2

This is issue seems to be fixed on the compiler Swift but Xcode appears to still need to be updated to write its command line arguments to a @params file in order for it to work. Please add Xcode support.

We still see this issue on Xcode 10.1 (10B61), Swift 4.2

By Dima.stAshevsky at Dec. 12, 2018, 10:31 p.m. (reply...)

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!