Skip to content

Split s out of the ar invocation #570

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 1 commit into from
Nov 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "cc"
version = "1.0.64"
version = "1.0.65"
authors = ["Alex Crichton <alex@alexcrichton.com>"]
license = "MIT/Apache-2.0"
repository = "https://github.com/alexcrichton/cc-rs"
Expand Down
15 changes: 12 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1777,17 +1777,20 @@ impl Build {
// Delete the destination if it exists as we want to
// create on the first iteration instead of appending.
let _ = fs::remove_file(&dst);
let target = self.get_target()?;

// Add objects to the archive in limited-length batches. This helps keep
// the length of the command line within a reasonable length to avoid
// blowing system limits on limiting platforms like Windows.
let objs: Vec<_> = objs
.iter()
.map(|o| o.dst.clone())
.chain(self.objects.clone())
.collect();

for chunk in objs.chunks(100) {
self.assemble_progressive(dst, chunk)?;
}

let target = self.get_target()?;
if target.contains("msvc") {
// The Rust compiler will look for libfoo.a and foo.lib, but the
// MSVC linker will also be passed foo.lib, so be sure that both
Expand All @@ -1807,6 +1810,12 @@ impl Build {
));
}
};
} else {
// Non-msvc targets (those using `ar`) need a separate step to add
// the symbol table to archives since our construction command of
// `cq` doesn't add it for us.
let (mut ar, cmd) = self.get_ar()?;
run(ar.arg("s").arg(dst), &cmd)?;
}

Ok(())
Expand Down Expand Up @@ -1859,7 +1868,7 @@ impl Build {
for flag in self.ar_flags.iter() {
ar.arg(flag);
}
run(ar.arg("cqs").arg(dst).args(objs), &cmd)?;
run(ar.arg("cq").arg(dst).args(objs), &cmd)?;
}

Ok(())
Expand Down