Skip to content
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

Internal Compiler Error after setting flag "-L/usr/local/lib" #11195

Closed
dwrensha opened this issue Dec 29, 2013 · 4 comments
Closed

Internal Compiler Error after setting flag "-L/usr/local/lib" #11195

dwrensha opened this issue Dec 29, 2013 · 4 comments

Comments

@dwrensha
Copy link
Contributor

I observe this error on Mac OSX 10.9.

// test.rs
fn main() {}
$ rustc -L/usr/local/lib test.rs
task 'rustc' failed at 'assertion failed: lib.dylib.is_none()', rust/src/librustc/metadata/loader.rs:211
error: internal compiler error: unexpected failure
This message reflects a bug in the Rust compiler. 
We would appreciate a bug report: https://github.com/mozilla/rust/wiki/HOWTO-submit-a-Rust-bug-report
note: the compiler hit an unexpected failure path. this is a bug
note: try running with RUST_LOG=rustc=1 to get further details and report the results to github.com/mozilla/rust/issues
task '<main>' failed at 'explicit failure', 
rust/src/librustc/lib.rs:441

Note that /usr/local/lib is the installation directory for Rust.

I ran into this error when I was trying to built rust-zmq, which requires linking against zmq.dylib, which is also installed in /usr/local/lib.

@alexcrichton
Copy link
Member

The sequence of events that would lead to this error are:

  1. An rlib for library X is found
  2. The corresponding dylib for library X is found
  3. The corresponding dylib for library X is found again (listed in the search paths twice?)

Right now this is an assertion that I used when debugging the introduction of rlibs, but I don't think that it's ok to override that assertion. If you've got /usr/local/lib as the installation directory for rust, then this is probably picking up the libstd that is used by rustc itself, and not the target libstd which you're supposed to be linking against.

All in all, this is correctly an error today, although This should certainly not actually be an error. We advertise rust as being installable to /usr/local/lib, (or /usr/lib), and it looks like that doesn't quite work. This would need a resolution of #11145 to make further progress on this issue.

In the meantime, I would sadly recommend installing rustc itself not to /usr/local/lib, but you can continue to install all other rust libraries to /usr/local/lib.

@SiegeLord
Copy link
Contributor

then this is probably picking up the libstd that is used by rustc itself, and not the target libstd which you're supposed to be linking against.

Why can't rustc be statically compiled?

@lilyball
Copy link
Contributor

lilyball commented Jun 4, 2014

This no longer ICEs. Instead it complains about multiple matching libraries.

> rustc -L/usr/local/lib test.rs
test.rs:1:1: 1:1 error: multiple dylib candidates for `std` found
test.rs:1 fn main() {}
          ^
test.rs:1:1: 1:1 note: candidate #1: /usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-59beb4f7-0.11.0-pre.dylib
test.rs:1 fn main() {}
          ^
test.rs:1:1: 1:1 note: candidate #2: /usr/local/lib/libstd-59beb4f7-0.11.0-pre.dylib
test.rs:1 fn main() {}
          ^
test.rs:1:1: 1:1 error: multiple dylib candidates for `libc` found
test.rs:1 fn main() {}
          ^
test.rs:1:1: 1:1 note: candidate #1: /usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4f9a876d-0.11.0-pre.dylib
test.rs:1 fn main() {}
          ^
test.rs:1:1: 1:1 note: candidate #2: /usr/local/lib/liblibc-4f9a876d-0.11.0-pre.dylib
test.rs:1 fn main() {}
          ^
error: aborting due to 2 previous errors

lilyball added a commit to lilyball/rust that referenced this issue Jun 4, 2014
When multiple candidates for a library are found, if one (and only one)
candidate lives in the target library path, prioritize that one. This
allows `rustc -L /usr/local/lib lib.rs` to compile successfully, whereas
today it complains about multiple candidates for e.g. libstd.

Fixes rust-lang#13733, rust-lang#11195.
@steveklabnik steveklabnik added the I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ label Sep 22, 2014
@steveklabnik steveklabnik added A-build and removed I-ICE Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️ labels Jan 16, 2015
@steveklabnik
Copy link
Member

Today, this gives me no error. Closing.

flip1995 pushed a commit to flip1995/rust that referenced this issue Jul 31, 2023
…d, r=Manishearth

fix: false positive for `option_env!` in `ifs_same_cond`

Clippy had a false positive for with `ifs_same_cond` when two if-let expressions have an `option_env!` macro. The fix is similar to the `env!` macro fix.

The following example had a clippy error:

```rust
if let Some(env1) = option_env!("ENV1") {
    // ...
} else if let Some(env2) = option_env!("ENV2") {
    // ...
}
```

See https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=01b85c61b56ddd900117fb247af04824

changelog: [`ifs_same_cond`]: fix false positive when using `option_env!` in if-let expressions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants