build: statically link a subset of libraries #4182
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Now that Windows supports static link (to a certain extent), this
strategically statically links some of the internal libraries of Swift
Package manager. This set was determined empirically, and was shown to
have a size benefit (beyond just reducing the distributed file count).
Before:
273,408 Basics.dll
543,232 Build.dll
3,083,776 Commands.dll
187,904 LLBuildManifest.dll
994,304 PackageCollections.dll
168,960 PackageCollectionsModel.dll
892,928 PackageCollectionsSigning.dll
74,240 PackageFingerprint.dll
818,176 PackageGraph.dll
591,872 PackageLoading.dll
776,704 PackageModel.dll
220,672 PackageRegistry.dll
181,248 SourceControl.dll
560,640 SPMBuildCore.dll
44,544 SPMLLBuild.dll
1,037,312 Workspace.dll
587,776 XCBuildSupport.dll
310,272 Xcodeproj.dll
22,016 swift-build.exe
24,576 swift-package.exe
22,016 swift-run.exe
22,016 swift-test.exe
11,438,592 bytes
After:
273,408 Basics.dll
662,528 Build.dll
5,531,136 Commands.dll
817,664 PackageGraph.dll
591,872 PackageLoading.dll
776,704 PackageModel.dll
560,640 SPMBuildCore.dll
1,355,264 Workspace.dll
20,992 swift-build.exe
23,552 swift-package.exe
20,992 swift-run.exe
20,992 swift-test.exe
10,655,744 bytes
This saves ~768KiB.
This additionally helps save ~1KiB from sourcekit-lsp after
SourceKit-LSP transitions to static linking.
Statically linking all the content in the repository causes the SPM
distribution to balloon 250% to ~25MiB and causes SourceKit-LSP to
balloon 300% to ~7MiB.
While it would be nice to statically link in Build into the Commands
(which saves ~100 KiB), it results in an overall bloat due to SK-LSP
increasing by ~300 KiB.
[One line description of your change]
Motivation:
[Explain here the context, and why you're making that change. What is the problem you're trying to solve.]
Modifications:
[Describe the modifications you've done.]
Result:
[After your change, what will change.]