Skip to content
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

Store metadata separately in rlib files #10795

Closed
wants to merge 1 commit into from

Commits on Dec 4, 2013

  1. 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).
    alexcrichton committed Dec 4, 2013
    4 Configuration menu
    Copy the full SHA
    7c8bf23 View commit details
    Browse the repository at this point in the history