From a5cf56d26caeed3d3ccd0c4518acf09ac4fee895 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 2 Jan 2018 16:21:35 -0800 Subject: [PATCH 1/6] rustc: Don't use relative paths for extended errors These no longer work now that Cargo changes the cwd of rustc while it's running. Instead use an absolute path that's set by rustbuild. --- src/bootstrap/builder.rs | 4 ++-- src/bootstrap/check.rs | 3 ++- src/bootstrap/doc.rs | 3 ++- src/bootstrap/lib.rs | 5 +++++ src/libsyntax/diagnostics/metadata.rs | 11 ++++++----- 5 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs index 16de31406f847..ce30d1f4cec42 100644 --- a/src/bootstrap/builder.rs +++ b/src/bootstrap/builder.rs @@ -484,8 +484,8 @@ impl<'a> Builder<'a> { } else { PathBuf::from("/path/to/nowhere/rustdoc/not/required") }) - .env("TEST_MIRI", self.config.test_miri.to_string()); - + .env("TEST_MIRI", self.config.test_miri.to_string()) + .env("RUSTC_ERROR_METADATA_DST", self.extended_error_dir()); if let Some(n) = self.config.rust_codegen_units { cargo.env("RUSTC_CODEGEN_UNITS", n.to_string()); } diff --git a/src/bootstrap/check.rs b/src/bootstrap/check.rs index 48b3d356985c3..e4fbae3ff0d85 100644 --- a/src/bootstrap/check.rs +++ b/src/bootstrap/check.rs @@ -980,7 +980,8 @@ impl Step for ErrorIndex { build.run(builder.tool_cmd(Tool::ErrorIndex) .arg("markdown") .arg(&output) - .env("CFG_BUILD", &build.build)); + .env("CFG_BUILD", &build.build) + .env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir())); markdown_test(builder, compiler, &output); } diff --git a/src/bootstrap/doc.rs b/src/bootstrap/doc.rs index 3c12cfc4c7ffd..832da24c994db 100644 --- a/src/bootstrap/doc.rs +++ b/src/bootstrap/doc.rs @@ -671,7 +671,8 @@ impl Step for ErrorIndex { index.arg(out.join("error-index.html")); // FIXME: shouldn't have to pass this env var - index.env("CFG_BUILD", &build.build); + index.env("CFG_BUILD", &build.build) + .env("RUSTC_ERROR_METADATA_DST", build.extended_error_dir()); build.run(&mut index); } diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs index 63a9c3ab905de..52767b403e4ec 100644 --- a/src/bootstrap/lib.rs +++ b/src/bootstrap/lib.rs @@ -721,6 +721,11 @@ impl Build { self.config.python.as_ref().unwrap() } + /// Temporary directory that extended error information is emitted to. + fn extended_error_dir(&self) -> PathBuf { + self.out.join("tmp/extended-error-metadata") + } + /// Tests whether the `compiler` compiling for `target` should be forced to /// use a stage1 compiler instead. /// diff --git a/src/libsyntax/diagnostics/metadata.rs b/src/libsyntax/diagnostics/metadata.rs index 5f06475919fec..dc01a79190b3a 100644 --- a/src/libsyntax/diagnostics/metadata.rs +++ b/src/libsyntax/diagnostics/metadata.rs @@ -14,9 +14,10 @@ //! currently always a crate name. use std::collections::BTreeMap; -use std::path::PathBuf; +use std::env; use std::fs::{remove_file, create_dir_all, File}; use std::io::Write; +use std::path::PathBuf; use std::error::Error; use rustc_serialize::json::as_json; @@ -24,9 +25,6 @@ use syntax_pos::{Span, FileName}; use ext::base::ExtCtxt; use diagnostics::plugin::{ErrorMap, ErrorInfo}; -// Default metadata directory to use for extended error JSON. -const ERROR_METADATA_PREFIX: &'static str = "tmp/extended-errors"; - /// JSON encodable/decodable version of `ErrorInfo`. #[derive(PartialEq, RustcDecodable, RustcEncodable)] pub struct ErrorMetadata { @@ -59,7 +57,10 @@ impl ErrorLocation { /// /// See `output_metadata`. pub fn get_metadata_dir(prefix: &str) -> PathBuf { - PathBuf::from(ERROR_METADATA_PREFIX).join(prefix) + env::var_os("RUSTC_ERROR_METADATA_DST") + .map(PathBuf::from) + .expect("env var `RUSTC_ERROR_METADATA_DST` isn't set") + .join(prefix) } /// Map `name` to a path in the given directory: /.json From 6a600f827b632fb798b9ca52345130748fe86a30 Mon Sep 17 00:00:00 2001 From: Niko Matsakis Date: Tue, 20 Feb 2018 13:24:50 -0500 Subject: [PATCH 2/6] temporarily disable rust-lang/rust#46833 due to rust-lang/rust#48251 --- src/librustc_mir/build/mod.rs | 4 +++- src/test/run-pass/abort-on-c-abi.rs | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_mir/build/mod.rs b/src/librustc_mir/build/mod.rs index 57059cd31a1bc..e20bc0020daf4 100644 --- a/src/librustc_mir/build/mod.rs +++ b/src/librustc_mir/build/mod.rs @@ -372,7 +372,9 @@ fn should_abort_on_panic<'a, 'gcx, 'tcx>(tcx: TyCtxt<'a, 'gcx, 'tcx>, // unwind anyway. Don't stop them. if tcx.has_attr(tcx.hir.local_def_id(fn_id), "unwind") { return false; } - return true; + // FIXME(rust-lang/rust#48251) -- Had to disable abort-on-panic + // for backwards compatibility reasons. + false } /////////////////////////////////////////////////////////////////////////// diff --git a/src/test/run-pass/abort-on-c-abi.rs b/src/test/run-pass/abort-on-c-abi.rs index 63fd934b0d0f4..40c4ec20151bd 100644 --- a/src/test/run-pass/abort-on-c-abi.rs +++ b/src/test/run-pass/abort-on-c-abi.rs @@ -12,6 +12,7 @@ // we never unwind through them. // ignore-emscripten no processes +// ignore-test FIXME rust-lang/rust#48251 -- temporarily disabled use std::{env, panic}; use std::io::prelude::*; From f8e00d0dc221564701ecdbb6dde57e0e9dd12900 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Thu, 22 Feb 2018 16:37:44 -0700 Subject: [PATCH 3/6] Encode linker arguments as UTF-16 on MSVC platforms --- src/librustc_trans/back/link.rs | 14 ++++++++++- .../long-linker-command-lines-cmd-exe/foo.rs | 25 +++++++++++++++---- .../run-make/long-linker-command-lines/foo.rs | 21 +++++++++++++--- 3 files changed, 50 insertions(+), 10 deletions(-) diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 360f85d78f172..abd02e719fa8d 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -776,7 +776,19 @@ fn exec_linker(sess: &Session, cmd: &mut Command, tmpdir: &Path) args.push_str("\n"); } let file = tmpdir.join("linker-arguments"); - fs::write(&file, args.as_bytes())?; + let bytes = if sess.target.target.options.is_like_msvc { + let mut out = vec![]; + // start the stream with a UTF-16 BOM + for c in vec![0xFEFF].into_iter().chain(args.encode_utf16()) { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + args.into_bytes() + }; + fs::write(&file, &bytes)?; cmd2.arg(format!("@{}", file.display())); return cmd2.output(); diff --git a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs b/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs index f9168a82e2259..67d8ad0b67255 100644 --- a/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs +++ b/src/test/run-make/long-linker-command-lines-cmd-exe/foo.rs @@ -36,8 +36,11 @@ fn main() { let ok = tmpdir.join("ok"); let not_ok = tmpdir.join("not_ok"); if env::var("YOU_ARE_A_LINKER").is_ok() { - match env::args().find(|a| a.contains("@")) { - Some(file) => { fs::copy(&file[1..], &ok).unwrap(); } + match env::args_os().find(|a| a.to_string_lossy().contains("@")) { + Some(file) => { + let file = file.to_str().unwrap(); + fs::copy(&file[1..], &ok).unwrap(); + } None => { File::create(¬_ok).unwrap(); } } return @@ -84,11 +87,23 @@ fn main() { continue } - let mut contents = String::new(); - File::open(&ok).unwrap().read_to_string(&mut contents).unwrap(); + let mut contents = Vec::new(); + File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); for j in 0..i { - assert!(contents.contains(&format!("{}{}", lib_name, j))); + let exp = format!("{}{}", lib_name, j); + let exp = if cfg!(target_env = "msvc") { + let mut out = Vec::with_capacity(exp.len() * 2); + for c in exp.encode_utf16() { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + exp.into_bytes() + }; + assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); } break diff --git a/src/test/run-make/long-linker-command-lines/foo.rs b/src/test/run-make/long-linker-command-lines/foo.rs index e6fd6b653667f..2ac240982afc4 100644 --- a/src/test/run-make/long-linker-command-lines/foo.rs +++ b/src/test/run-make/long-linker-command-lines/foo.rs @@ -27,7 +27,8 @@ fn main() { let tmpdir = PathBuf::from(env::var_os("TMPDIR").unwrap()); let ok = tmpdir.join("ok"); if env::var("YOU_ARE_A_LINKER").is_ok() { - if let Some(file) = env::args().find(|a| a.contains("@")) { + if let Some(file) = env::args_os().find(|a| a.to_string_lossy().contains("@")) { + let file = file.to_str().expect("non-utf8 file argument"); fs::copy(&file[1..], &ok).unwrap(); } return @@ -76,11 +77,23 @@ fn main() { continue } - let mut contents = String::new(); - File::open(&ok).unwrap().read_to_string(&mut contents).unwrap(); + let mut contents = Vec::new(); + File::open(&ok).unwrap().read_to_end(&mut contents).unwrap(); for j in 0..i { - assert!(contents.contains(&format!("{}{}", lib_name, j))); + let exp = format!("{}{}", lib_name, j); + let exp = if cfg!(target_env = "msvc") { + let mut out = Vec::with_capacity(exp.len() * 2); + for c in exp.encode_utf16() { + // encode in little endian + out.push(c as u8); + out.push((c >> 8) as u8); + } + out + } else { + exp.into_bytes() + }; + assert!(contents.windows(exp.len()).any(|w| w == &exp[..])); } break From 17a7bae777f00eec2477ae0cdeca86e1ffa9b16c Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Mon, 26 Feb 2018 15:51:56 -0800 Subject: [PATCH 4/6] Update Cargo with a Windows 7 warning More info at rust-lang/cargo#5066 --- src/tools/cargo | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/cargo b/src/tools/cargo index 8c93e08953646..96d8071da2800 160000 --- a/src/tools/cargo +++ b/src/tools/cargo @@ -1 +1 @@ -Subproject commit 8c93e089536467783957fec23b0f2627bb6ce357 +Subproject commit 96d8071da2800d871677d090c31b030d5b9682bc From 3e3f0cc050c7da6fca4a1e7986cd810d9b3175a1 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Thu, 22 Feb 2018 17:15:32 -0700 Subject: [PATCH 5/6] Add release notes for 1.24.1 --- RELEASES.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/RELEASES.md b/RELEASES.md index 3077d31c282b1..e1f4a566464b5 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -1,3 +1,16 @@ +Version 1.24.1 (2018-03-01) +========================== + + - [Do not abort when unwinding through FFI][48251] + - [Emit UTF-16 files for linker arguments on Windows][48318] + - [Make the error index generator work again][48308] + - [Cargo will warn on Windows 7 if an update is needed][cargo/5069]. + +[48251]: https://github.com/rust-lang/rust/issues/48251 +[48308]: https://github.com/rust-lang/rust/issues/48308 +[48318]: https://github.com/rust-lang/rust/issues/48318 +[cargo/5069]: https://github.com/rust-lang/cargo/pull/5069 + Version 1.24.0 (2018-02-15) ========================== From 9853d20e4d054207c54b62e3fb700106652bcac9 Mon Sep 17 00:00:00 2001 From: Mark Simulacrum Date: Thu, 22 Feb 2018 16:48:46 -0700 Subject: [PATCH 6/6] Bump to 1.24.1 --- src/bootstrap/channel.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bootstrap/channel.rs b/src/bootstrap/channel.rs index 046ae7e767819..d675834bd62ab 100644 --- a/src/bootstrap/channel.rs +++ b/src/bootstrap/channel.rs @@ -24,7 +24,7 @@ use Build; use config::Config; // The version number -pub const CFG_RELEASE_NUM: &str = "1.24.0"; +pub const CFG_RELEASE_NUM: &str = "1.24.1"; pub struct GitInfo { inner: Option,