Skip to content

Commit 0bf48d2

Browse files
committed
---
yaml --- r: 130516 b: refs/heads/try c: cf67285 h: refs/heads/master v: v3
1 parent 5317525 commit 0bf48d2

File tree

11 files changed

+774
-286
lines changed

11 files changed

+774
-286
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: c964cb229bd342bdeb0b4506c3a6d32b03e575f6
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 67b97ab6d2b7de9b69fd97dc171fcf8feec932ff
5-
refs/heads/try: e29aa1430bb45d18a5d3fcc5f3b7d20e99a57758
5+
refs/heads/try: cf672850df05a05e8bb5785228c408a24e102d32
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/compiletest/runtest.rs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,10 +1577,6 @@ fn _arm_push_aux_shared_library(config: &Config, testfile: &Path) {
15771577

15781578
// codegen tests (vs. clang)
15791579

1580-
fn make_o_name(config: &Config, testfile: &Path) -> Path {
1581-
output_base_name(config, testfile).with_extension("o")
1582-
}
1583-
15841580
fn append_suffix_to_stem(p: &Path, suffix: &str) -> Path {
15851581
if suffix.len() == 0 {
15861582
(*p).clone()
@@ -1596,14 +1592,13 @@ fn compile_test_and_save_bitcode(config: &Config, props: &TestProps,
15961592
// FIXME (#9639): This needs to handle non-utf8 paths
15971593
let link_args = vec!("-L".to_string(),
15981594
aux_dir.as_str().unwrap().to_string());
1599-
let llvm_args = vec!("--emit=obj".to_string(),
1600-
"--crate-type=lib".to_string(),
1601-
"-C".to_string(),
1602-
"save-temps".to_string());
1595+
let llvm_args = vec!("--emit=bc,obj".to_string(),
1596+
"--crate-type=lib".to_string());
16031597
let args = make_compile_args(config,
16041598
props,
16051599
link_args.append(llvm_args.as_slice()),
1606-
|a, b| ThisFile(make_o_name(a, b)), testfile);
1600+
|a, b| ThisDirectory(output_base_name(a, b).dir_path()),
1601+
testfile);
16071602
compose_and_run_compiler(config, props, testfile, args, None)
16081603
}
16091604

branches/try/src/librustc/back/link.rs

Lines changed: 46 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -662,51 +662,56 @@ fn link_rlib<'a>(sess: &'a Session,
662662
ab.add_file(&metadata).unwrap();
663663
remove(sess, &metadata);
664664

665-
// For LTO purposes, the bytecode of this library is also inserted
666-
// into the archive.
667-
//
668-
// Note that we make sure that the bytecode filename in the archive
669-
// is never exactly 16 bytes long by adding a 16 byte extension to
670-
// it. This is to work around a bug in LLDB that would cause it to
671-
// crash if the name of a file in an archive was exactly 16 bytes.
672-
let bc_filename = obj_filename.with_extension("bc");
673-
let bc_deflated_filename = obj_filename.with_extension("bytecode.deflate");
674-
675-
let bc_data = match fs::File::open(&bc_filename).read_to_end() {
676-
Ok(buffer) => buffer,
677-
Err(e) => sess.fatal(format!("failed to read bytecode: {}",
678-
e).as_slice())
679-
};
665+
if sess.opts.cg.codegen_units == 1 {
666+
// For LTO purposes, the bytecode of this library is also
667+
// inserted into the archive. We currently do this only when
668+
// codegen_units == 1, so we don't have to deal with multiple
669+
// bitcode files per crate.
670+
//
671+
// Note that we make sure that the bytecode filename in the
672+
// archive is never exactly 16 bytes long by adding a 16 byte
673+
// extension to it. This is to work around a bug in LLDB that
674+
// would cause it to crash if the name of a file in an archive
675+
// was exactly 16 bytes.
676+
let bc_filename = obj_filename.with_extension("bc");
677+
let bc_deflated_filename = obj_filename.with_extension("bytecode.deflate");
678+
679+
let bc_data = match fs::File::open(&bc_filename).read_to_end() {
680+
Ok(buffer) => buffer,
681+
Err(e) => sess.fatal(format!("failed to read bytecode: {}",
682+
e).as_slice())
683+
};
680684

681-
let bc_data_deflated = match flate::deflate_bytes(bc_data.as_slice()) {
682-
Some(compressed) => compressed,
683-
None => sess.fatal(format!("failed to compress bytecode from {}",
684-
bc_filename.display()).as_slice())
685-
};
685+
let bc_data_deflated = match flate::deflate_bytes(bc_data.as_slice()) {
686+
Some(compressed) => compressed,
687+
None => sess.fatal(format!("failed to compress bytecode from {}",
688+
bc_filename.display()).as_slice())
689+
};
686690

687-
let mut bc_file_deflated = match fs::File::create(&bc_deflated_filename) {
688-
Ok(file) => file,
689-
Err(e) => {
690-
sess.fatal(format!("failed to create compressed bytecode \
691-
file: {}", e).as_slice())
692-
}
693-
};
691+
let mut bc_file_deflated = match fs::File::create(&bc_deflated_filename) {
692+
Ok(file) => file,
693+
Err(e) => {
694+
sess.fatal(format!("failed to create compressed bytecode \
695+
file: {}", e).as_slice())
696+
}
697+
};
694698

695-
match write_rlib_bytecode_object_v1(&mut bc_file_deflated,
696-
bc_data_deflated.as_slice()) {
697-
Ok(()) => {}
698-
Err(e) => {
699-
sess.err(format!("failed to write compressed bytecode: \
700-
{}", e).as_slice());
701-
sess.abort_if_errors()
702-
}
703-
};
699+
match write_rlib_bytecode_object_v1(&mut bc_file_deflated,
700+
bc_data_deflated.as_slice()) {
701+
Ok(()) => {}
702+
Err(e) => {
703+
sess.err(format!("failed to write compressed bytecode: \
704+
{}", e).as_slice());
705+
sess.abort_if_errors()
706+
}
707+
};
704708

705-
ab.add_file(&bc_deflated_filename).unwrap();
706-
remove(sess, &bc_deflated_filename);
707-
if !sess.opts.cg.save_temps &&
708-
!sess.opts.output_types.contains(&OutputTypeBitcode) {
709-
remove(sess, &bc_filename);
709+
ab.add_file(&bc_deflated_filename).unwrap();
710+
remove(sess, &bc_deflated_filename);
711+
if !sess.opts.cg.save_temps &&
712+
!sess.opts.output_types.contains(&OutputTypeBitcode) {
713+
remove(sess, &bc_filename);
714+
}
710715
}
711716
}
712717

branches/try/src/librustc/back/lto.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,14 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
6767
archive.read(format!("{}.bytecode.deflate",
6868
file).as_slice())
6969
});
70-
let bc_encoded = bc_encoded.expect("missing compressed bytecode in archive!");
70+
let bc_encoded = match bc_encoded {
71+
Some(data) => data,
72+
None => {
73+
sess.fatal(format!("missing compressed bytecode in {} \
74+
(perhaps it was compiled with -C codegen-units > 1)",
75+
path.display()).as_slice());
76+
},
77+
};
7178
let bc_extractor = if is_versioned_bytecode_format(bc_encoded) {
7279
|_| {
7380
// Read the version
@@ -120,7 +127,7 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
120127
if !llvm::LLVMRustLinkInExternalBitcode(llmod,
121128
ptr as *const libc::c_char,
122129
bc_decoded.len() as libc::size_t) {
123-
write::llvm_err(sess,
130+
write::llvm_err(sess.diagnostic().handler(),
124131
format!("failed to load bc of `{}`",
125132
name.as_slice()));
126133
}

0 commit comments

Comments
 (0)