diff options
| author | bors <bors@rust-lang.org> | 2014-03-06 12:37:01 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-03-06 12:37:01 -0800 |
| commit | 987de2986539fe01e86aa711b43f05e94becba89 (patch) | |
| tree | 9fce3c6784bd847827cbb2f4baafff65a7433725 | |
| parent | 1eb3f63d9d6b2239a6907b8dec5ee8bb371e3e0e (diff) | |
| parent | f6afd40fc11a45e3c9b86ea101362a1b579d9283 (diff) | |
auto merge of #12732 : klutzy/rust/this-is-windows, r=alexcrichton
On Windows, `LLVMRustGetLastError()` may return non-utf8 mojibake string if system uses non-English locale. It caused ICE when llvm fails. This patch doesn't fix the real problem, but just make rustc not die.
| -rw-r--r-- | src/librustc/back/link.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index 09e5b99fc23..0b7450e5265 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -26,7 +26,7 @@ use util::common::time; use util::ppaux; use util::sha2::{Digest, Sha256}; -use std::c_str::ToCStr; +use std::c_str::{ToCStr, CString}; use std::char; use std::os::consts::{macos, freebsd, linux, android, win32}; use std::ptr; @@ -61,7 +61,9 @@ pub fn llvm_err(sess: Session, msg: ~str) -> ! { if cstr == ptr::null() { sess.fatal(msg); } else { - sess.fatal(msg + ": " + str::raw::from_c_str(cstr)); + let err = CString::new(cstr, false); + let err = str::from_utf8_lossy(err.as_bytes()); + sess.fatal(msg + ": " + err.as_slice()); } } } |
