Skip to content

rustc: Fail if LLVM is passed an invalid triple #18411

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 31, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 13 additions & 7 deletions src/librustc/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,12 +226,10 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
}
};

unsafe {
sess.targ_cfg
.target_strs
.target_triple
.as_slice()
.with_c_str(|t| {
let triple = sess.targ_cfg.target_strs.target_triple.as_slice();

let tm = unsafe {
triple.with_c_str(|t| {
sess.opts.cg.target_cpu.as_slice().with_c_str(|cpu| {
target_feature(sess).with_c_str(|features| {
llvm::LLVMRustCreateTargetMachine(
Expand All @@ -249,7 +247,15 @@ fn create_target_machine(sess: &Session) -> TargetMachineRef {
})
})
})
}
};

if tm.is_null() {
llvm_err(sess.diagnostic().handler(),
format!("Could not create LLVM TargetMachine for triple: {}",
triple).to_string());
} else {
return tm;
};
}


Expand Down