]> git.lizzy.rs Git - rust.git/commit
trans: Link rlibs to dylibs with --whole-archive
authorAlex Crichton <alex@alexcrichton.com>
Wed, 8 Jul 2015 04:33:44 +0000 (21:33 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 8 Jul 2015 22:24:23 +0000 (15:24 -0700)
commit9bc8e6d1472a57441afe3592078838d2bc767996
tree07bb476f368f42c89b476671ecc9082175d91b69
parentd23239b48e2066d3f38eb03e2429427bffade822
trans: Link rlibs to dylibs with --whole-archive

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
16 files changed:
src/liballoc/lib.rs
src/libcollections/lib.rs
src/liblibc/lib.rs
src/librustc/metadata/encoder.rs
src/librustc_driver/driver.rs
src/librustc_driver/lib.rs
src/librustc_trans/back/link.rs
src/librustc_trans/back/linker.rs
src/librustc_trans/back/lto.rs
src/test/auxiliary/issue-14344-1.rs [new file with mode: 0644]
src/test/auxiliary/issue-14344-2.rs [new file with mode: 0644]
src/test/auxiliary/issue-25185-1.rs [new file with mode: 0644]
src/test/auxiliary/issue-25185-2.rs [new file with mode: 0644]
src/test/run-make/extern-fn-reachable/Makefile
src/test/run-pass/issue-14344.rs [new file with mode: 0644]
src/test/run-pass/issue-25185.rs [new file with mode: 0644]