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

cargo recompile all crates when building cross architecture with specifying +crt-static in rustflags on Windows #11264

Closed
metaworm opened this issue Oct 20, 2022 · 1 comment
Labels
C-bug Category: bug

Comments

@metaworm
Copy link

Problem

I specify rustflags in .cargo/config.toml in my project directory like this

[target.i686-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]
[target.x86_64-pc-windows-msvc]
rustflags = ["-C", "target-feature=+crt-static"]

Every time when i build project using cargo build --target <target-triple> and switch one target to another, cargo will recompile all crates rather than reuse the compiled result in the target/<target-triple> directory

Steps

  1. Put these configuration into .cargo/config.toml in your project directory
    [target.i686-pc-windows-msvc]
    rustflags = ["-C", "target-feature=+crt-static"]
    [target.x86_64-pc-windows-msvc]
    rustflags = ["-C", "target-feature=+crt-static"]
  2. Build the x86_64 version which is the default on Windows using cargo build
  3. Build the x86 version using cargo build --target i686-pc-windows-msvc
  4. Build the x86_64 version again using cargo build, cargo will recompile all crates

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.66.0-nightly (b332991a5 2022-10-13)
@metaworm metaworm added the C-bug Category: bug label Oct 20, 2022
@ehuss
Copy link
Contributor

ehuss commented Oct 20, 2022

Thanks for the report! This is a known issue where running cargo build and cargo build --target share the same build-script/proc-macro artifacts, but use different RUSTFLAGS and thus cause a rebuild.

Workarounds involve always using --target, separate target directories, or target-applies-to-host.

Closing as a duplicate of #9453 (and #3739, and #6375, and #8716).

@ehuss ehuss closed this as not planned Won't fix, can't repro, duplicate, stale Oct 20, 2022
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