Skip to content

Building for host architecture and then another target invalidates cache #10839

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

Closed
ryanbai1412 opened this issue Jul 9, 2022 · 6 comments
Closed
Labels
C-bug Category: bug

Comments

@ryanbai1412
Copy link

Problem

  1. Run cargo build and wait for the build to finish
  2. Run cargo build --target <target triple> for a few seconds
  3. Run cargo build again, the build restarts from scratch

I would expect step 3 to not rebuild from scratch and instead use the cached artifacts produced in step 1.

Steps

No response

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.62.0 (a748cf5a3 2022-06-08)
release: 1.62.0
commit-hash: a748cf5a3e666bc2dcdf54f37adef8ef22196452
commit-date: 2022-06-08
host: x86_64-unknown-linux-gnu
libgit2: 1.4.2 (sys:0.14.2 vendored)
libcurl: 7.80.0-DEV (sys:0.4.51+curl-7.80.0 vendored ssl:OpenSSL/1.1.1n)
os: Ubuntu 22.04 (jammy) [64-bit]
@ryanbai1412 ryanbai1412 added the C-bug Category: bug label Jul 9, 2022
@ehuss
Copy link
Contributor

ehuss commented Jul 9, 2022

Thanks for the report! Can you please provide a complete reproduction? That shouldn't happen, and I'm unable to reproduce it with a typical project.

@ryanbai1412
Copy link
Author

In my .cargo/config.toml I have:

[target.x86_64-unknown-linux-gnu]
linker = "clang" 
rustflags = ["-C", "link-arg=-fuse-ld=/usr/local/bin/mold"]

Without the above cargo works as expected. A simpler version of the config.toml would be something like:

[target.x86_64-unknown-linux-gnu]
rustflags = ["-O"]

Also I should mention that cargo build --target x86_64-unknown-linux-gnu (my host) instead of cargo build caches with other targets.

@ehuss
Copy link
Contributor

ehuss commented Jul 10, 2022

Ah, specifying rustflags will indeed cause a difference here. There are two points:

@willhodges
Copy link

@ehuss I'm seeing this issue with multiple build targets and the same non-default RUSTFLAGS across those targets.

@willhodges
Copy link

This is still an issue.

@ehuss
Copy link
Contributor

ehuss commented Aug 13, 2022

Closing as a duplicate of the two issues linked above. This is just something that cargo does not support at this time.

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Aug 13, 2022
lucasfernog added a commit to tauri-apps/tauri that referenced this issue Aug 26, 2024
Currently we force the usage of the host target triple due to a Cargo cache issue (rust-lang/cargo#10839) but seems like it is not affecting us anymore.
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

3 participants