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 build recompiles when using rustc -- -Z no-trans #3204

Closed
antoyo opened this issue Oct 17, 2016 · 3 comments
Closed

Cargo build recompiles when using rustc -- -Z no-trans #3204

antoyo opened this issue Oct 17, 2016 · 3 comments
Labels
A-caching Area: caching of dependencies, repositories, and build artifacts A-rebuild-detection Area: rebuild detection and fingerprinting C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-rustc

Comments

@antoyo
Copy link

antoyo commented Oct 17, 2016

Hello.

When I use cargo rustc -- -Z -no-trans, the following cargo build will recompile even thought I did not changed the source code.

Here is the commands that I ran:

$ cargo build
   Compiling test v0.1.0 (file:///path/to/project)
    Finished debug [unoptimized + debuginfo] target(s) in 0.40 secs
$ cargo rustc -- -Z no-trans
   Compiling test v0.1.0 (file:///path/to/project)
    Finished debug [unoptimized + debuginfo] target(s) in 0.17 secs
$ cargo build
   Compiling test v0.1.0 (file:///path/to/project)
    Finished debug [unoptimized + debuginfo] target(s) in 0.40 secs

The second cargo build should not recompile the project.

Thanks to fix this issue.

@alexcrichton
Copy link
Member

Thanks for the report! Right now this is expected, however, due to how Cargo tracks cargo rustc and flags and such. Cargo has no knowledge of rustc flags, so it doesn't understand that -Z no-trans doesn't actually affect compilation, so the second cargo build to Cargo has a different set of flags being passed to the compiler, so the target is recompiled.

@carols10cents carols10cents added A-caching Area: caching of dependencies, repositories, and build artifacts A-rebuild-detection Area: rebuild detection and fingerprinting C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-rustc labels Sep 28, 2017
@ghost
Copy link

ghost commented Jan 4, 2018

There's another side-effect to using -Zno-trans(which I'm using within vim when file gets saved).

Steps to repro:

  1. change only the contents of build.rs file (or just touch build.rs ? not tested)
  2. run cargo rustc -- -Zno-trans // EDIT2: Same thing happens for cargo check
    (no errors, presumably)
  3. run cargo build
    (nothing gets built because of 2.!)

What happened?
Step 2. has updated build.rs output (eg. this file target/debug/build/recompile_self-feb93e46b6e91788/output),
so when I try step 3. it will NOT build anything.

Workaround is step 2.5. touch build.rs

What's a better way?

EDIT: If I change step 1. to touch src/main.rs however, step 3. will re-build, which is good.
Btw, the OP case doesn't seem to be true anymore, currently.

@ehuss
Copy link
Contributor

ehuss commented Mar 21, 2019

Closing as no longer applicable.
-Z no-trans was removed a while ago.
The issue @xftroxgpx mentions is fixed by #6720.

@ehuss ehuss closed this as completed Mar 21, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-caching Area: caching of dependencies, repositories, and build artifacts A-rebuild-detection Area: rebuild detection and fingerprinting C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` Command-rustc
Projects
None yet
Development

No branches or pull requests

4 participants