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

Incremental builds #381

Closed
MGlolenstine opened this issue Feb 26, 2020 · 4 comments
Closed

Incremental builds #381

MGlolenstine opened this issue Feb 26, 2020 · 4 comments

Comments

@MGlolenstine
Copy link

Is there a way to prebuild certain libraries, so that next builds are a lot faster?

@Alexhuszagh
Copy link
Contributor

I believe this is only an issue if you switch between using cross and cargo on the host. As it is, this should already be supported, incremental builds are used by default.

A simple test is:

# Ensure we're using the latest cross
 cargo install cross --git https://github.com/cross-rs/cross

# Build a sample project with numerous dependencies.
git clone https://github.com/hyperium/hyper
cd hyper
git checkout v0.14.16

# Build once
cross build --target sparc64-unknown-linux-gnu

# Apply a patch and rebuild
git apply << EOF 
diff --git a/src/lib.rs b/src/lib.rs
index 41a0b375..1d1ef726 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -6,6 +6,8 @@
 #![cfg_attr(all(test, feature = "nightly"), feature(test))]
 #![cfg_attr(docsrs, feature(doc_cfg))]
 
+// Modified file
+
 //! # hyper
 //!
 //! hyper is a **fast** and **correct** HTTP implementation written in and for Rust.
EOF
cross build --target sparc64-unknown-linux-gnu --verbose

In this example, only hyper is rebuilt, and does a similar incremental build to cargo on the host. Adding the --verbose flag shows only lib.rs is being rebuilt.

If you cargo on the host and use cross afterwards, however, yes, the entire dependency tree is rebuilt.

@Emilgardis
Copy link
Member

it shouldn't invalidate incremental data, as the directory for incremental data will be in target/{target}/{profile}, exactly what happens when you use --target in cargo natively (since that's what we actually do). I can switch between cross and cargo between diffs and keep incremental data, I did one time observe it being invalidated, but haven't been able to replicate it more.

@Alexhuszagh
Copy link
Contributor

I believe this is linked to #280.

@Alexhuszagh
Copy link
Contributor

If this reproduces outside of a situation where you switch between cargo and cross or update toolchain versions for the same target, I'll re-open this. Otherwise, it's a duplicate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants