提交 987de298 编写于 作者: B bors

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.
......@@ -26,7 +26,7 @@
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());
}
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册