Skip to content

Doc test link failure with native dependencies #1469

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

Closed
dcuddeback opened this issue Mar 29, 2015 · 1 comment
Closed

Doc test link failure with native dependencies #1469

dcuddeback opened this issue Mar 29, 2015 · 1 comment

Comments

@dcuddeback
Copy link

This is reopening #1401. Github doesn't give me the option of reopening the same issue, so I'm creating a new one. I reproduced the issue with the latest Cargo nightly. Here's the output of my test command:

$ cargo clean && cargo test --verbose
   Compiling bug v0.0.1 (file:///Users/david/src/rust-link-bug)
     Running `rustc build.rs --crate-name build_script_build --crate-type bin -C prefer-dynamic -g --out-dir /Users/david/src/rust-link-bug/target/debug/build/bug-7d595e9c49b14df7 --emit=dep-info,link -L dependency=/Users/david/src/rust-link-bug/target/debug -L dependency=/Users/david/src/rust-link-bug/target/debug/deps`
     Running `/Users/david/src/rust-link-bug/target/debug/build/bug-7d595e9c49b14df7/build-script-build`
     Running `rustc src/lib.rs --crate-name bug --crate-type lib -g -C metadata=7d595e9c49b14df7 -C extra-filename=-7d595e9c49b14df7 --out-dir /Users/david/src/rust-link-bug/target/debug --emit=dep-info,link -L dependency=/Users/david/src/rust-link-bug/target/debug -L dependency=/Users/david/src/rust-link-bug/target/debug/deps -L native=/usr/local/Cellar/libusb/1.0.19/lib -l usb-1.0`
     Running `rustc src/lib.rs --crate-name bug --crate-type lib -g --test -C metadata=df6636dbde15889d -C extra-filename=-df6636dbde15889d --out-dir /Users/david/src/rust-link-bug/target/debug --emit=dep-info,link -L dependency=/Users/david/src/rust-link-bug/target/debug -L dependency=/Users/david/src/rust-link-bug/target/debug/deps -L native=/usr/local/Cellar/libusb/1.0.19/lib -l usb-1.0`
     Running `/Users/david/src/rust-link-bug/target/debug/bug-df6636dbde15889d`

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured

   Doc-tests bug
     Running `rustdoc --test /Users/david/src/rust-link-bug/src/lib.rs --crate-name bug -L /Users/david/src/rust-link-bug/target/debug -L /Users/david/src/rust-link-bug/target/debug/deps --extern bug=/Users/david/src/rust-link-bug/target/debug/libbug-7d595e9c49b14df7.rlib`

running 1 test
test hello_0 ... FAILED

failures:

---- hello_0 stdout ----
    error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/var/folders/7f/z9y9c0gj52gb38jlrsr2pzkc0000gn/T/rustdoctest.e2lupTv465I8/rust_out" "/var/folders/7f/z9y9c0gj52gb38jlrsr2pzkc0000gn/T/rustdoctest.e2lupTv465I8/rust_out.o" "-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a" "-Wl,-dead_strip" "-nodefaultlibs" "/Users/david/src/rust-link-bug/target/debug/libbug-7d595e9c49b14df7.rlib" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-lstd-4e7c5e5c" "-L" "/Users/david/src/rust-link-bug/target/debug" "-L" "/Users/david/src/rust-link-bug/target/debug/deps" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/david/src/rust-link-bug/.rust/lib/x86_64-apple-darwin" "-L" "/Users/david/src/rust-link-bug/lib/x86_64-apple-darwin" "-lusb-1.0" "-lSystem" "-lpthread" "-lc" "-lm" "-lcompiler-rt"
note: ld: warning: directory not found for option '-L/Users/david/src/rust-link-bug/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/david/src/rust-link-bug/lib/x86_64-apple-darwin'
ld: library not found for -lusb-1.0
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
thread 'hello_0' panicked at 'Box<Any>', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libsyntax/diagnostic.rs:152



failures:
    hello_0

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

thread '<unnamed>' panicked at 'Some tests failed', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libtest/lib.rs:261
thread '<main>' panicked at 'child thread None panicked', /Users/rustbuild/src/rust-buildbot/slave/nightly-dist-rustc-mac/build/src/libstd/thread/mod.rs:775

I notice that the two rustc commands both receive the link flags (-L native=/usr/local/Cellar/libusb/1.0.19/lib -l usb-1.0), but the rustdoc command does not. Running the rustdoc command manually with the -L flag works:

$ rustdoc --test /Users/david/src/rust-link-bug/src/lib.rs --crate-name bug -L /Users/david/src/rust-link-bug/target/debug -L /Users/david/src/rust-link-bug/target/debug/deps --extern bug=/Users/david/src/rust-link-bug/target/debug/libbug-7d595e9c49b14df7.rlib -L native=/usr/local/Cellar/libusb/1.0.19/lib

running 1 test
test hello_0 ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured

I also tried with Cargo built from the latest master branch, just to make sure I had the fixes from #1441.

@alexcrichton
Copy link
Member

Fixed in #1530 (purportedly). Feel free to comment if it still reproduces though!

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

2 participants