]> git.lizzy.rs Git - rust.git/commit
rustc: Add `_imp_` symbols later in compilation
authorAlex Crichton <alex@alexcrichton.com>
Tue, 17 Oct 2017 20:08:13 +0000 (13:08 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 18 Oct 2017 14:01:29 +0000 (07:01 -0700)
commit3541ffb668c3b908aa5e3b6ba8a890d56a8360a7
treee6b61b7c8dedf19f3b4cdfa8ee7fcb6b0d8f518d
parent0be6863a15f5aacacb287ca490823ab3b7ceb302
rustc: Add `_imp_` symbols later in compilation

On MSVC targets rustc will add symbols prefixed with `_imp_` to LLVM modules to
"emulate" dllexported statics as that workaround is still in place after #27438
hasn't been solved otherwise. These statics, however, were getting gc'd by
ThinLTO accidentally which later would cause linking failures.

This commit updates the location we add such symbols to happen just before
codegen to ensure that (a) they're not eliminated by the optimizer and (b) the
optimizer doesn't even worry about them.

Closes #45347
src/librustc_trans/back/write.rs
src/librustc_trans/base.rs
src/test/run-pass/thinlto/auxiliary/msvc-imp-present.rs [new file with mode: 0644]
src/test/run-pass/thinlto/msvc-imp-present.rs [new file with mode: 0644]