Skip to content

check for CARGO_INCREMENTAL and pass -Zincremental if present #3527

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

Merged
merged 3 commits into from
Jan 12, 2017

Conversation

nikomatsakis
Copy link
Contributor

Per the discussion on IRC, this adds a very simple way for cargo users to opt into incremental compilation by setting the CARGO_INCREMENTAL environment variable (i.e., CARGO_INCREMENTAL=1 cargo build). This will result in incremental data being stored into the target/incremental directory. Since it supplies -Z, this option is only intended for use on nightly compilers, though cargo makes no effort to check.

The plan is to keep incremental compilation optional until we are feeling more confident it's not going to cause problems for people. At that point, it should become part of the compilation profile. It will be the default when building in debug builds, and opt-in for release builds.

@rust-highfive
Copy link

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @brson (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@nikomatsakis
Copy link
Contributor Author

cc @alexcrichton @michaelwoerister

@@ -843,6 +850,14 @@ impl<'a, 'cfg> Context<'a, 'cfg> {
self.lib_profile()
}

pub fn incremental_args(&self, _unit: &Unit) -> CargoResult<Vec<String>> {
if self.incremental_enabled {
Ok(vec![format!("-Zincremental={}", self.host.incremental().display())])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think here we may not want to always use self.host, but rather perhaps:

self.layout(unit.kind).incremental()

assert_that(
p.cargo_process("build").arg("-v").env("CARGO_INCREMENTAL", "1"),
execs().with_stderr_contains(
" Running `rustc [..] -Zincremental=[..]/target/debug/incremental`\n"));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You'll want to change / here I think to [/] to handle Windows where it's \ instead

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also change Running to just [RUNNING]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(without the leading spaces)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh and lastly, can you add with_status(0) to ensure a successful execution?

@nikomatsakis
Copy link
Contributor Author

@alexcrichton changes made

@michaelwoerister
Copy link
Member

LGTM!
Just to confirm, this will allocate the incremental dir at target/debug/incremental and target/release/incremental, right?

@alexcrichton
Copy link
Member

@bors: r+

@bors
Copy link
Contributor

bors commented Jan 12, 2017

📌 Commit 30e91b5 has been approved by alexcrichton

@bors
Copy link
Contributor

bors commented Jan 12, 2017

⌛ Testing commit 30e91b5 with merge b38ac29...

@bors
Copy link
Contributor

bors commented Jan 12, 2017

💔 Test failed - status-appveyor

@alexcrichton
Copy link
Member

alexcrichton commented Jan 12, 2017 via email

@bors
Copy link
Contributor

bors commented Jan 12, 2017

⌛ Testing commit 30e91b5 with merge d12cc03...

bors added a commit that referenced this pull request Jan 12, 2017
check for `CARGO_INCREMENTAL` and pass `-Zincremental` if present

Per the discussion on IRC, this adds a very simple way for cargo users to opt into incremental compilation by setting the `CARGO_INCREMENTAL` environment variable (i.e., `CARGO_INCREMENTAL=1 cargo build`). This will result in incremental data being stored into the `target/incremental` directory. Since it supplies `-Z`, this option is only intended for use on nightly compilers, though cargo makes no effort to check.

The plan is to keep incremental compilation optional until we are feeling more confident it's not going to cause problems for people. At that point, it should become part of the compilation profile. It will be the default when building in debug builds, and opt-in for release builds.
@bors
Copy link
Contributor

bors commented Jan 12, 2017

☀️ Test successful - status-appveyor, status-travis
Approved by: alexcrichton
Pushing d12cc03 to master...

@bors bors merged commit 30e91b5 into rust-lang:master Jan 12, 2017
@ehuss ehuss added this to the 1.16.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants