From 7984c895b6995703254035e81d0a85ae1fa9fe2b Mon Sep 17 00:00:00 2001 From: kennytm Date: Sun, 11 Feb 2018 05:05:11 +0800 Subject: [PATCH 1/3] Improve debuggability of #48116. 1. When the invalid condition is hit, write out the relevant variables too 2. In compile-fail/parse-fail tests, check for ICE first, so the invalid error patterns won't mask our ICE output. --- src/librustc_resolve/resolve_imports.rs | 15 +++++++++++++-- src/tools/compiletest/src/runtest.rs | 2 +- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/src/librustc_resolve/resolve_imports.rs b/src/librustc_resolve/resolve_imports.rs index 8cb25f449b667..a8070c553bdbc 100644 --- a/src/librustc_resolve/resolve_imports.rs +++ b/src/librustc_resolve/resolve_imports.rs @@ -1026,6 +1026,8 @@ fn import_path_to_string(names: &[SpannedIdent], if names.is_empty() { import_directive_subclass_to_string(subclass) } else { + // FIXME: Remove this entire logic after #48116 is fixed. + // // Note that this code looks a little wonky, it's currently here to // hopefully help debug #48116, but otherwise isn't intended to // cause any problems. @@ -1034,8 +1036,17 @@ fn import_path_to_string(names: &[SpannedIdent], names_to_string(names), import_directive_subclass_to_string(subclass), ); - assert!(!names.is_empty()); - assert!(!x.starts_with("::")); + if names.is_empty() || x.starts_with("::") { + span_bug!( + span, + "invalid name `{}` at {:?}; global = {}, names = {:?}, subclass = {:?}", + x, + span, + global, + names, + subclass + ); + } return x } } diff --git a/src/tools/compiletest/src/runtest.rs b/src/tools/compiletest/src/runtest.rs index a87809dd7bcfd..bef085e17ea16 100644 --- a/src/tools/compiletest/src/runtest.rs +++ b/src/tools/compiletest/src/runtest.rs @@ -250,6 +250,7 @@ impl<'test> TestCx<'test> { fn run_cfail_test(&self) { let proc_res = self.compile_test(); self.check_if_test_should_compile(&proc_res); + self.check_no_compiler_crash(&proc_res); let output_to_check = self.get_output(&proc_res); let expected_errors = errors::load_errors(&self.testpaths.file, self.revision); @@ -262,7 +263,6 @@ impl<'test> TestCx<'test> { self.check_error_patterns(&output_to_check, &proc_res); } - self.check_no_compiler_crash(&proc_res); self.check_forbid_output(&output_to_check, &proc_res); } From ec36e7e972e8036fe7bd428458462a2aacd40927 Mon Sep 17 00:00:00 2001 From: kennytm Date: Wed, 14 Feb 2018 23:18:18 +0800 Subject: [PATCH 2/3] Partially revert #47333. Removed the `assume()` which we assumed is the cause of misoptimization in issue #48116. --- src/libcore/slice/mod.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/libcore/slice/mod.rs b/src/libcore/slice/mod.rs index aacbbd5058e05..ac390313a6797 100644 --- a/src/libcore/slice/mod.rs +++ b/src/libcore/slice/mod.rs @@ -1246,15 +1246,18 @@ macro_rules! iterator { { // The addition might panic on overflow // Use the len of the slice to hint optimizer to remove result index bounds check. - let n = make_slice!(self.ptr, self.end).len(); + let _n = make_slice!(self.ptr, self.end).len(); self.try_fold(0, move |i, x| { if predicate(x) { Err(i) } else { Ok(i + 1) } }).err() - .map(|i| { - unsafe { assume(i < n) }; - i - }) + // // FIXME(#48116/#45964): + // // This assume() causes misoptimization on LLVM 6. + // // Commented out until it is fixed again. + // .map(|i| { + // unsafe { assume(i < n) }; + // i + // }) } #[inline] @@ -1271,10 +1274,13 @@ macro_rules! iterator { if predicate(x) { Err(i) } else { Ok(i) } }).err() - .map(|i| { - unsafe { assume(i < n) }; - i - }) + // // FIXME(#48116/#45964): + // // This assume() causes misoptimization on LLVM 6. + // // Commented out until it is fixed again. + // .map(|i| { + // unsafe { assume(i < n) }; + // i + // }) } } From e0da9902a1ab8e620be45470130cd72e31d54fc2 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Wed, 14 Feb 2018 07:44:53 -0800 Subject: [PATCH 3/3] Revert "rustbuild: Pass `ccache` to build scripts" This reverts commit 64a8730e171367e4979cd9c25f0e0fdc2c157446. --- src/bootstrap/builder.rs | 27 +++++---------------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 74dd4a6fa0144..03630dfbed3e0 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -600,25 +600,9 @@ impl<'a> Builder<'a> { // // FIXME: the guard against msvc shouldn't need to be here if !target.contains("msvc") { - let ccache = self.config.ccache.as_ref(); - let ccacheify = |s: &Path| { - let ccache = match ccache { - Some(ref s) => s, - None => return s.display().to_string(), - }; - // FIXME: the cc-rs crate only recognizes the literal strings - // `ccache` and `sccache` when doing caching compilations, so we - // mirror that here. It should probably be fixed upstream to - // accept a new env var or otherwise work with custom ccache - // vars. - match &ccache[..] { - "ccache" | "sccache" => format!("{} {}", ccache, s.display()), - _ => s.display().to_string(), - } - }; - let cc = ccacheify(&self.cc(target)); - cargo.env(format!("CC_{}", target), &cc) - .env("CC", &cc); + let cc = self.cc(target); + cargo.env(format!("CC_{}", target), cc) + .env("CC", cc); let cflags = self.cflags(target).join(" "); cargo.env(format!("CFLAGS_{}", target), cflags.clone()) @@ -633,9 +617,8 @@ impl<'a> Builder<'a> { } if let Ok(cxx) = self.cxx(target) { - let cxx = ccacheify(&cxx); - cargo.env(format!("CXX_{}", target), &cxx) - .env("CXX", &cxx) + cargo.env(format!("CXX_{}", target), cxx) + .env("CXX", cxx) .env(format!("CXXFLAGS_{}", target), cflags.clone()) .env("CXXFLAGS", cflags); }