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

multiple rlib candidates passed to rustdoc #5650

Closed
cuviper opened this issue Jun 25, 2018 · 1 comment · Fixed by #5651
Closed

multiple rlib candidates passed to rustdoc #5650

cuviper opened this issue Jun 25, 2018 · 1 comment · Fixed by #5651
Labels
C-bug Category: bug

Comments

@cuviper
Copy link
Member

cuviper commented Jun 25, 2018

Starting with Rust 1.27, we're seeing duplicate rlibs passed to rustdoc for the miniz_oxide_c_api crate.
https://kojipkgs.fedoraproject.org/work/tasks/1896/27791896/build.log

Rust 1.26 was fine, and I can reproduce the issue up through nightly.

$ cargo +nightly -Vv
cargo 1.28.0-nightly (e2348c2db 2018-06-07)
release: 1.28.0
commit-hash: e2348c2db296ce33428933c3ab8786d5f3c54a2e
commit-date: 2018-06-07
$ rustc +nightly -Vv
rustc 1.28.0-nightly (01cc982e9 2018-06-24)
binary: rustc
commit-hash: 01cc982e936120acb0424e41de14e42ba2d88c6f
commit-date: 2018-06-24
host: x86_64-unknown-linux-gnu
release: 1.28.0-nightly
LLVM version: 6.0

It's easy to reproduce by checking out https://github.com/Frommi/miniz_oxide, for the current master at commit 10c070c61b2d412358196db1e83f48f3b7422d7e.

$ cargo +nightly build --release --verbose
   Compiling build_const v0.2.1
   Compiling cc v1.0.17
   Compiling libc v0.2.42
   Compiling adler32 v1.0.3
     Running `rustc --crate-name build_const /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/build_const-0.2.1/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=237bc424c8fc27b7 -C extra-filename=-237bc424c8fc27b7 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cap-lints allow`
     Running `rustc --crate-name libc /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.42/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort --cfg 'feature="default"' --cfg 'feature="use_std"' -C metadata=583e369a8ae79b43 -C extra-filename=-583e369a8ae79b43 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cap-lints allow`
     Running `rustc --crate-name adler32 /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/adler32-1.0.3/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C metadata=6582e487cd20c9f9 -C extra-filename=-6582e487cd20c9f9 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cap-lints allow`
     Running `rustc --crate-name cc /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/cc-1.0.17/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=8386dfd55958a0e1 -C extra-filename=-8386dfd55958a0e1 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cap-lints allow`
   Compiling crc v1.8.1
     Running `rustc --crate-name build_script_build /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/crc-1.8.1/build.rs --crate-type bin --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=9eec806c9cb2cdca -C extra-filename=-9eec806c9cb2cdca --out-dir /home/jistone/rust/miniz_oxide/target/release/build/crc-9eec806c9cb2cdca -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --extern build_const=/home/jistone/rust/miniz_oxide/target/release/deps/libbuild_const-237bc424c8fc27b7.rlib --cap-lints allow`
     Running `/home/jistone/rust/miniz_oxide/target/release/build/crc-9eec806c9cb2cdca/build-script-build`
     Running `rustc --crate-name crc /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/crc-1.8.1/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=db9c267dd054f996 -C extra-filename=-db9c267dd054f996 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cap-lints allow`
   Compiling miniz_oxide v0.1.3 (file:///home/jistone/rust/miniz_oxide/miniz_oxide)
     Running `rustc --crate-name miniz_oxide miniz_oxide/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort -C metadata=da63d85bc3dac2b9 -C extra-filename=-da63d85bc3dac2b9 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --extern adler32=/home/jistone/rust/miniz_oxide/target/release/deps/libadler32-6582e487cd20c9f9.rlib --extern libc=/home/jistone/rust/miniz_oxide/target/release/deps/liblibc-583e369a8ae79b43.rlib`
   Compiling miniz_oxide_c_api v0.1.3 (file:///home/jistone/rust/miniz_oxide)
     Running `rustc --crate-name build_script_build src/build.rs --crate-type bin --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' -C metadata=8cb98112f97a7701 -C extra-filename=-8cb98112f97a7701 --out-dir /home/jistone/rust/miniz_oxide/target/release/build/miniz_oxide_c_api-8cb98112f97a7701 -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --extern cc=/home/jistone/rust/miniz_oxide/target/release/deps/libcc-8386dfd55958a0e1.rlib`
     Running `/home/jistone/rust/miniz_oxide/target/release/build/miniz_oxide_c_api-8cb98112f97a7701/build-script-build`
     Running `rustc --crate-name miniz_oxide_c_api src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C panic=abort --cfg 'feature="default"' -C metadata=c8ec649d83efdc32 -C extra-filename=-c8ec649d83efdc32 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --extern crc=/home/jistone/rust/miniz_oxide/target/release/deps/libcrc-db9c267dd054f996.rlib --extern libc=/home/jistone/rust/miniz_oxide/target/release/deps/liblibc-583e369a8ae79b43.rlib --extern miniz_oxide=/home/jistone/rust/miniz_oxide/target/release/deps/libminiz_oxide-da63d85bc3dac2b9.rlib`
    Finished release [optimized] target(s) in 3.32s

$ cargo +nightly test --release --verbose
       Fresh build_const v0.2.1
       Fresh cc v1.0.17
   Compiling libc v0.2.42
   Compiling adler32 v1.0.3
   Compiling crc v1.8.1
     Running `rustc --crate-name adler32 /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/adler32-1.0.3/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=995d235a15de691d -C extra-filename=-995d235a15de691d --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cap-lints allow`
   Compiling miniz_oxide_c_api v0.1.3 (file:///home/jistone/rust/miniz_oxide)
     Running `rustc --crate-name libc /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.42/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' --cfg 'feature="use_std"' -C metadata=6e0a133a0f1a257e -C extra-filename=-6e0a133a0f1a257e --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cap-lints allow`
     Running `rustc --crate-name crc /home/jistone/.cargo/registry/src/github.com-1ecc6299db9ec823/crc-1.8.1/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' --cfg 'feature="std"' -C metadata=0a0ba9a6b5735bbc -C extra-filename=-0a0ba9a6b5735bbc --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cap-lints allow`
     Running `rustc --crate-name miniz_oxide_c_api src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 --cfg 'feature="default"' -C metadata=829895175cd8b7e5 -C extra-filename=-829895175cd8b7e5 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --extern crc=/home/jistone/rust/miniz_oxide/target/release/deps/libcrc-db9c267dd054f996.rlib --extern libc=/home/jistone/rust/miniz_oxide/target/release/deps/liblibc-583e369a8ae79b43.rlib --extern miniz_oxide=/home/jistone/rust/miniz_oxide/target/release/deps/libminiz_oxide-da63d85bc3dac2b9.rlib`
   Compiling miniz_oxide v0.1.3 (file:///home/jistone/rust/miniz_oxide/miniz_oxide)
     Running `rustc --crate-name miniz_oxide miniz_oxide/src/lib.rs --crate-type lib --emit=dep-info,link -C opt-level=3 -C metadata=8736d1ee18e2a046 -C extra-filename=-8736d1ee18e2a046 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --extern adler32=/home/jistone/rust/miniz_oxide/target/release/deps/libadler32-995d235a15de691d.rlib --extern libc=/home/jistone/rust/miniz_oxide/target/release/deps/liblibc-6e0a133a0f1a257e.rlib`
     Running `rustc --crate-name test tests/test.rs --emit=dep-info,link -C opt-level=3 --test --cfg 'feature="default"' -C metadata=69128140fba22fe4 -C extra-filename=-69128140fba22fe4 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --extern crc=/home/jistone/rust/miniz_oxide/target/release/deps/libcrc-0a0ba9a6b5735bbc.rlib --extern libc=/home/jistone/rust/miniz_oxide/target/release/deps/liblibc-6e0a133a0f1a257e.rlib --extern miniz_oxide=/home/jistone/rust/miniz_oxide/target/release/deps/libminiz_oxide-8736d1ee18e2a046.rlib --extern miniz_oxide_c_api=/home/jistone/rust/miniz_oxide/target/release/deps/libminiz_oxide_c_api-829895175cd8b7e5.rlib`
     Running `rustc --crate-name miniz_oxide_c_api src/lib.rs --emit=dep-info,link -C opt-level=3 --test --cfg 'feature="default"' -C metadata=4e2159d4b5622e18 -C extra-filename=-4e2159d4b5622e18 --out-dir /home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --extern crc=/home/jistone/rust/miniz_oxide/target/release/deps/libcrc-0a0ba9a6b5735bbc.rlib --extern libc=/home/jistone/rust/miniz_oxide/target/release/deps/liblibc-6e0a133a0f1a257e.rlib --extern miniz_oxide=/home/jistone/rust/miniz_oxide/target/release/deps/libminiz_oxide-8736d1ee18e2a046.rlib`
    Finished release [optimized] target(s) in 2.36s
     Running `/home/jistone/rust/miniz_oxide/target/release/deps/miniz_oxide_c_api-4e2159d4b5622e18`

running 3 tests
test tinfl::test::mem_to_heap ... ok
test tinfl::test::mem_to_mem ... ok
test tdef::test::mem_to_heap ... ok

test result: ok. 3 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

     Running `/home/jistone/rust/miniz_oxide/target/release/deps/test-69128140fba22fe4`

running 2 tests
test roundtrip_level_1 ... ok
test roundtrip ... ok

test result: ok. 2 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

   Doc-tests miniz_oxide_c_api
     Running `rustdoc --test /home/jistone/rust/miniz_oxide/src/lib.rs --crate-name miniz_oxide_c_api -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps -L dependency=/home/jistone/rust/miniz_oxide/target/release/deps --cfg 'feature="default"' --extern crc=/home/jistone/rust/miniz_oxide/target/release/deps/libcrc-0a0ba9a6b5735bbc.rlib --extern libc=/home/jistone/rust/miniz_oxide/target/release/deps/liblibc-583e369a8ae79b43.rlib --extern miniz_oxide_c_api=/home/jistone/rust/miniz_oxide/target/release/deps/libminiz_oxide_c_api-829895175cd8b7e5.rlib --extern miniz_oxide=/home/jistone/rust/miniz_oxide/target/release/deps/libminiz_oxide-da63d85bc3dac2b9.rlib --extern libc=/home/jistone/rust/miniz_oxide/target/release/deps/liblibc-6e0a133a0f1a257e.rlib --extern miniz_oxide=/home/jistone/rust/miniz_oxide/target/release/deps/libminiz_oxide-8736d1ee18e2a046.rlib --extern crc=/home/jistone/rust/miniz_oxide/target/release/deps/libcrc-db9c267dd054f996.rlib`
error[E0465]: multiple rlib candidates for `crc` found
 --> /home/jistone/rust/miniz_oxide/src/lib.rs:1:1
  |
1 | extern crate crc;
  | ^^^^^^^^^^^^^^^^^
  |
note: candidate #1: /home/jistone/rust/miniz_oxide/target/release/deps/libcrc-0a0ba9a6b5735bbc.rlib
 --> /home/jistone/rust/miniz_oxide/src/lib.rs:1:1
  |
1 | extern crate crc;
  | ^^^^^^^^^^^^^^^^^
note: candidate #2: /home/jistone/rust/miniz_oxide/target/release/deps/libcrc-db9c267dd054f996.rlib
 --> /home/jistone/rust/miniz_oxide/src/lib.rs:1:1
  |
1 | extern crate crc;
  | ^^^^^^^^^^^^^^^^^

error[E0463]: can't find crate for `crc`
 --> /home/jistone/rust/miniz_oxide/src/lib.rs:1:1
  |
1 | extern crate crc;
  | ^^^^^^^^^^^^^^^^^ can't find crate

error: test failed, to rerun pass '--doc'

This does not happen with plain cargo test. We generally use cargo test --release in Fedora rpm builds to try and test the same artifacts produced in the rpm %build step, but it looks like panic = "abort" is throwing a wrench in things.

@ehuss
Copy link
Contributor

ehuss commented Jun 25, 2018

Sorry about that, there is a test specifically for this case, but it didn't quite catch this particular issue (it's a complex interaction between having build scripts, dependencies, and using panic). There are multiple bugs here, and I'm trying to think of the best approach. I'll see if I can come up with something.

ehuss added a commit to ehuss/cargo that referenced this issue Jun 26, 2018
Fixes rust-lang#5650.  cc rust-lang#5435

As part of my recent work on profiles, I introduced some situations where a
library can be compiled multiple times with different settings.  Doctests were
greedily grabbing all dependencies for a package, regardless of which target
is was for.  This can cause doctests to fail if it links multiple copies of
the same library.

One way to trigger this is `cargo test --release` if you have dependencies, a
build script, and `panic="abort"`.  There are other (more obscure) ways to
trigger it with profile overrides.
@matklad matklad added the C-bug Category: bug label Jun 26, 2018
bors added a commit that referenced this issue Jul 5, 2018
Fix doctests linking too many libs.

Fixes #5650.  cc #5435

As part of my recent work on profiles, I introduced some situations where a
library can be compiled multiple times with different settings.  Doctests were
greedily grabbing all dependencies for a package, regardless of which target
is was for.  This can cause doctests to fail if it links multiple copies of
the same library.

One way to trigger this is `cargo test --release` if you have dependencies, a
build script, and `panic="abort"`.  There are other (more obscure) ways to
trigger it with profile overrides.
@bors bors closed this as completed in #5651 Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants