Skip to content
  • Alex Crichton's avatar
    trans: Link rlibs to dylibs with --whole-archive · 9bc8e6d1
    Alex Crichton authored
    This commit starts passing the `--whole-archive` flag (`-force_load` on OSX) to
    the linker when linking rlibs into dylibs. The primary purpose of this commit is
    to ensure that the linker doesn't strip out objects from an archive when
    creating a dynamic library. Information on how this can go wrong can be found in
    issues #14344 and #25185.
    
    The unfortunate part about passing this flag to the linker is that we have to
    preprocess the rlib to remove the metadata and compressed bytecode found within.
    This means that creating a dylib will now take longer to link as we've got to
    copy around the input rlibs to a temporary location, modify them, and then
    invoke the linker. This isn't done for executables, however, so the "hello
    world" compile time is not affected.
    
    This fix was instigated because of the previous commit where rlibs may not
    contain multiple object files instead of one due to codegen units being greater
    than one. That change prevented the main distribution from being compiled with
    more than one codegen-unit and this commit fixes that.
    
    Closes #14344
    Closes #25185
    9bc8e6d1