-
Notifications
You must be signed in to change notification settings - Fork 13k
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
impls containing static defined in private modules cause linking errors #20201
Comments
Additionally, inlining rawmessage.rs into message.rs will introduce new linker erorrs:
|
Closing as a dupe of #16734, but if you can get a minimized example that's different, feel free to reopen! |
@alexcrichton It seems I have no button to repoen. This minimal case is pretty different, since I could reduce it enough to cause it even without the use of ⊥ type: lib.rs: #![crate_name="repr"]
#![crate_type="rlib"]
pub use link::Link;
mod link {
use error::Error;
pub struct Link;
impl Link {
pub fn error(&self) -> Error { Error }
}
}
mod error {
use std::default::Default;
pub struct Error;
impl Error {
pub fn produce<T : Default>(self) -> (T, uint) {
static LINK_ERROR : uint = 0u;
(Default::default(), LINK_ERROR)
}
}
} main.rs: extern crate repr;
use repr::Link;
fn main() {
let link_error : (uint, uint) = Link.error().produce();
} $ bash -c 'rustc lib.rs && rustc main.rs -L.'
…
note: main.o: In function `error::Error::produce::h13795623746139935984':
main.0.rs:(.text._ZN5error5Error7produce21h13795623746139935984E+0x3d): undefined reference to `error::Error::produce::LINK_ERROR::h6790b04a8ae1707fTaa'
collect2: error: ld returned 1 exit status I hypothesise, that this is caused by module visibility issues (note: only the This gist contains a “non-prettified” (i.e. before I renamed |
That example is actually a dupe of #16734 in that the reachability pass isn't quite doing as much as it should. The type Once a generic method is used we always monomorphize across crates, which is why the error goes away. Regardless though, I'm going to close this as a dupe again of #16734, but thanks for the minimized example! |
I see. Thanks for the explanation. |
Yesterday on IRC @kmcguire3413 asked about interesting link issue which stems from the use of
panic!
macro. Sadly we couldn’t quite pinpoint the exact issue or produce more minimal test case than a full repository of code.The repository in question is water.rs. When debugging be sure to use this exact commit linked by previous link since the next commit introduces a workaroud. Steps to reproduce:
Now the funny thing is, that the symbol exists in the rlib, that’s linked to the test (though it’s type should probably be
D
, rather thand
):Commenting the panic or call to the relevant function fixes the issue as well as moving SyncMessage implementation to a different file.
The text was updated successfully, but these errors were encountered: