Skip to content

Rebuild/emit new object file if it has been removed but the source has not changed #8507

Open
@micouy

Description

@micouy

I compile my project to an object file I then want to link with non-Rust files:

cargo rustc --release -Z build-std=core -- --emit obj=my-project.o

But sometimes I remove all object files in my project dir. I then want to rebuild my project without changing the source but cargo doesn't emit the object file.

cargo clean -p my-project && cargo rustc ...

Cleaning and building again by running the command above doesn't work. It only emits a new binary file (to the target dir) if I remove it. It may be related to the fact that I build the core library. That's because the binary is emitted to target/target/release not target/release as usual.

What can I do to force cargo to rebuild the project? I don't want to clean the whole target dir since I'd have to rebuild the core crate each time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`Command-cleanS-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions