Skip to content

build: statically link a subset of libraries #4182

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 2, 2022

Conversation

compnerd
Copy link
Member

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.]

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.
compnerd added a commit to compnerd/swift-installer-scripts that referenced this pull request Feb 27, 2022
…r#4182

Update the packaging manifest for partially statically linking the
swift-package-manager libraries.  This reduces the number of distributed
libraries and the overall size of the toolchain by a minuscule amount.
@compnerd
Copy link
Member Author

This requires that swiftlang/swift-installer-scripts#76 is co-merged.

@compnerd
Copy link
Member Author

@swift-ci please smoke test

@compnerd
Copy link
Member Author

compnerd commented Mar 1, 2022

@swift-ci please smoke test Linux platform

@compnerd compnerd merged commit 910552c into swiftlang:main Mar 2, 2022
@compnerd compnerd deleted the partial-static branch March 2, 2022 16:34
compnerd added a commit to swiftlang/swift-installer-scripts that referenced this pull request Mar 2, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants