Skip to content

Commit 42eb850

Browse files
committed
Upgrade to LLVM's master branch (LLVM 7)
This commit upgrades the main LLVM submodule to LLVM's current master branch. The LLD submodule is updated in tandem as well as compiler-builtins. Along the way support was also added for LLVM 7's new features. This primarily includes the support for custom section concatenation natively in LLD so we now add wasm custom sections in LLVM IR rather than having custom support in rustc itself for doing so. Some other miscellaneous changes are: * We now pass `--gc-sections` to `wasm-ld` * The optimization level is now passed to `wasm-ld` * A `--stack-first` option is passed to LLD to have stack overflow always cause a trap instead of corrupting static data * The wasm target for LLVM switched to `wasm32-unknown-unknown`. * The syntax for aligned pointers has changed in LLVM IR and tests are updated to reflect this. * The `thumbv6m-none-eabi` target is disabled due to an [LLVM bug][llbug] Nowadays we've been mostly only upgrading whenever there's a major release of LLVM but enough changes have been happening on the wasm target that there's been growing motivation for quite some time now to upgrade out version of LLD. To upgrade LLD, however, we need to upgrade LLVM to avoid needing to build yet another version of LLVM on the builders. The revision of LLVM in use here is arbitrarily chosen. We will likely need to continue to update it over time if and when we discover bugs. Once LLVM 7 is fully released we can switch to that channel as well. [llbug]: https://bugs.llvm.org/show_bug.cgi?id=37382
1 parent c30acc7 commit 42eb850

File tree

39 files changed

+202
-198
lines changed

39 files changed

+202
-198
lines changed

src/librustc/dep_graph/dep_node.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,8 +665,6 @@ define_dep_nodes!( <'tcx>
665665

666666
[] InstanceDefSizeEstimate { instance_def: InstanceDef<'tcx> },
667667

668-
[] WasmCustomSections(CrateNum),
669-
670668
[input] Features,
671669

672670
[] ProgramClausesFor(DefId),

src/librustc/hir/check_attr.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ struct CheckAttrVisitor<'a, 'tcx: 'a> {
5757
impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
5858
/// Check any attribute.
5959
fn check_attributes(&self, item: &hir::Item, target: Target) {
60-
if target == Target::Fn {
60+
if target == Target::Fn || target == Target::Const {
6161
self.tcx.codegen_fn_attrs(self.tcx.hir.local_def_id(item.id));
6262
} else if let Some(a) = item.attrs.iter().find(|a| a.check_name("target_feature")) {
6363
self.tcx.sess.struct_span_err(a.span, "attribute should be applied to a function")
@@ -85,11 +85,6 @@ impl<'a, 'tcx> CheckAttrVisitor<'a, 'tcx> {
8585
if target != Target::Const {
8686
self.tcx.sess.span_err(attr.span, "only allowed on consts");
8787
}
88-
89-
if attr.value_str().is_none() {
90-
self.tcx.sess.span_err(attr.span, "must be of the form \
91-
#[wasm_custom_section = \"foo\"]");
92-
}
9388
}
9489
}
9590

src/librustc/hir/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,6 +2259,7 @@ pub struct CodegenFnAttrs {
22592259
pub export_name: Option<Symbol>,
22602260
pub target_features: Vec<Symbol>,
22612261
pub linkage: Option<Linkage>,
2262+
pub wasm_custom_section: Option<Symbol>,
22622263
}
22632264

22642265
bitflags! {
@@ -2283,6 +2284,7 @@ impl CodegenFnAttrs {
22832284
export_name: None,
22842285
target_features: vec![],
22852286
linkage: None,
2287+
wasm_custom_section: None,
22862288
}
22872289
}
22882290

src/librustc/ich/impls_hir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,7 @@ impl_stable_hash_for!(struct hir::CodegenFnAttrs {
11201120
export_name,
11211121
target_features,
11221122
linkage,
1123+
wasm_custom_section,
11231124
});
11241125

11251126
impl<'hir> HashStable<StableHashingContext<'hir>> for hir::CodegenFnAttrFlags

src/librustc/mir/mono.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub enum MonoItem<'tcx> {
2424
Fn(Instance<'tcx>),
2525
Static(DefId),
2626
GlobalAsm(NodeId),
27+
CustomSection(DefId),
2728
}
2829

2930
impl<'tcx> MonoItem<'tcx> {
@@ -36,7 +37,9 @@ impl<'tcx> MonoItem<'tcx> {
3637
},
3738
// Conservatively estimate the size of a static declaration
3839
// or assembly to be 1.
39-
MonoItem::Static(_) | MonoItem::GlobalAsm(_) => 1,
40+
MonoItem::Static(_) |
41+
MonoItem::GlobalAsm(_) |
42+
MonoItem::CustomSection(_) => 1,
4043
}
4144
}
4245
}
@@ -51,7 +54,8 @@ impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for MonoItem<'tcx> {
5154
MonoItem::Fn(ref instance) => {
5255
instance.hash_stable(hcx, hasher);
5356
}
54-
MonoItem::Static(def_id) => {
57+
MonoItem::Static(def_id) |
58+
MonoItem::CustomSection(def_id) => {
5559
def_id.hash_stable(hcx, hasher);
5660
}
5761
MonoItem::GlobalAsm(node_id) => {

src/librustc/ty/query/config.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -776,12 +776,6 @@ impl<'tcx> QueryDescription<'tcx> for queries::instance_def_size_estimate<'tcx>
776776
}
777777
}
778778

779-
impl<'tcx> QueryDescription<'tcx> for queries::wasm_custom_sections<'tcx> {
780-
fn describe(_tcx: TyCtxt, _: CrateNum) -> String {
781-
format!("custom wasm sections for a crate")
782-
}
783-
}
784-
785779
impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> {
786780
#[inline]
787781
fn cache_on_disk(def_id: Self::Key) -> bool {

src/librustc/ty/query/mod.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,6 @@ define_queries! { <'tcx>
546546
ty::ParamEnv<'tcx>
547547
) -> Clauses<'tcx>,
548548

549-
[] fn wasm_custom_sections: WasmCustomSections(CrateNum) -> Lrc<Vec<DefId>>,
550549
[] fn wasm_import_module_map: WasmImportModuleMap(CrateNum)
551550
-> Lrc<FxHashMap<DefId, String>>,
552551
}

src/librustc/ty/query/plumbing.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,6 @@ pub fn force_from_dep_node<'a, 'gcx, 'lcx>(tcx: TyCtxt<'a, 'gcx, 'lcx>,
12081208
DepKind::Features => { force!(features_query, LOCAL_CRATE); }
12091209

12101210
DepKind::ProgramClausesFor => { force!(program_clauses_for, def_id!()); }
1211-
DepKind::WasmCustomSections => { force!(wasm_custom_sections, krate!()); }
12121211
DepKind::WasmImportModuleMap => { force!(wasm_import_module_map, krate!()); }
12131212
DepKind::ForeignModules => { force!(foreign_modules, krate!()); }
12141213

src/librustc_codegen_llvm/attributes.rs

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
1212
use std::ffi::{CStr, CString};
1313

14-
use rustc::hir::{self, CodegenFnAttrFlags};
14+
use rustc::hir::CodegenFnAttrFlags;
1515
use rustc::hir::def_id::{DefId, LOCAL_CRATE};
16-
use rustc::hir::itemlikevisit::ItemLikeVisitor;
1716
use rustc::session::Session;
1817
use rustc::session::config::Sanitizer;
1918
use rustc::ty::TyCtxt;
@@ -222,37 +221,9 @@ pub fn provide(providers: &mut Providers) {
222221
}
223222
};
224223

225-
providers.wasm_custom_sections = |tcx, cnum| {
226-
assert_eq!(cnum, LOCAL_CRATE);
227-
let mut finder = WasmSectionFinder { tcx, list: Vec::new() };
228-
tcx.hir.krate().visit_all_item_likes(&mut finder);
229-
Lrc::new(finder.list)
230-
};
231-
232224
provide_extern(providers);
233225
}
234226

235-
struct WasmSectionFinder<'a, 'tcx: 'a> {
236-
tcx: TyCtxt<'a, 'tcx, 'tcx>,
237-
list: Vec<DefId>,
238-
}
239-
240-
impl<'a, 'tcx: 'a> ItemLikeVisitor<'tcx> for WasmSectionFinder<'a, 'tcx> {
241-
fn visit_item(&mut self, i: &'tcx hir::Item) {
242-
match i.node {
243-
hir::ItemConst(..) => {}
244-
_ => return,
245-
}
246-
if i.attrs.iter().any(|i| i.check_name("wasm_custom_section")) {
247-
self.list.push(self.tcx.hir.local_def_id(i.id));
248-
}
249-
}
250-
251-
fn visit_trait_item(&mut self, _: &'tcx hir::TraitItem) {}
252-
253-
fn visit_impl_item(&mut self, _: &'tcx hir::ImplItem) {}
254-
}
255-
256227
pub fn provide_extern(providers: &mut Providers) {
257228
providers.wasm_import_module_map = |tcx, cnum| {
258229
let mut ret = FxHashMap();

0 commit comments

Comments
 (0)