Skip to content

Commit 209b47f

Browse files
committed
auto merge of #12379 : alexcrichton/rust/fix-ar-thing, r=brson
When creating a staticlib, it unzips all static archives it finds and then inserts the files manually into the output file. This process is done through `ar`, and `ar` doesn't like if you specify you want to add files and you don't give it any files. This case arose whenever you linked to an archive that didn't have any contents or all of the contents were filtered out. This just involved ignoring the case where the number of inputs we have is 0, because we don't have any files to add anyway.
2 parents af4b5b4 + 2eacc72 commit 209b47f

File tree

3 files changed

+23
-0
lines changed

3 files changed

+23
-0
lines changed

src/librustc/back/archive.rs

+1
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ impl Archive {
173173
if_ok!(fs::rename(file, &new_filename));
174174
inputs.push(new_filename);
175175
}
176+
if inputs.len() == 0 { return Ok(()) }
176177

177178
// Finally, add all the renamed files to this archive
178179
let mut args = ~[&self.dst];
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
-include ../tools.mk
2+
3+
all:
4+
ar crus libfoo.a foo.rs
5+
ar d libfoo.a foo.rs
6+
$(RUSTC) foo.rs
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[crate_type = "staticlib"];
12+
13+
#[link(name = "foo", kind = "static")]
14+
extern {}
15+
16+
fn main() {}

0 commit comments

Comments
 (0)