We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent cb74cd5 commit f239cd6Copy full SHA for f239cd6
compiler/rustc_codegen_llvm/src/llvm_util.rs
@@ -330,6 +330,9 @@ pub(crate) fn print(req: PrintRequest, sess: &Session) {
330
let tm = create_informational_target_machine(sess);
331
match req {
332
PrintRequest::TargetCPUs => {
333
+ // SAFETY generate a C compatible string from a byte slice to pass
334
+ // the target CPU name into LLVM, the lifetime of the reference is
335
+ // at least as long as the C function
336
let cpu_cstring = CString::new(handle_native(sess.target.cpu.as_ref()))
337
.unwrap_or_else(|e| bug!("failed to convert to cstring: {}", e));
338
unsafe { llvm::LLVMRustPrintTargetCPUs(tm, cpu_cstring.as_ptr()) };
0 commit comments