1
Fork 0

change expect() to unwrap_or_else() and update msg

This commit is contained in:
James Dietz 2023-04-30 09:47:29 -04:00
parent 9aa596a014
commit cb74cd524f
2 changed files with 7 additions and 3 deletions

View file

@ -331,7 +331,7 @@ pub(crate) fn print(req: PrintRequest, sess: &Session) {
match req { match req {
PrintRequest::TargetCPUs => { PrintRequest::TargetCPUs => {
let cpu_cstring = CString::new(handle_native(sess.target.cpu.as_ref())) let cpu_cstring = CString::new(handle_native(sess.target.cpu.as_ref()))
.expect("failed to convert to cstring"); .unwrap_or_else(|e| bug!("failed to convert to cstring: {}", e));
unsafe { llvm::LLVMRustPrintTargetCPUs(tm, cpu_cstring.as_ptr()) }; unsafe { llvm::LLVMRustPrintTargetCPUs(tm, cpu_cstring.as_ptr()) };
} }
PrintRequest::TargetFeatures => print_target_features(sess, tm), PrintRequest::TargetFeatures => print_target_features(sess, tm),

View file

@ -324,10 +324,14 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM, const char* Tar
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data()); MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
} }
for (auto &CPU : CPUTable) { for (auto &CPU : CPUTable) {
printf(" %-*s", MaxCPULen, CPU.Key);
// Compare cpu against current target to label the default // Compare cpu against current target to label the default
if (strcmp(CPU.Key, TargetCPU) == 0) { if (strcmp(CPU.Key, TargetCPU) == 0) {
printf(" - this is the default target cpu for the current target"); printf(" %-*s - This is the default target CPU"
" for the current build target (currently %s).",
MaxCPULen, CPU.Key, Target->getTargetTriple().str().c_str());
}
else {
printf(" %-*s", MaxCPULen, CPU.Key);
} }
printf("\n"); printf("\n");
} }