Open LER0ever opened 3 years ago
Hm, that's a strange one! If you're able to still reproduce the problem, some things you could try:
cargo build --all-targets --verbose
to make sure it is actually compiling the test (after saving the test file so it triggers a rebuild).cargo check
with the CARGO_INCREMENTAL
environment variable set to 0
. This will determine if it is maybe an incremental cache problem.target
directory and try both commands again.@ehuss Sure, I've saved a snapshot of the project that consistently reproduce the issue on multiple machines. I've attached a terminal log of me executing the following command in order:
$ cargo build --all-targets --verbose
$ CARGO_INCREMENTAL=0 cargo check --all-targets
$ rm -rf targets
$ cargo build --all-targets --verbose
$ CARGO_INCREMENTAL=0 cargo check --all-targets
build
command compiles all the tests, and completes without errorscheck
checks all of them as well, exits with 22 errorsHere is a file structure of my project, and my Cargo.toml, in case it helps:
Hm, yea, it looks like it is behaving as-if there are two copies of anyhow (the types are mismatching), as well as log
crate.
Would you mind clearing the target directory and posting the output of both cargo check --all-targets --verbose
and cargo build --all-targets --verbose
? I'd like to compare the exact flags given to the compiler.
Hi @ehuss , sorry for the late reply. The problem still persists, and here's my cargo check and build verbose log.
rm -rf target
cargo check --all-targets --verbose &> check.log
Log Pastebin: https://pastebin.ubuntu.com/p/b6TC9tX2Ct/
rm -rf target
cargo build --verbose &> build.log
cargo build --examples --no-default-features --verbose &>> build.log
cargo build --tests --no-default-features --verbose &>> build.log
Log Pastebin: https://pastebin.ubuntu.com/p/tXsnJfG9wF/
Here's a rustc command copied from each pastebin log above, both compiling the same test:
# Check
Running `rustc --crate-name test_dx_eir_io --edition=2018 tests/test_dx_eir_io.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,metadata -C embed-bitcode=no -C debuginfo=2 --test --cfg 'feature="default"' --cfg 'feature="extension-module"' -C metadata=752d9008c081a063 -C extra-filename=-752d9008c081a063 --out-dir /home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps -C incremental=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/incremental -L dependency=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps --extern ansi_term=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libansi_term-8ce5d0a29c873f5b.rmeta --extern anyhow=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libanyhow-bbfde8b292a6254c.rmeta --extern chrono=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libchrono-1548f9516ca6365c.rmeta --extern dashmap=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libdashmap-2724b6154e11ce47.rmeta --extern dyn_clonable=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libdyn_clonable-bbf5239723dc1217.rmeta --extern ebony=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libebony.rlib --extern ebony_macros=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libebony_macros-88f6fc692d4802c8.so --extern itertools=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libitertools-47140419371f3318.rmeta --extern kv_log_macro=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libkv_log_macro-4be0b8dc4a1c89c2.rmeta --extern log=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/liblog-96e73fa8caefdd45.rmeta --extern ordered_float=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libordered_float-e950cb78843605b6.rmeta --extern petgraph=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libpetgraph-2f288a90bbb87435.rmeta --extern prettytable=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libprettytable-26f1e55d5e9aa22f.rmeta --extern protobuf=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libprotobuf-1880b3260f839d05.rmeta --extern pyo3=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libpyo3-c662c5000744e374.rmeta --extern rayon=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/librayon-ca4e6fa1e1ad8d51.rmeta --extern serde=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde-2a31be97e4bca51f.rmeta --extern serde_cbor=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde_cbor-5977b1fba8c0642c.rmeta --extern serde_json=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde_json-1221e05f4483a350.rmeta --extern serde_with=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde_with-724522e3513120e0.rmeta --extern serde_yaml=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde_yaml-4177d9964ea96727.rmeta --extern stacker=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libstacker-f9d6e9d1388061a2.rmeta --extern structopt=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libstructopt-e4a244da1e9e9318.rmeta --extern tensorflow_rosenbridge=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libtensorflow_rosenbridge_emt_master-965fa9ff4917598e.rmeta --extern thiserror=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libthiserror-4727584834cbedf2.rmeta --extern typetag=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libtypetag-7be8c9d47980b810.rmeta --extern uuid=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libuuid-5e925cbdcac4dc1c.rmeta -L native=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/build/psm-f8e633fbc74b891a/out`
# Build
Running `rustc --crate-name test_dx_eir_io --edition=2018 tests/test_dx_eir_io.rs --error-format=json --json=diagnostic-rendered-ansi --emit=dep-info,link -C embed-bitcode=no -C debuginfo=2 --test -C metadata=b27d93528af4f66c -C extra-filename=-b27d93528af4f66c --out-dir /home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps -C incremental=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/incremental -L dependency=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps --extern ansi_term=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libansi_term-389f8788aa0acea0.rlib --extern anyhow=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libanyhow-af47ab8c672d4ea6.rlib --extern chrono=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libchrono-1daa02e0ee90b929.rlib --extern dashmap=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libdashmap-d2c92c8cffb8a81b.rlib --extern dyn_clonable=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libdyn_clonable-6ba1af9dd15a91ff.rlib --extern ebony=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libebony.rlib --extern ebony_macros=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libebony_macros-88f6fc692d4802c8.so --extern itertools=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libitertools-cd6259a4fce34e80.rlib --extern kv_log_macro=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libkv_log_macro-eb2df51715a7153d.rlib --extern log=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/liblog-257e9d8e6616ac0e.rlib --extern ordered_float=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libordered_float-1c61cd1f9187f71d.rlib --extern petgraph=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libpetgraph-199069e4dad294c5.rlib --extern prettytable=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libprettytable-989290056fde5985.rlib --extern protobuf=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libprotobuf-e43f80596f921d2e.rlib --extern pyo3=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libpyo3-cadce405ca06c6ba.rlib --extern rayon=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/librayon-f2495bae360fbaf4.rlib --extern serde=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde-4234845126fbd5b8.rlib --extern serde_cbor=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde_cbor-5e756bf3c1271543.rlib --extern serde_json=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde_json-8fff24548708018b.rlib --extern serde_with=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde_with-f9594084f4fdfad0.rlib --extern serde_yaml=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libserde_yaml-3d09f420b85a9378.rlib --extern stacker=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libstacker-11daf17aa1307882.rlib --extern structopt=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libstructopt-33f13edd63981811.rlib --extern tensorflow_rosenbridge=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libtensorflow_rosenbridge_emt_master-f45ecc3801cf8785.rlib --extern thiserror=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libthiserror-52d24f5f7b3608b6.rlib --extern typetag=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libtypetag-5f2a268330bd28df.rlib --extern uuid=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/deps/libuuid-67f303e397ed29d6.rlib -L native=/usr/lib -L native=/home/rongyi/Monorepo/work/bytedance/ebony/target/debug/build/psm-f8e633fbc74b891a/out`
FYI, I use --no-default-features
when building examples and tests mainly to workaround PyO3 (https://github.com/PyO3/pyo3/issues/340#issuecomment-461514532) and has nothing to do with this cargo check issue. Adding --no-default-features
to cargo check doesn't change anything.
Thanks for posting the extra information.
There's a piece of the puzzle I'm missing, and I can't quite fill in the blank. cargo check
is building the ebony binary 3 times, but I would only expect it twice. The third build is actually generating the cdylib/rlib (like a regular build), which doesn't make much sense. It should only do that if there is a build-dependency or proc-macro that depends on ebony itself. The tests then end up linking the rlib, which is built differently from all the other rmeta files. I suspect that it the source of the issue.
A few more questions:
rustc -Vv
should print it).rosenbridge/Cargo.toml
manifest? Or is it pretty basic? Same question for macros/Cargo.toml
, is that just a basic proc-macro?cargo +nightly check --all-targets --unit-graph -Z unstable-options
The third build is actually generating the cdylib/rlib (like a regular build), which doesn't make much sense.
It should only do that if there is a build-dependency or proc-macro that depends on ebony itself.
@ehuss Is it because I specified the crate type as crate-type = ["cdylib", "rlib"]
? In my case, nothing is depending on this project while building it.
What is the target you are building for (rustc -Vv should print it).
β
rustc -Vv
rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-unknown-linux-gnu
release: 1.51.0
LLVM version: 11.0.1
Is there anything unusual about the rosenbridge/Cargo.toml manifest? Or is it pretty basic? Same question for macros/Cargo.toml, is that just a basic proc-macro?
Not really. The first one is a rust-protobuf
generated binding to all the TensorFlow data structure, the second is just a proc-macro. Attaching both Cargo.toml below:
If you have the nightly toolchain available, can you save the output of
cargo +nightly check --all-targets --unit-graph -Z unstable-options
I do, but due to a rust-protobuf issue (https://github.com/stepancheg/rust-protobuf/issues/551), it currently does not build under nightly Rust.
I do, but due to a rust-protobuf issue (stepancheg/rust-protobuf#551), it currently does not build under nightly Rust.
The --unit-graph
flag doesn't actually build anything. It should just spit out a big JSON blob. That can help me understand the internal dependencies. I think it should work even if the code doesn't build.
The --unit-graph flag doesn't actually build anything. It should just spit out a big JSON blob.
Indeed, thanks for the clarification. I've attached the formatted json dump here: https://pastebin.ubuntu.com/p/phzqTqQZpw/
Unfortunately I am running out of ideas on what could cause this.
From what I can tell, checking the binaries, tests, and examples all decide that the library needs to be built instead of checked. The code for adding that is here. The key part is the call to check_or_build_mode
which decides if the library needs to be checked or built. That function will only build the library if the binary is being built (it's not), or if the library is "for_host". for_host
is only set in these situations:
Cargo.toml
has plugin=true
in [lib]
Cargo.toml
has proc-macro=true
in [lib]
Cargo.toml
has proc-macro
in the crate-type
list in [lib]
.None of those are true, so I am a bit baffled on how that function could think the library is being built for the host.
If you can create a reproduction that you can share, that would be helpful. Like, if you can take your project, remove all the code (just an empty lib.rs
and main.rs
with fn main() {}
), and if you run cargo check --all-targets --verbose
and you see rustc --crate-name ebony --edition=2018 src/lib.rs
show up three times (instead of twice), then that would be a positive reproduction.
Problem
Running
cargo build --all-targets
does NOT show any errors (not even a single warning), and all targets run fine. But runningcargo check --all-targets
gives out errors that should not exists, and exits prematurely witherror: could not compile xxx
. A detailed example is attached below.Steps
I haven't got the time to make a minimal reproducible case, but have a real project showcasing the error below.
Possible Solution(s)
Beyond my reach. But I would guess it's related to import resolution, in my case interpreting
Result
tostd::result::Result
instead of the importedanyhow::Result
.Notes
Output of
cargo version
:Screenshot of the issue
In the screenshot, the left pane of the integrated terminal is running
cargo check --all-targets
, and the right is runningcargo build --all-targets
. The build works fine butcargo check
gives out 22 errors which I'm sure are not valid errors after examination.Most errors say "the trait
std::error::Error
is not implemented foranyhow::Error
", which seems to me thatcargo check
thinks theResult
isstd::result::Result
, however all theResult
in this project isanyhow::Result
, so the error does not make sense.All the errors are reported by
cargo check
on test targetstests/*.rs
. Runningcargo build --tests
gives no error. Running the tests shows 100% pass. So it's likely a problem ofcargo check
.