Toolchain size increased after rebranch was merged (stable/20240723)

The toolchain size for Xcode has increased after updating to the stable branch (rebranch). The size of /usr/bin/clangd has gone up from 192.40 MB to 382.04 MB.

This graph illustrates the .pkg size for each tag from November 9, 2024, to January 2, 2020. The highlighted areas indicate the points when the new llvm-project branch was updated.

Xcode Toolchain:

  • swift-DEVELOPMENT-SNAPSHOT-2024-10-27-a-osx.pkg - 1.49 GB
  • swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a-osx.pkg - 1.61 GB

Uncompressed space on disk:

5.3G	/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-10-27-a.xctoolchain
5.6G	/Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a.xctoolchain

Diff between toolchain before and after rebranch.

Baseline: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-10-27-a.xctoolchain
Current: /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-10-30-a.xctoolchain
Size changed
+-----------------------------------------------------------------------------------------------------------+-----------+---------------+-------+
| File                                                                                                      | main (MB) | rebranch (MB) | Delta |
+-----------------------------------------------------------------------------------------------------------+-----------+---------------+-------+
| /usr/lib/clang/17/lib/darwin/libclang_rt.fuzzer_no_main_osx.a                                             |    2.00   |      1.64     |  -18% |
| /usr/lib/clang/17/lib/darwin/libclang_rt.fuzzer_osx.a                                                     |    2.00   |      1.64     |  -18% |
| /usr/lib/swift/macosx/libswift_Backtracing.dylib                                                          |    1.24   |      1.11     |  -10% |
| /usr/lib/swift/watchsimulator/libswift_Differentiation.dylib                                              |    1.68   |      1.64     |  -2%  |
| /usr/lib/swift/macosx/libswift_Differentiation.dylib                                                      |    1.07   |      1.05     |  -2%  |
| /usr/lib/swift/xrsimulator/libswift_StringProcessing.dylib                                                |    1.18   |      1.16     |  -1%  |
| /usr/lib/swift/iphonesimulator/libswift_StringProcessing.dylib                                            |    2.38   |      2.35     |  -1%  |
| /usr/lib/swift/appletvsimulator/libswift_StringProcessing.dylib                                           |    2.38   |      2.35     |  -1%  |
| /usr/lib/swift/watchsimulator/libswift_StringProcessing.dylib                                             |    3.61   |      3.57     |  -1%  |
| /usr/lib/swift/xros/libswift_RegexParser.dylib                                                            |    2.59   |      2.56     |  -1%  |
| /usr/lib/swift/iphoneos/libswift_RegexParser.dylib                                                        |    2.59   |      2.56     |  -1%  |
| /usr/lib/swift/xrsimulator/libswiftCore.dylib                                                             |    7.83   |      7.74     |  -1%  |
| /usr/lib/swift/appletvos/libswiftCore.dylib                                                               |    7.87   |      7.78     |  -1%  |
| /usr/lib/swift/appletvos/libswift_RegexParser.dylib                                                       |    1.27   |      1.26     |  -1%  |
| /usr/lib/swift/xrsimulator/libswift_RegexParser.dylib                                                     |    1.27   |      1.26     |  -1%  |
| /usr/bin/swift-format                                                                                     |   39.82   |     39.39     |  -1%  |
| /usr/lib/swift/FrameworkABIBaseline/Swift/API/macos.json                                                  |    6.08   |      6.02     |  -1%  |
| /usr/lib/swift/appletvsimulator/libswiftCore.dylib                                                        |   16.02   |     15.87     |  -1%  |
| /usr/lib/swift/iphonesimulator/libswiftCore.dylib                                                         |   16.02   |     15.87     |  -1%  |
| /usr/lib/swift/watchos/libswiftCore.dylib                                                                 |   15.12   |     14.98     |  -1%  |
| /usr/lib/swift/watchsimulator/libswiftCore.dylib                                                          |   24.42   |     24.20     |  -1%  |
| /usr/lib/swift/watchos/libswift_Concurrency.dylib                                                         |    1.57   |      1.56     |  -1%  |
| /usr/lib/swift/macosx/libswiftCore.dylib                                                                  |   16.02   |     15.89     |  -1%  |
| /usr/lib/swift/iphonesimulator/libswift_Concurrency.dylib                                                 |    1.68   |      1.67     |  -1%  |
| /usr/lib/swift/appletvsimulator/libswift_Concurrency.dylib                                                |    1.68   |      1.67     |  -1%  |
| /usr/lib/swift/macosx/libswift_Concurrency.dylib                                                          |    1.68   |      1.67     |  -1%  |
| /usr/lib/swift/watchos/libswift_StringProcessing.dylib                                                    |    2.31   |      2.29     |  -1%  |
| /usr/lib/swift/macosx/libswift_StringProcessing.dylib                                                     |    2.38   |      2.36     |  -1%  |
| /usr/bin/sourcekit-lsp                                                                                    |   117.18  |     116.50    |  -1%  |
| /usr/bin/swift-package                                                                                    |   104.59  |     104.01    |  -1%  |
| /usr/lib/swift/macosx/libswift_RegexParser.dylib                                                          |    2.60   |      2.59     |  -1%  |
| /usr/lib/swift/iphonesimulator/libswift_RegexParser.dylib                                                 |    2.60   |      2.59     |  -1%  |
| /usr/lib/swift/appletvsimulator/libswift_RegexParser.dylib                                                |    2.60   |      2.59     |  -1%  |
| /usr/lib/swift/watchsimulator/libswift_Concurrency.dylib                                                  |    2.51   |      2.53     |   1%  |
| /usr/bin/swift-build-tool                                                                                 |    3.12   |      3.14     |   1%  |
| /usr/lib/swift/macosx/libTSCBasic.dylib                                                                   |    2.12   |      2.14     |   1%  |
| /usr/lib/swift/embedded/arm64-apple-macos/libswift_Concurrency.a                                          |    4.88   |      4.91     |   1%  |
| /usr/lib/swift/embedded/x86_64-apple-macos/libswift_Concurrency.a                                         |    4.91   |      4.95     |   1%  |
| /usr/lib/swift/xros/libswiftRemoteMirror.dylib                                                            |    2.36   |      2.38     |   1%  |
| /usr/lib/swift/iphonesimulator/libswiftRemoteMirror.dylib                                                 |    2.37   |      2.39     |   1%  |
| /usr/lib/swift/appletvsimulator/libswiftRemoteMirror.dylib                                                |    2.37   |      2.39     |   1%  |
| /usr/lib/swift/macosx/libswiftRemoteMirror.dylib                                                          |    2.37   |      2.39     |   1%  |
| /usr/lib/swift/iphoneos/libswiftRemoteMirror.dylib                                                        |    2.34   |      2.36     |   1%  |
| /usr/lib/swift/embedded/arm64e-apple-macos/libswift_Concurrency.a                                         |    4.92   |      4.96     |   1%  |
| /usr/bin/swift-demangle                                                                                   |    2.15   |      2.17     |   1%  |
| /_CodeSignature/CodeResources                                                                             |    1.09   |      1.10     |   1%  |
| /usr/lib/swift/pm/llbuild/libllbuildSwift.dylib                                                           |    4.06   |      4.11     |   1%  |
| /usr/lib/swift/watchsimulator/Swift.swiftmodule/Swift.opt.bitstream                                       |    2.65   |      2.69     |   2%  |
| /usr/lib/swift/xrsimulator/libswiftRemoteMirror.dylib                                                     |    1.15   |      1.17     |   2%  |
| /usr/lib/swift/watchos/libswiftRemoteMirror.dylib                                                         |    2.12   |      2.16     |   2%  |
| /usr/lib/swift/watchsimulator/libswiftRemoteMirror.dylib                                                  |    3.61   |      3.67     |   2%  |
| /usr/lib/swift/macosx/libSwiftOptions.dylib                                                               |    2.29   |      2.34     |   2%  |
| /usr/bin/dsymutil                                                                                         |   172.07  |     175.98    |   2%  |
| /usr/bin/lld                                                                                              |   266.24  |     275.51    |   3%  |
| /usr/lib/libLTO.dylib                                                                                     |   231.10  |     239.27    |   4%  |
| /usr/lib/sourcekitd.framework/Versions/A/sourcekitd                                                       |    1.21   |      1.27     |   5%  |
| /usr/bin/lldb                                                                                             |    1.19   |      1.25     |   5%  |
| /usr/lib/sourcekitd.framework/Versions/A/XPCServices/SourceKitService.xpc/Contents/MacOS/SourceKitService |   524.94  |     551.91    |   5%  |
| /System/Library/PrivateFrameworks/LLDB.framework/Versions/A/LLDB                                          |   552.69  |     581.16    |   5%  |
| /usr/bin/swift-frontend                                                                                   |   528.52  |     555.75    |   5%  |
| /usr/lib/swift/host/lib_InternalSwiftScan.dylib                                                           |   521.26  |     548.12    |   5%  |
| /usr/lib/swift/macosx/lib_InternalSwiftStaticMirror.dylib                                                 |   14.03   |     14.75     |   5%  |
| /usr/lib/clang/17/include/arm_neon.h                                                                      |    2.45   |      2.58     |   5%  |
| /System/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Clang/include/arm_neon.h            |    2.45   |      2.58     |   5%  |
| /usr/bin/clang-17                                                                                         |   463.70  |     495.59    |   7%  |
| /usr/bin/llvm-cov                                                                                         |   15.31   |     16.46     |   8%  |
| /usr/bin/llvm-profdata                                                                                    |   16.63   |     18.31     |  10%  |
| /usr/bin/llvm-ar                                                                                          |   46.89   |     51.79     |  10%  |
| /usr/lib/clang/17/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib                                           |    2.63   |      2.92     |  11%  |
| /usr/lib/clang/17/lib/darwin/libclang_rt.asan_osx_dynamic.dylib                                           |    3.20   |      3.57     |  12%  |
| /usr/bin/lldb-dap                                                                                         |    1.83   |      2.06     |  13%  |
| /usr/lib/clang/17/lib/darwin/libclang_rt.xray_osx.a                                                       |    1.51   |      1.74     |  15%  |
| /usr/lib/libIndexStore.dylib                                                                              |   28.41   |     33.12     |  17%  |
| /usr/lib/clang/17/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib                                           |    1.17   |      1.40     |  20%  |
| /usr/lib/clang/17/lib/darwin/libclang_rt.stats_osx_dynamic.dylib                                          |    0.90   |      1.08     |  20%  |
| /usr/lib/clang/17/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib                                          |    1.03   |      1.25     |  21%  |
| /System/Library/PrivateFrameworks/LLDB.framework/Versions/A/Resources/Clang/include/arm_sve.h             |    1.51   |      1.96     |  29%  |
| /usr/lib/clang/17/include/arm_sve.h                                                                       |    1.51   |      1.96     |  29%  |
| /usr/bin/clangd                                                                                           |   192.40  |     382.04    |  99%  |
+-----------------------------------------------------------------------------------------------------------+-----------+---------------+-------+

I didn't investigate this in detail, but the regression might be caused by upstream clangd changes to support standard C++ modules. This was discussed here and fixed by this PR. The gist of it is that clangd started linking the clangDependencyScanning library, which links clangCodeGen, which links LLVM targets.

That should have been resolved with [clang] Split ObjectFilePCHContainerReader from ObjectFilePCHContainerWriter by ChuanqiXu9 · Pull Request #99599 · llvm/llvm-project · GitHub I believe. We should check if that is merged into rebranch or if it got missed.

Created PR to cherry-pick the split to reduce the binary size.