Skip to content

Commit 987de29

Browse files
committed
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.
2 parents 1eb3f63 + f6afd40 commit 987de29

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/librustc/back/link.rs

+4-2
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use util::common::time;
2626
use util::ppaux;
2727
use util::sha2::{Digest, Sha256};
2828

29-
use std::c_str::ToCStr;
29+
use std::c_str::{ToCStr, CString};
3030
use std::char;
3131
use std::os::consts::{macos, freebsd, linux, android, win32};
3232
use std::ptr;
@@ -61,7 +61,9 @@ pub fn llvm_err(sess: Session, msg: ~str) -> ! {
6161
if cstr == ptr::null() {
6262
sess.fatal(msg);
6363
} else {
64-
sess.fatal(msg + ": " + str::raw::from_c_str(cstr));
64+
let err = CString::new(cstr, false);
65+
let err = str::from_utf8_lossy(err.as_bytes());
66+
sess.fatal(msg + ": " + err.as_slice());
6567
}
6668
}
6769
}

0 commit comments

Comments
 (0)