Skip to content

Commit 841f31e

Browse files
committed
auto merge of #13074 : pczarn/rust/build-rlib, r=alexcrichton
Fixes #12992 I tried to increase the number of deflate's probes. Reduction of 0.5% or 2% is not enough.
2 parents bc37b8f + f0f5072 commit 841f31e

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/librustc/back/link.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -937,16 +937,18 @@ fn link_rlib<'a>(sess: &'a Session,
937937
// For LTO purposes, the bytecode of this library is also inserted
938938
// into the archive.
939939
let bc = obj_filename.with_extension("bc");
940+
let bc_deflated = obj_filename.with_extension("bc.deflate");
940941
match fs::File::open(&bc).read_to_end().and_then(|data| {
941-
fs::File::create(&bc).write(flate::deflate_bytes(data).as_slice())
942+
fs::File::create(&bc_deflated).write(flate::deflate_bytes(data).as_slice())
942943
}) {
943944
Ok(()) => {}
944945
Err(e) => {
945946
sess.err(format!("failed to compress bytecode: {}", e));
946947
sess.abort_if_errors()
947948
}
948949
}
949-
a.add_file(&bc, false);
950+
a.add_file(&bc_deflated, false);
951+
remove(sess, &bc_deflated);
950952
if !sess.opts.cg.save_temps &&
951953
!sess.opts.output_types.contains(&OutputTypeBitcode) {
952954
remove(sess, &bc);

src/librustc/back/lto.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
5252

5353
let archive = ArchiveRO::open(&path).expect("wanted an rlib");
5454
debug!("reading {}", name);
55-
let bc = time(sess.time_passes(), format!("read {}.bc", name), (), |_|
56-
archive.read(format!("{}.bc", name)));
57-
let bc = bc.expect("missing bytecode in archive!");
55+
let bc = time(sess.time_passes(), format!("read {}.bc.deflate", name), (), |_|
56+
archive.read(format!("{}.bc.deflate", name)));
57+
let bc = bc.expect("missing compressed bytecode in archive!");
5858
let bc = time(sess.time_passes(), format!("inflate {}.bc", name), (), |_|
5959
flate::inflate_bytes(bc));
6060
let ptr = bc.as_slice().as_ptr();

src/test/run-make/output-type-permutations/Makefile

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ all:
1515
rm $(TMPDIR)/bar
1616
$(RUSTC) foo.rs --emit=asm,ir,bc,obj,link --crate-type=staticlib
1717
rm $(TMPDIR)/bar.ll
18-
rm $(TMPDIR)/bar.bc
1918
rm $(TMPDIR)/bar.s
2019
rm $(TMPDIR)/bar.o
2120
rm $(TMPDIR)/$(call STATICLIB_GLOB,bar)
@@ -37,6 +36,9 @@ all:
3736
rm $(TMPDIR)/foo
3837
$(RUSTC) foo.rs --crate-type=bin -o $(TMPDIR)/foo
3938
rm $(TMPDIR)/foo
39+
mv $(TMPDIR)/bar.bc $(TMPDIR)/foo.bc
4040
$(RUSTC) foo.rs --emit=bc,link --crate-type=rlib
41+
cmp $(TMPDIR)/foo.bc $(TMPDIR)/bar.bc
4142
rm $(TMPDIR)/bar.bc
43+
rm $(TMPDIR)/foo.bc
4244
rm $(TMPDIR)/$(call RLIB_GLOB,bar)

0 commit comments

Comments
 (0)