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

cache invalidated building workspace members for default and explicit targets #8899

Closed
nitsky opened this issue Nov 25, 2020 · 4 comments
Closed
Labels
C-bug Category: bug

Comments

@nitsky
Copy link

nitsky commented Nov 25, 2020

Problem

Cargo's cache appears to be invalidated when building one workspace member with the default target followed by another workspace member with an explicit target.

Steps

Create a workspace with two crates, a and b. Make each workspace member depend on the "wasm-bindgen" crate.

Run cargo build --package a and cargo build --package b --target wasm32-unknown-unknown.

Now run cargo build --package a and observe that the build starts from scratch, rather than finishing immediately.

Caching does work as expected when the default target is explicitly specified. For example:

cargo build --package a --target x86_64-unknown-linux-gnu
cargo build --package b --target wasm32-unknown-unknown
cargo build --package a --target x86_64-unknown-linux-gnu

As a workaround, I currently use a separate target directory for wasm builds.

Output of cargo version: cargo 1.48.0 (65cbdd2 2020-10-14)

@nitsky nitsky added the C-bug Category: bug label Nov 25, 2020
@ehuss
Copy link
Contributor

ehuss commented Nov 25, 2020

Hm, I'm not able to immediately reproduce the issue with the steps provided.

When it rebuilds, can you run cargo with the CARGO_LOG=cargo::core::compiler::fingerprint=trace environment variable set to print out some debug information that should indicate why it thinks it needed to rebuild.

@nitsky
Copy link
Author

nitsky commented Nov 25, 2020

@ehuss thanks, that helped. Cargo is reporting that rustflags have changed when I switch targets because I have the following in ~/.cargo/config.toml: target.x86_64-unknown-linux-gnu.rustflags = ["-C", "link-arg=-fuse-ld=lld"]. Removing that line resolves the issue, but is there some way that I can use LLD for the linux target while not triggering rebuilds by building for wasm?

@ehuss
Copy link
Contributor

ehuss commented Nov 25, 2020

I don't think so, you'll need to always pass --target (or use separate target directories). It's kind of a long-standing issue that RUSTFLAGS without --target applies to build dependencies (#3739). There's also #8716, which is to keep crates built with different flags isolated with different filenames, but there are some complications that make that difficult.

@nitsky
Copy link
Author

nitsky commented Nov 25, 2020

Thanks for the help. I will close this in favor of #8716.

@nitsky nitsky closed this as completed Nov 25, 2020
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