Skip to content

Rollup of 5 pull requests #33965

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 13 commits into from
May 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/etc/htmldocck.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@
from htmlentitydefs import entitydefs
entitydefs['larrb'] = u'\u21e4'
entitydefs['rarrb'] = u'\u21e5'
entitydefs['nbsp'] = ' '

# "void elements" (no closing tag) from the HTML Standard section 12.1.2
VOID_ELEMENTS = set(['area', 'base', 'br', 'col', 'embed', 'hr', 'img', 'input', 'keygen',
Expand Down
10 changes: 5 additions & 5 deletions src/librustc_driver/driver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ use syntax_ext;

#[derive(Clone)]
pub struct Resolutions {
pub def_map: RefCell<DefMap>,
pub def_map: DefMap,
pub freevars: FreevarMap,
pub trait_map: TraitMap,
pub maybe_unused_trait_imports: NodeSet,
Expand Down Expand Up @@ -818,7 +818,7 @@ pub fn lower_and_resolve<'a>(sess: &Session,
name: &id,
glob_map: if resolver.make_glob_map { Some(resolver.glob_map) } else { None },
}, Resolutions {
def_map: RefCell::new(resolver.def_map),
def_map: resolver.def_map,
freevars: resolver.freevars,
trait_map: resolver.trait_map,
maybe_unused_trait_imports: resolver.maybe_unused_trait_imports,
Expand Down Expand Up @@ -866,7 +866,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
"lifetime resolution",
|| middle::resolve_lifetime::krate(sess,
&hir_map,
&resolutions.def_map.borrow()))?;
&resolutions.def_map))?;

time(time_passes,
"looking for entry point",
Expand All @@ -886,14 +886,14 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,

time(time_passes,
"static item recursion checking",
|| static_recursion::check_crate(sess, &resolutions.def_map.borrow(), &hir_map))?;
|| static_recursion::check_crate(sess, &resolutions.def_map, &hir_map))?;

let index = stability::Index::new(&hir_map);

let trait_map = resolutions.trait_map;
TyCtxt::create_and_enter(sess,
arenas,
resolutions.def_map,
RefCell::new(resolutions.def_map),
named_region_map,
hir_map,
resolutions.freevars,
Expand Down
5 changes: 3 additions & 2 deletions src/librustc_driver/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ use rustc_metadata::cstore::CStore;
use rustc_metadata::creader::read_local_crates;
use rustc::hir::map as hir_map;
use rustc::session::{self, config};
use std::cell::RefCell;
use std::rc::Rc;
use syntax::ast;
use syntax::abi::Abi;
Expand Down Expand Up @@ -134,12 +135,12 @@ fn test_env<F>(source_string: &str,

// run just enough stuff to build a tcx:
let lang_items = lang_items::collect_language_items(&sess, &ast_map);
let named_region_map = resolve_lifetime::krate(&sess, &ast_map, &resolutions.def_map.borrow());
let named_region_map = resolve_lifetime::krate(&sess, &ast_map, &resolutions.def_map);
let region_map = region::resolve_crate(&sess, &ast_map);
let index = stability::Index::new(&ast_map);
TyCtxt::create_and_enter(&sess,
&arenas,
resolutions.def_map,
RefCell::new(resolutions.def_map),
named_region_map.unwrap(),
ast_map,
resolutions.freevars,
Expand Down
29 changes: 21 additions & 8 deletions src/librustc_llvm/archive_ro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ use std::path::Path;
use std::slice;
use std::str;

pub struct ArchiveRO { ptr: ArchiveRef }
pub struct ArchiveRO {
ptr: ArchiveRef,
}

pub struct Iter<'a> {
archive: &'a ArchiveRO,
Expand Down Expand Up @@ -61,11 +63,16 @@ impl ArchiveRO {
}
}

pub fn raw(&self) -> ArchiveRef { self.ptr }
pub fn raw(&self) -> ArchiveRef {
self.ptr
}

pub fn iter(&self) -> Iter {
unsafe {
Iter { ptr: ::LLVMRustArchiveIteratorNew(self.ptr), archive: self }
Iter {
ptr: ::LLVMRustArchiveIteratorNew(self.ptr),
archive: self,
}
}
}
}
Expand All @@ -86,7 +93,10 @@ impl<'a> Iterator for Iter<'a> {
if ptr.is_null() {
::last_error().map(Err)
} else {
Some(Ok(Child { ptr: ptr, _data: marker::PhantomData }))
Some(Ok(Child {
ptr: ptr,
_data: marker::PhantomData,
}))
}
}
}
Expand All @@ -107,8 +117,7 @@ impl<'a> Child<'a> {
if name_ptr.is_null() {
None
} else {
let name = slice::from_raw_parts(name_ptr as *const u8,
name_len as usize);
let name = slice::from_raw_parts(name_ptr as *const u8, name_len as usize);
str::from_utf8(name).ok().map(|s| s.trim())
}
}
Expand All @@ -125,11 +134,15 @@ impl<'a> Child<'a> {
}
}

pub fn raw(&self) -> ::ArchiveChildRef { self.ptr }
pub fn raw(&self) -> ::ArchiveChildRef {
self.ptr
}
}

impl<'a> Drop for Child<'a> {
fn drop(&mut self) {
unsafe { ::LLVMRustArchiveChildFree(self.ptr); }
unsafe {
::LLVMRustArchiveChildFree(self.ptr);
}
}
}
61 changes: 36 additions & 25 deletions src/librustc_llvm/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,25 @@ fn main() {
println!("cargo:rustc-cfg=cargobuild");

let target = env::var("TARGET").unwrap();
let llvm_config = env::var_os("LLVM_CONFIG").map(PathBuf::from)
.unwrap_or_else(|| {
match env::var_os("CARGO_TARGET_DIR").map(PathBuf::from) {
Some(dir) => {
let to_test = dir.parent().unwrap().parent().unwrap()
.join(&target).join("llvm/bin/llvm-config");
if Command::new(&to_test).output().is_ok() {
return to_test
}
}
None => {}
}
PathBuf::from("llvm-config")
});
let llvm_config = env::var_os("LLVM_CONFIG")
.map(PathBuf::from)
.unwrap_or_else(|| {
match env::var_os("CARGO_TARGET_DIR").map(PathBuf::from) {
Some(dir) => {
let to_test = dir.parent()
.unwrap()
.parent()
.unwrap()
.join(&target)
.join("llvm/bin/llvm-config");
if Command::new(&to_test).output().is_ok() {
return to_test;
}
}
None => {}
}
PathBuf::from("llvm-config")
});

println!("cargo:rerun-if-changed={}", llvm_config.display());

Expand Down Expand Up @@ -63,20 +68,22 @@ fn main() {
let host = env::var("HOST").unwrap();
let is_crossed = target != host;

let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc",
"pnacl"];
let optional_components = ["x86", "arm", "aarch64", "mips", "powerpc", "pnacl"];

// FIXME: surely we don't need all these components, right? Stuff like mcjit
// or interpreter the compiler itself never uses.
let required_components = &["ipo", "bitreader", "bitwriter", "linker",
"asmparser", "mcjit", "interpreter",
let required_components = &["ipo",
"bitreader",
"bitwriter",
"linker",
"asmparser",
"mcjit",
"interpreter",
"instrumentation"];

let components = output(Command::new(&llvm_config).arg("--components"));
let mut components = components.split_whitespace().collect::<Vec<_>>();
components.retain(|c| {
optional_components.contains(c) || required_components.contains(c)
});
components.retain(|c| optional_components.contains(c) || required_components.contains(c));

for component in required_components {
if !components.contains(component) {
Expand All @@ -96,7 +103,7 @@ fn main() {
for flag in cxxflags.split_whitespace() {
// Ignore flags like `-m64` when we're doing a cross build
if is_crossed && flag.starts_with("-m") {
continue
continue;
}
cfg.flag(flag);
}
Expand Down Expand Up @@ -131,7 +138,7 @@ fn main() {
} else if lib.starts_with("-") {
&lib[1..]
} else {
continue
continue;
};

// Don't need or want this library, but LLVM's CMake build system
Expand All @@ -140,10 +147,14 @@ fn main() {
// library and it otherwise may just pull in extra dependencies on
// libedit which we don't want
if name == "LLVMLineEditor" {
continue
continue;
}

let kind = if name.starts_with("LLVM") {"static"} else {"dylib"};
let kind = if name.starts_with("LLVM") {
"static"
} else {
"dylib"
};
println!("cargo:rustc-link-lib={}={}", kind, name);
}

Expand Down
49 changes: 26 additions & 23 deletions src/librustc_llvm/diagnostic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub use self::Diagnostic::*;
use libc::{c_char, c_uint};
use std::ptr;

use {ValueRef, TwineRef, DebugLocRef, DiagnosticInfoRef};
use {DebugLocRef, DiagnosticInfoRef, TwineRef, ValueRef};

#[derive(Copy, Clone)]
pub enum OptimizationDiagnosticKind {
Expand Down Expand Up @@ -46,8 +46,9 @@ pub struct OptimizationDiagnostic {
}

impl OptimizationDiagnostic {
unsafe fn unpack(kind: OptimizationDiagnosticKind, di: DiagnosticInfoRef)
-> OptimizationDiagnostic {
unsafe fn unpack(kind: OptimizationDiagnosticKind,
di: DiagnosticInfoRef)
-> OptimizationDiagnostic {

let mut opt = OptimizationDiagnostic {
kind: kind,
Expand All @@ -58,10 +59,10 @@ impl OptimizationDiagnostic {
};

super::LLVMUnpackOptimizationDiagnostic(di,
&mut opt.pass_name,
&mut opt.function,
&mut opt.debug_loc,
&mut opt.message);
&mut opt.pass_name,
&mut opt.function,
&mut opt.debug_loc,
&mut opt.message);

opt
}
Expand All @@ -75,8 +76,7 @@ pub struct InlineAsmDiagnostic {
}

impl InlineAsmDiagnostic {
unsafe fn unpack(di: DiagnosticInfoRef)
-> InlineAsmDiagnostic {
unsafe fn unpack(di: DiagnosticInfoRef) -> InlineAsmDiagnostic {

let mut opt = InlineAsmDiagnostic {
cookie: 0,
Expand All @@ -85,9 +85,9 @@ impl InlineAsmDiagnostic {
};

super::LLVMUnpackInlineAsmDiagnostic(di,
&mut opt.cookie,
&mut opt.message,
&mut opt.instruction);
&mut opt.cookie,
&mut opt.message,
&mut opt.instruction);

opt
}
Expand All @@ -106,22 +106,25 @@ impl Diagnostic {
let kind = super::LLVMGetDiagInfoKind(di);

match kind {
super::DK_InlineAsm
=> InlineAsm(InlineAsmDiagnostic::unpack(di)),
super::DK_InlineAsm => InlineAsm(InlineAsmDiagnostic::unpack(di)),

super::DK_OptimizationRemark
=> Optimization(OptimizationDiagnostic::unpack(OptimizationRemark, di)),
super::DK_OptimizationRemark => {
Optimization(OptimizationDiagnostic::unpack(OptimizationRemark, di))
}

super::DK_OptimizationRemarkMissed
=> Optimization(OptimizationDiagnostic::unpack(OptimizationMissed, di)),
super::DK_OptimizationRemarkMissed => {
Optimization(OptimizationDiagnostic::unpack(OptimizationMissed, di))
}

super::DK_OptimizationRemarkAnalysis
=> Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di)),
super::DK_OptimizationRemarkAnalysis => {
Optimization(OptimizationDiagnostic::unpack(OptimizationAnalysis, di))
}

super::DK_OptimizationFailure
=> Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di)),
super::DK_OptimizationFailure => {
Optimization(OptimizationDiagnostic::unpack(OptimizationFailure, di))
}

_ => UnknownDiagnostic(di)
_ => UnknownDiagnostic(di),
}
}
}
Loading