Skip to content

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

@metaworm

Description

@metaworm

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions