-
Notifications
You must be signed in to change notification settings - Fork 336
[Linux] Adding swift-argument-parser as a dependency increases binary size to 50+MB (10x larger than without) #748
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
Comments
I might be wrong, but I think the
Edit: I have been (partially) wrong. Indeed |
Thanks for the reply,
I tried this just now, sadly it seems that the problem might not have to do with I then tried (all separately), compiling while importing:
|
No, the problem is that I put up a quick hack to only use You can try building with
In my test I got:
|
Ah, right you are. I tested as well, and my results were identical to yours, both with fully static linking against Musl and static Swift STDLIB with dynamic GLIBC they were under 15MB I appreciate your efforts to help me troubleshoot this very much; thank you. Is this an issue that the project intends to upstream (I.E. using I'm fine with forking your workaround to hold for personal use; since as of now the library does everything I need it to and more. I know linux isn't as large of a priority as the mainly supported platforms, so you can close/keep the issue at your discretion. Thanks again. |
My branch now passes all tests on both Linux and macOS. I think I will open this as a new PR soon. |
Happy to hear that! Thank you. |
With Swift version 6.0.3, on Linux, compiling a project with
swift-argument-parser
increases binary size from between 8MB/5MB (un-stripped/stripped), to 68MB/54MB respectively; resulting in a size increase of 8-10x.ArgumentParser version:
1.5.0
, also tested with1.3.0
with identical resultsSwift version:
6.0.3, target: x86_64-unknown-linux-gnu
Checklist
main
branch of this packageResults identical to that of versions 1.3.0 and 1.5.0
I read through #296, however the sizes there are much smaller and within reason.
Steps to Reproduce
Raw new project:
Resulting binary:
8.1MB
Stripped:
5.6MB
A bit beefy, but I'm willing to pay that price for anyone who uses my binaries to not depend on the Swift STD Library, since it's only officially supported on three distributions
In
Package.swift
, addingswift-argument-parser
swift build -c release --static-swift-stdlib
Resulting binary: 68MB
Stripped: 54MB
... Am I crazy or is this increase in size a bit strange?
When statically linked against the
x86_64-swift-linux-musl
SDK, the stripped binary is roughly the same, at 56MB.Expected behavior
Perhaps an increase of a few MB, I probably wouldn't even be bothered by an increase of 10-15MB.
Actual behavior
Shown above in "Steps to Reproduce", the resulting binary isn't just a little bit larger, but exponentially larger.
I will add below the results of running
bloaty
on both a fresh package with and withoutswift-argument-parser
added as a dependency.Without
swift-argument-parser
With
swift-argument-parser
Note:
These were both compiled with
swift build -c release --static-swift-stdlib
. Only difference is the dependency added toPackage.swift
I'd be willing to try any suggestions you have and report back with my results
The text was updated successfully, but these errors were encountered: