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

no separate caching for target/host #7822

Closed
davemilter opened this issue Jan 23, 2020 · 4 comments
Closed

no separate caching for target/host #7822

davemilter opened this issue Jan 23, 2020 · 4 comments
Labels
C-bug Category: bug

Comments

@davemilter
Copy link

davemilter commented Jan 23, 2020

Problem

I compile for PC and "Raspberry PI 3" from the same sources,
every time I change target it recomiples from scratch all dependicies what is very strange,
because of data in separate directories:
target/debug
and
target/armv7-unknown-linux-gnueabihf/debug

Steps

  1. build/check two times
    myapp.zip
    crate in attachment.
cargo check
cargo check
  1. Cross-compile it
cargo check --target=armv7-unknown-linux-gnueabihf
cargo check --target=armv7-unknown-linux-gnueabihf
  1. Recompile for host again:
cargo check

and you see that cache for host is gone and cargo rebuild all from scratch.

Notes

Output of cargo version:
cargo 1.40.0 (bc8e4c8 2019-11-22)

This is happens only if rppal used as dependency, but any way why armv7-unknown-linux-gnueabihf and my host (x86_64-unknown-linux-gnu) can interfere to each other?

rustc 1.40.0 (73528e339 2019-12-16) / linux / amd64, stable installed via rustup.

@davemilter davemilter added the C-bug Category: bug label Jan 23, 2020
@ehuss
Copy link
Contributor

ehuss commented Jan 23, 2020

Hm, I'm unable to reproduce your example. Can you run with the CARGO_LOG=cargo::core::compiler::fingerprint=trace environment variable? It should print some debug information explaining why Cargo thinks it needs to be rebuilt.

@davemilter
Copy link
Author

@ehuss

I find out culprit:

$ cat ~/.cargo/config 
[target.x86_64-unknown-linux-gnu]
rustflags = ["-Clink-arg=-fuse-ld=gold"]

If I remove ~/.cargo/config from my home directory caching starts work,
if I return it back then every target change cause rebuild from scratch.

Have no idea why change of linker for x86_64 breaks cargo caching though.

@ehuss
Copy link
Contributor

ehuss commented Jan 23, 2020

Ah. The reason is that when using the --target flag, rustflags are not included for build scripts. However, without the --target flag, Cargo will include the rustflags for build scripts. This causes the libc build script to switch to being built with and without the flag based on whether or not the --target flag is passed. There are a variety of issues that cover this (#6375, and those linked there).

@ehuss
Copy link
Contributor

ehuss commented Feb 2, 2020

I'm going to close this as it seems like the problem was figured out, and there are other issues tracking handling of RUSTFLAGS.

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

No branches or pull requests

2 participants