Skip to content

Commit 8994806

Browse files
committed
---
yaml --- r: 147102 b: refs/heads/try2 c: fce4a17 h: refs/heads/master v: v3
1 parent 809066b commit 8994806

File tree

21 files changed

+433
-125
lines changed

21 files changed

+433
-125
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 52b835c5e7a68b32a8f0532f178c150d09be200d
8+
refs/heads/try2: fce4a174b9ffff71a66feecd9f4960f17fc9c331
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustc/back/archive.rs

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@ fn run_ar(sess: Session, args: &str, cwd: Option<&Path>,
4242
}
4343
let o = Process::new(ar, args.as_slice(), opts).finish_with_output();
4444
if !o.status.success() {
45-
sess.err(format!("{} failed with: {}", ar, o.status));
45+
sess.err(format!("{} {} failed with: {}", ar, args.connect(" "),
46+
o.status));
4647
sess.note(format!("stdout ---\n{}", str::from_utf8(o.output)));
4748
sess.note(format!("stderr ---\n{}", str::from_utf8(o.error)));
4849
sess.abort_if_errors();
@@ -88,16 +89,34 @@ impl Archive {
8889

8990
/// Adds all of the contents of the rlib at the specified path to this
9091
/// archive.
91-
pub fn add_rlib(&mut self, rlib: &Path) {
92-
let name = rlib.filename_str().unwrap().split('-').next().unwrap();
93-
self.add_archive(rlib, name, [METADATA_FILENAME]);
92+
///
93+
/// This ignores adding the bytecode from the rlib, and if LTO is enabled
94+
/// then the object file also isn't added.
95+
pub fn add_rlib(&mut self, rlib: &Path, name: &str, lto: bool) {
96+
let object = format!("{}.o", name);
97+
let bytecode = format!("{}.bc", name);
98+
let mut ignore = ~[METADATA_FILENAME, bytecode.as_slice()];
99+
if lto {
100+
ignore.push(object.as_slice());
101+
}
102+
self.add_archive(rlib, name, ignore);
94103
}
95104

96105
/// Adds an arbitrary file to this archive
97106
pub fn add_file(&mut self, file: &Path) {
98107
run_ar(self.sess, "r", None, [&self.dst, file]);
99108
}
100109

110+
/// Removes a file from this archive
111+
pub fn remove_file(&mut self, file: &str) {
112+
run_ar(self.sess, "d", None, [&self.dst, &Path::new(file)]);
113+
}
114+
115+
pub fn files(&self) -> ~[~str] {
116+
let output = run_ar(self.sess, "t", None, [&self.dst]);
117+
str::from_utf8(output.output).lines().map(|s| s.to_owned()).collect()
118+
}
119+
101120
fn add_archive(&mut self, archive: &Path, name: &str, skip: &[&str]) {
102121
let loc = TempDir::new("rsar").unwrap();
103122

@@ -109,11 +128,17 @@ impl Archive {
109128
// The reason for this is that archives are keyed off the name of the
110129
// files, so if two files have the same name they will override one
111130
// another in the archive (bad).
131+
//
132+
// We skip any files explicitly desired for skipping, and we also skip
133+
// all SYMDEF files as these are just magical placeholders which get
134+
// re-created when we make a new archive anyway.
112135
let files = fs::readdir(loc.path());
113136
let mut inputs = ~[];
114137
for file in files.iter() {
115138
let filename = file.filename_str().unwrap();
116139
if skip.iter().any(|s| *s == filename) { continue }
140+
if filename.contains(".SYMDEF") { continue }
141+
117142
let filename = format!("r-{}-{}", name, filename);
118143
let new_filename = file.with_filename(filename);
119144
fs::rename(file, &new_filename);

0 commit comments

Comments
 (0)