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

A linkage error when running tests relying on a sys crate #3200

Closed
IvanUkhov opened this issue Oct 15, 2016 · 4 comments · Fixed by #3205
Closed

A linkage error when running tests relying on a sys crate #3200

IvanUkhov opened this issue Oct 15, 2016 · 4 comments · Fixed by #3205

Comments

@IvanUkhov
Copy link
Contributor

IvanUkhov commented Oct 15, 2016

There is a crate that depend on a sys crate. The crate has documentation tests and benchmarks. The tests used to compile and pass on nightly a couple of days back, but they fail to do so right now. The benchmarks work just fine in both cases. The error is due to linkage:

dyld: Library not loaded: @rpath/libfoo.dylib
  Referenced from: /var/folders/_c/vpdds93d4h1_bqdypvl5jqd40000gn/T/rustdoctest.V4bH22QTQP0U/rust_out
  Reason: image not found
', ../src/librustdoc/test.rs:323

The versions of Rust and Cargo that don’t have this issue are as follows:

rustc 1.14.0-nightly (a3bc191b5 2016-10-10)
cargo 0.13.0-nightly (957a47b 2016-10-10)

The versions of Rust and Cargo that have this issue are as follows:

rustc 1.14.0-nightly (098d22845 2016-10-13)
cargo 0.13.0-nightly (5f2cc15 2016-10-13)

Here is how it looks on Travis CI: before and after.

I’m wondering if it’s indeed due to the latest changes in Rust and/or Cargo, or it’s a problem with the crate itself. Let me know if the rust repository is a better fit for this issue. Thank you.

Regards,
Ivan

@alexcrichton
Copy link
Member

Hm two relevant PRs could be #3193 or #3198. Intended to be refactorings but may have been buggy, I'll take another look.

@alexcrichton
Copy link
Member

@matklad it looks like the dylib path var stuff in #3198 changed in some of the refactoring, I think maybe that's what caused this?

@matklad
Copy link
Member

matklad commented Oct 17, 2016

Yep, looks like it. Will investigate.

rustdoc gets different flags:

Before:

Running `rustdoc --test /home/user/projects/blas/src/lib.rs --crate-name blas
-L dependency=/home/user/projects/blas/target/debug/deps
-L dependency=/home/user/projects/blas/target/debug
-L /home/user/projects/blas/target/debug/build/openblas-src-243dacb5e0bf19bc/out/opt/OpenBLAS/lib
--cfg feature=\"blas-sys\" --cfg feature=\"default\" --cfg feature=\"openblas\" --extern num_complex=/home/user/projects/blas/target/debug/deps/libnum_complex-704ef091ce88b7b2.rlib --extern blas_sys=/home/user/projects/blas/target/debug/deps/libblas_sys-c7db4cd665708a15.rlib --extern blas=/home/user/projects/blas/target/debug/libblas.rlib --extern libc=/home/user/projects/blas/target/debug/deps/liblibc-ad32fde1bd850538.rlib`

After:

Running `rustdoc --test /home/user/projects/blas/src/lib.rs --crate-name blas
-L dependency=/home/user/projects/blas/target/debug/deps
-L /home/user/projects/blas/target/debug/build/openblas-src-243dacb5e0bf19bc/out/opt/OpenBLAS/lib
--cfg feature=\"openblas\" --cfg feature=\"default\" --cfg feature=\"blas-sys\" --extern num_complex=/home/user/projects/blas/target/debug/deps/libnum_complex-704ef091ce88b7b2.rlib --extern blas_sys=/home/user/projects/blas/target/debug/deps/libblas_sys-c7db4cd665708a15.rlib --extern libc=/home/user/projects/blas/target/debug/deps/liblibc-ad32fde1bd850538.rlib --extern blas=/home/user/projects/blas/target/debug/deps/libblas.rlib`

@IvanUkhov
Copy link
Contributor Author

@matklad, thanks for the help! Please note also that the job in question had a custom feature enabled, not the default one:

cargo test -vv --no-default-features --features=netlib

By default, it’s openblas, not netlib.

bors added a commit that referenced this issue Oct 17, 2016
Pass target environment for rustdoc

This should fix #3200, but I am not sure that this is a correct fix, and I need some input to figure this out.

`rustdoc` is invoked in two places, in `cargo_test.rs` and in `cargo_rustc/mod.rs`. Before the refactoring PR, these invocations used different LD_LIBRARY paths. [The one in cargo_rustc](https://github.com/rust-lang/cargo/pull/3198/files#diff-59acd1a3101aebbb591ac7ab51c19d9eR427) used "host" version, while [the one in cargo_test](https://github.com/rust-lang/cargo/blob/a8baa5b8f36e88170c8c56523b6eb72efc2cc55e/src/cargo/ops/cargo_test.rs#L131) used "target" version.

The original PR changed both to "host", this PR switches both to "target". Is this correct, or should we stick with different environments for building documentation and doctests?
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.

3 participants