rust-skeptic icon indicating copy to clipboard operation
rust-skeptic copied to clipboard

Errors caused by "incompatible version of rustc"

Open asajeffrey opened this issue 8 years ago • 4 comments
trafficstars

Skeptic appears to be picking up the wrong version of a crate if rustc has changed but the source hasn't, for example https://travis-ci.org/asajeffrey/josephine#L2092-L2114

error[E0514]: found crate `josephine` compiled by an incompatible version of rustc
--> /tmp/rust-skeptic.SAsIuPpyeagm/test.rs:2:1
|
2 | extern crate josephine;
| ^^^^^^^^^^^^^^^^^^^^^^^
|
= help: please recompile that crate using this compiler (rustc 1.22.0-nightly (4c053db23 2017-10-22))
= note: crate `josephine` path #1: /home/travis/build/asajeffrey/josephine/target/debug/deps/libjosephine-336dea286aed8204.rlib compiled by "rustc 1.22.0-nightly (b633341c4 2017-10-20)"
error: aborting due to previous error
test readme_sect_examples_line_63 ... FAILED
failures:
---- readme_sect_examples_line_63 stdout ----
thread 'readme_sect_examples_line_63' panicked at 'Command failed:
"rustc" "/tmp/rust-skeptic.SAsIuPpyeagm/test.rs" "--verbose" "--crate-type=bin" "-L" "/home/travis/build/asajeffrey/josephine/target/debug" "-L" "/home/travis/build/asajeffrey/josephine/target/debug/deps" "--target" "x86_64-unknown-linux-gnu" "--extern" "log=/home/travis/build/asajeffrey/josephine/target/debug/deps/liblog-26b8b3080393a27c.rlib" "--extern" "skeptic=/home/travis/build/asajeffrey/josephine/target/debug/deps/libskeptic-d91e747230b57dfd.rlib" "--extern" "josephine=/home/travis/build/asajeffrey/josephine/target/debug/deps/libjosephine-336dea286aed8204.rlib" "--extern" "env_logger=/home/travis/build/asajeffrey/josephine/target/debug/deps/libenv_logger-f3b9160ea48e94eb.rlib" "--extern" "libc=/home/travis/build/asajeffrey/josephine/target/debug/deps/liblibc-c93596e46b3057df.rlib" "-o" "/tmp/rust-skeptic.SAsIuPpyeagm/out.exe"', /home/travis/.cargo/registry/src/github.com-1ecc6299db9ec823/skeptic-0.13.2/lib.rs:818:12
note: Run with `RUST_BACKTRACE=1` for a backtrace.
failures:
readme_sect_examples_line_63

asajeffrey avatar Oct 24 '17 17:10 asajeffrey

Same here

Freyskeyd avatar Nov 03 '17 08:11 Freyskeyd

Thanks! I'll look into it

budziq avatar Nov 04 '17 23:11 budziq

As described by OP this problem arises when we have dependency that has not changed on crates.io and was built locally with more than one version of the compiler (ie. switch from nightly to stable, release of new stable, etc.).

The heuristics for selecting the rlib/so/dylib/dll to link are as follows:

  • find crates directly listed as deps in cargo.lock
  • filter known rlib/so/dylib/dll to the locked deps and appropriate versions
  • chose the file with latest mtime from each duplicate candidate list

This works quite well in case of dynamic deps (libs changing locally without version bump) and static compiler setup it breaks apart if we change the compiler (we have >1 rlib for given crate, all with identical versions and the latest one is for wrong compiler - rlibs don't get rebuilt by cargo if matching version already exists).

Sadly I see no clear solution, each one of the below seams not acceptable:

  • reimplementing even more cargo logic - some of it tightly coupled to unstable rustc internals
  • analyzing each crate file for for compiler version string. - The information exists there at least for rlib's and so's but I'm not sure if we can get it in portable manner (dll's and dylib's) this would be brittle at best and would significantly slow down the testing phase. Unfortunately the rustc version string in .fingerprint dir metadata is mangled and not usable with rustc_version crate.
  • fabricate the tests to be built and run by cargo - original POC from some time ago shows that this slows down testing phase to a crawl and we loose the nice distinction between compile only / no_run and normal tests.
  • wait for cargo build-plans feature

TL;NR I'll need to think about it some more :/

budziq avatar Nov 05 '17 01:11 budziq

Hmm one hotfix that seams to work on POC level is to actually invoke rustc for candidate deps and check if it spews incompatible version error. Of course this slows the testing to a crawl ATM but with some skeptic internals rewriting it might give a workable short term solution.

We would have to move the candidate dep/fingerprint handling from rt part (run on each test) to an upfront cached state that would be serialized into the prefabricated doctests text.

This will most likely need to wait for the semi-major rewrite of skeptic I'm planning including the usage of macros 1.1 https://github.com/budziq/rust-skeptic/issues/60.

budziq avatar Nov 05 '17 03:11 budziq