]> git.lizzy.rs Git - rust.git/commit
trans: Be a little more picky about dllimport
authorAlex Crichton <alex@alexcrichton.com>
Wed, 22 Jul 2015 00:31:35 +0000 (17:31 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 22 Jul 2015 04:31:25 +0000 (21:31 -0700)
commita0efd3a3d99a98e3399a4f07abe6a67cf0660335
treeb66737059440b271396609ecb1254350db1f4645
parentee2d3bc8a20545aa6bb660ae0e30ff143f160d16
trans: Be a little more picky about dllimport

Currently you can hit a link error on MSVC by only referencing static items from
a crate (no functions for example) and then link to the crate statically (as all
Rust crates do 99% of the time). A detailed investigation can be found [on
github][details], but the tl;dr is that we need to stop applying dllimport so
aggressively.

This commit alters the application of dllimport on constants to only cases where
the crate the constant originated from will be linked as a dylib in some output
crate type. That way if we're just linking rlibs (like the motivation for this
issue) we won't use dllimport. For the compiler, however, (which has lots of
dylibs) we'll use dllimport.

[details]: https://github.com/rust-lang/rust/issues/26591#issuecomment-123513631

cc #26591
src/librustc_trans/trans/base.rs
src/librustc_trans/trans/context.rs
src/test/auxiliary/xcrate-static.rs [new file with mode: 0644]
src/test/run-pass/xcrate-static.rs [new file with mode: 0644]