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

prefer-dynamic has bad error messages when rlibs are available #12133

Closed
kvark opened this issue Feb 9, 2014 · 2 comments · Fixed by #12398
Closed

prefer-dynamic has bad error messages when rlibs are available #12133

kvark opened this issue Feb 9, 2014 · 2 comments · Fixed by #12398

Comments

@kvark
Copy link
Contributor

kvark commented Feb 9, 2014

Sometimes linking against 'rlib' ones fails. Latest repro case is:

git clone https://github.com/alexcrichton/rust-compress
cd rust-compress
rustc lib.rs
rustdoc -L. --test lib.rs

Last command output:

running 6 tests
error: could not find dynamic library for: `compress`
error: aborting due to previous error
task 'dc_0' failed at '~Any', /mnt/code/other/rust/src/libsyntax/diagnostic.rs:88
test dc_0 ... FAILED
error: could not find dynamic library for: `compress`
error: aborting due to previous error
task 'bwt_0' failed at '~Any', /mnt/code/other/rust/src/libsyntax/diagnostic.rs:88
test bwt_0 ... FAILED
error: could not find dynamic library for: `compress`
error: aborting due to previous error
task 'entropy::ari_0' failed at '~Any', /mnt/code/other/rust/src/libsyntax/diagnostic.rs:88
test entropy::ari_0 ... FAILED
error: could not find dynamic library for: `compress`
error: aborting due to previous error
task 'flate_0' failed at '~Any', /mnt/code/other/rust/src/libsyntax/diagnostic.rs:88
test flate_0 ... FAILED
error: could not find dynamic library for: `compress`
error: aborting due to previous error
task 'lz4_0' failed at '~Any', /mnt/code/other/rust/src/libsyntax/diagnostic.rs:88
test lz4_0 ... FAILED
error: could not find dynamic library for: `compress`
error: aborting due to previous error
task 'zlib_0' failed at '~Any', /mnt/code/other/rust/src/libsyntax/diagnostic.rs:88
test zlib_0 ... FAILED

failures:
    bwt_0
    dc_0
    entropy::ari_0
    flate_0
    lz4_0
    zlib_0

test result: FAILED. 0 passed; 6 failed; 0 ignored; 0 measured

Changing the crate_type from 'rlib' to 'dylib' solves it.

Environment:

rustc 0.10-pre (ed885e3 2014-02-05 03:16:35 -0800)
host: x86_64-unknown-linux-gnu
@alexcrichton
Copy link
Member

The underlying cause of this behavior is the prefer-dynamic flag to rustc. When rustdoc is compiling tests, it flags the prefer-dynamic option because the binaries generated have no need to be many megabytes in size.

When specified, the linking portion of the compiler will refuse to even look for rlibs if you specified that you wanted dynamic linking. The problem is that compress is an rlib and there's no dylib for it, so linking is failing as a dynamic version (as requested) can't be found for libcompress.

There are a few ways to go about this:

  1. Close as WONTFIX and leave the behavior as-is.
  2. Change prefer-dynamic to fall back on rlib linking. This may catch some people by surprise, but it would possibly fix the error.
  3. Leave the behavior as-is and implement better error messages suggesting what to do. The linking stage knows that there's an rlib available (it found it already) and it's mostly just ignoring that with respect to the error message.

I would personally vote for option 3, what do others think?

I'm also changing the title to reflect the prefer-dynamic bug here.

@kvark
Copy link
Contributor Author

kvark commented Feb 9, 2014

Thanks Alex. I see it in your Travis CI log now:
rustc --crate-type=dylib lib.rs
As for your ways to solve it, I'd be fine with either 2 or 3. However, prefer-dynamic flag suggests that it's just a preference, but not the only choice. If you want the behavior to remain the same (i.e. failing to link), you should probably rename it to use-dynamic or something.

bors added a commit that referenced this issue Feb 20, 2014
The new methodology can be found in the re-worded comment, but the gist of it is
that -C prefer-dynamic doesn't turn off static linkage. The error messages
should also be a little more sane now.

Closes #12133
bors added a commit to rust-lang-ci/rust that referenced this issue Jul 25, 2022
internal: Fix crate names for release
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

Successfully merging a pull request may close this issue.

2 participants