Skip to content

Commit 801a87b

Browse files
authored
Split s out of the ar invocation (#570)
This commit splits out the `s` command from the `ar` invocation to happen as part of a separate step after the archive is fully assembled. Turns out #569 has an issue on Linux where `qs` implies `r` (??), so to get the append-only behavior of `q` we need to omit the `s`. Closes #568 (for real this time?)
1 parent 3c1e2f4 commit 801a87b

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cc"
3-
version = "1.0.64"
3+
version = "1.0.65"
44
authors = ["Alex Crichton <[email protected]>"]
55
license = "MIT/Apache-2.0"
66
repository = "https://github.com/alexcrichton/cc-rs"

src/lib.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1777,17 +1777,20 @@ impl Build {
17771777
// Delete the destination if it exists as we want to
17781778
// create on the first iteration instead of appending.
17791779
let _ = fs::remove_file(&dst);
1780-
let target = self.get_target()?;
1780+
1781+
// Add objects to the archive in limited-length batches. This helps keep
1782+
// the length of the command line within a reasonable length to avoid
1783+
// blowing system limits on limiting platforms like Windows.
17811784
let objs: Vec<_> = objs
17821785
.iter()
17831786
.map(|o| o.dst.clone())
17841787
.chain(self.objects.clone())
17851788
.collect();
1786-
17871789
for chunk in objs.chunks(100) {
17881790
self.assemble_progressive(dst, chunk)?;
17891791
}
17901792

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

18121821
Ok(())
@@ -1859,7 +1868,7 @@ impl Build {
18591868
for flag in self.ar_flags.iter() {
18601869
ar.arg(flag);
18611870
}
1862-
run(ar.arg("cqs").arg(dst).args(objs), &cmd)?;
1871+
run(ar.arg("cq").arg(dst).args(objs), &cmd)?;
18631872
}
18641873

18651874
Ok(())

0 commit comments

Comments
 (0)