Skip to content

Commit bad05bb

Browse files
committed
---
yaml --- r: 277269 b: refs/heads/try c: 358e41c h: refs/heads/master i: 277267: 2e4d3f8
1 parent 1cd507b commit bad05bb

File tree

4 files changed

+59
-52
lines changed

4 files changed

+59
-52
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
33
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4-
refs/heads/try: 92e24b95167897881377d43ce3ee6aa7ba2685a4
4+
refs/heads/try: 358e41cee4c31a739b6a45723e8917b19e7f7db9
55
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
66
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
77
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try/src/librustc/session/mod.rs

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,16 @@ use syntax::{ast, codemap};
3030
use syntax::feature_gate::AttributeType;
3131

3232
use rustc_back::target::Target;
33+
use llvm;
3334

3435
use std::path::{Path, PathBuf};
3536
use std::cell::{Cell, RefCell};
3637
use std::collections::{HashMap, HashSet};
3738
use std::env;
39+
use std::ffi::CString;
3840
use std::rc::Rc;
3941
use std::fmt;
42+
use libc::c_int;
4043

4144
pub mod config;
4245
pub mod filesearch;
@@ -491,9 +494,63 @@ pub fn build_session_(sopts: config::Options,
491494
imported_macro_spans: RefCell::new(HashMap::new()),
492495
};
493496

497+
init_llvm(&sess);
498+
494499
sess
495500
}
496501

502+
fn init_llvm(sess: &Session) {
503+
unsafe {
504+
// Before we touch LLVM, make sure that multithreading is enabled.
505+
use std::sync::Once;
506+
static INIT: Once = Once::new();
507+
static mut POISONED: bool = false;
508+
INIT.call_once(|| {
509+
if llvm::LLVMStartMultithreaded() != 1 {
510+
// use an extra bool to make sure that all future usage of LLVM
511+
// cannot proceed despite the Once not running more than once.
512+
POISONED = true;
513+
}
514+
515+
configure_llvm(sess);
516+
});
517+
518+
if POISONED {
519+
bug!("couldn't enable multi-threaded LLVM");
520+
}
521+
}
522+
}
523+
524+
unsafe fn configure_llvm(sess: &Session) {
525+
let mut llvm_c_strs = Vec::new();
526+
let mut llvm_args = Vec::new();
527+
528+
{
529+
let mut add = |arg: &str| {
530+
let s = CString::new(arg).unwrap();
531+
llvm_args.push(s.as_ptr());
532+
llvm_c_strs.push(s);
533+
};
534+
add("rustc"); // fake program name
535+
if sess.time_llvm_passes() { add("-time-passes"); }
536+
if sess.print_llvm_passes() { add("-debug-pass=Structure"); }
537+
538+
// FIXME #21627 disable faulty FastISel on AArch64 (even for -O0)
539+
if sess.target.target.arch == "aarch64" { add("-fast-isel=0"); }
540+
541+
for arg in &sess.opts.cg.llvm_args {
542+
add(&(*arg));
543+
}
544+
}
545+
546+
llvm::LLVMInitializePasses();
547+
548+
llvm::initialize_available_targets();
549+
550+
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
551+
llvm_args.as_ptr());
552+
}
553+
497554
pub fn early_error(output: config::ErrorOutputType, msg: &str) -> ! {
498555
let mut emitter: Box<Emitter> = match output {
499556
config::ErrorOutputType::HumanReadable(color_config) => {

branches/try/src/librustc_trans/back/write.rs

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ use std::str;
3131
use std::sync::{Arc, Mutex};
3232
use std::sync::mpsc::channel;
3333
use std::thread;
34-
use libc::{c_uint, c_int, c_void};
34+
use libc::{c_uint, c_void};
3535

3636
pub fn llvm_err(handler: &errors::Handler, msg: String) -> ! {
3737
match llvm::last_error() {
@@ -984,36 +984,6 @@ pub fn run_assembler(sess: &Session, outputs: &OutputFilenames) {
984984
}
985985
}
986986

987-
pub unsafe fn configure_llvm(sess: &Session) {
988-
let mut llvm_c_strs = Vec::new();
989-
let mut llvm_args = Vec::new();
990-
991-
{
992-
let mut add = |arg: &str| {
993-
let s = CString::new(arg).unwrap();
994-
llvm_args.push(s.as_ptr());
995-
llvm_c_strs.push(s);
996-
};
997-
add("rustc"); // fake program name
998-
if sess.time_llvm_passes() { add("-time-passes"); }
999-
if sess.print_llvm_passes() { add("-debug-pass=Structure"); }
1000-
1001-
// FIXME #21627 disable faulty FastISel on AArch64 (even for -O0)
1002-
if sess.target.target.arch == "aarch64" { add("-fast-isel=0"); }
1003-
1004-
for arg in &sess.opts.cg.llvm_args {
1005-
add(&(*arg));
1006-
}
1007-
}
1008-
1009-
llvm::LLVMInitializePasses();
1010-
1011-
llvm::initialize_available_targets();
1012-
1013-
llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int,
1014-
llvm_args.as_ptr());
1015-
}
1016-
1017987
pub unsafe fn with_llvm_pmb(llmod: ModuleRef,
1018988
config: &ModuleConfig,
1019989
f: &mut FnMut(llvm::PassManagerBuilderRef)) {

branches/try/src/librustc_trans/base.rs

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2709,26 +2709,6 @@ pub fn trans_crate<'tcx>(tcx: &TyCtxt<'tcx>,
27092709
tcx.sess.opts.debug_assertions
27102710
};
27112711

2712-
// Before we touch LLVM, make sure that multithreading is enabled.
2713-
unsafe {
2714-
use std::sync::Once;
2715-
static INIT: Once = Once::new();
2716-
static mut POISONED: bool = false;
2717-
INIT.call_once(|| {
2718-
if llvm::LLVMStartMultithreaded() != 1 {
2719-
// use an extra bool to make sure that all future usage of LLVM
2720-
// cannot proceed despite the Once not running more than once.
2721-
POISONED = true;
2722-
}
2723-
2724-
::back::write::configure_llvm(&tcx.sess);
2725-
});
2726-
2727-
if POISONED {
2728-
bug!("couldn't enable multi-threaded LLVM");
2729-
}
2730-
}
2731-
27322712
let link_meta = link::build_link_meta(&tcx, name);
27332713

27342714
let codegen_units = tcx.sess.opts.cg.codegen_units;

0 commit comments

Comments
 (0)