Cargo cache: why different triple use the same cache?

I program for Raspberry Pi, but want to run some test localy on my PC.
So I use x86_64-unknown-linux-gnu and armv7-unknown-linux-gnueabihf,
and for some unknown reason them use the same cache.

Why???

cargo new --bin myapp
cargo add rppal
cargo add env_logger
cargo add log
cargo add libc

Now I have something like:

[dependencies]
rppal = "0.11.3"
env_logger = "0.7.1"
log = "0.4.1"
libc = "0.2.62"

in my Cargo.toml

after that I start

cargo check and cargo check --target=armv7-unknown-linux-gnueabihf.

cargo's caching works if I run consecutively cargo check or the same with only "--target=armv7-unknown-linux-gnueabihf", but if I mix with --target=armv7-unknown-linux-gnueabihf and without --target=armv7-unknown-linux-gnueabihf,
I see rebuild of several dependicies:

$ cargo check
   Compiling memchr v2.3.0
   Compiling libc v0.2.66
   Compiling log v0.4.8
    Checking aho-corasick v0.7.6
    Checking atty v0.2.14
    Checking rppal v0.11.3
    Checking regex v1.3.3
    Checking env_logger v0.7.1
    Checking myapp v0.1.0 (/tmp/myapp)
    Finished dev [unoptimized + debuginfo] target(s) in 2.90s
$ cargo check
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
$ cargo check --target=armv7-unknown-linux-gnueabihf
   Compiling libc v0.2.66
   Compiling memchr v2.3.0
   Compiling log v0.4.8
    Checking aho-corasick v0.7.6
    Checking atty v0.2.14
    Checking rppal v0.11.3
    Checking regex v1.3.3
    Checking env_logger v0.7.1
    Checking myapp v0.1.0 (/tmp/myapp)
    Finished dev [unoptimized + debuginfo] target(s) in 2.47s
$ cargo check --target=armv7-unknown-linux-gnueabihf
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s

What is going on, I thought that result of one compilation go to target/debug and other one to target/armv7-unknown-linux-gnueabihf/debug , why rebuild of one make some influence to another?

2 Likes

This is probably caused by #4423, in particular this comment. As a work-around, instead of running cargo check to build the x86_64 version, run

cargo check --target x86_64-unknown-linux-gnu
4 Likes