-
Notifications
You must be signed in to change notification settings - Fork 13.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store metadata separately in rlib files
Right now whenever an rlib file is linked against, all of the metadata from the rlib is pulled in to the final staticlib or binary. The reason for this is that the metadata is currently stored in a section of the object file. Note that this is intentional for dynamic libraries in order to distribute metadata bundled with static libraries. This commit alters the situation for rlib libraries to instead store the metadata in a separate file in the archive. In doing so, when the archive is passed to the linker, none of the metadata will get pulled into the result executable. Furthermore, the metadata file is skipped when assembling rlibs into an archive. The snag in this implementation comes with multiple output formats. When generating a dylib, the metadata needs to be in the object file, but when generating an rlib this needs to be separate. In order to accomplish this, the metadata variable is inserted into an entirely separate LLVM Module which is then codegen'd into a different location (foo.metadata.o). This is then linked into dynamic libraries and silently ignored for rlib files. While changing how metadata is inserted into archives, I have also stopped compressing metadata when inserted into rlib files. We have wanted to stop compressing metadata, but the sections it creates in object file sections are apparently too large. Thankfully if it's just an arbitrary file it doesn't matter how large it is. I have seen massive reductions in executable sizes, as well as staticlib output sizes (to confirm that this is all working).
- Loading branch information
1 parent
693ec73
commit 7c8bf23
Showing
7 changed files
with
156 additions
and
78 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
7c8bf23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
saw approval from pcwalton
at alexcrichton@7c8bf23
7c8bf23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
merging alexcrichton/rust/smaller-metadata = 7c8bf23 into auto
7c8bf23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alexcrichton/rust/smaller-metadata = 7c8bf23 merged ok, testing candidate = 495251bb
7c8bf23
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some tests failed:
failure: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-c/builds/1907
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-opt/builds/2799
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-c/builds/644
exception: http://buildbot.rust-lang.org/builders/auto-mac-32-nopt-t/builds/644
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-opt/builds/2803
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-c/builds/1909
exception: http://buildbot.rust-lang.org/builders/auto-mac-64-nopt-t/builds/1908
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-opt/builds/2815
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-c/builds/1907
exception: http://buildbot.rust-lang.org/builders/auto-linux-32-nopt-t/builds/1908
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-opt/builds/2817
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-nopt-t/builds/1907
exception: http://buildbot.rust-lang.org/builders/auto-linux-64-x-android/builds/1983
exception: http://buildbot.rust-lang.org/builders/auto-win-32-opt/builds/2804
exception: http://buildbot.rust-lang.org/builders/auto-bsd-64-opt/builds/2579