]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_codegen_llvm/src/llvm_util.rs
Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`
[rust.git] / compiler / rustc_codegen_llvm / src / llvm_util.rs
index 79a261244d3ffddeeb8bd6617414d229e383dfca..e4935ac431c8d8bcee2fbb7890377b0b450e5276 100644 (file)
@@ -4,6 +4,7 @@
 use libloading::Library;
 use rustc_codegen_ssa::target_features::supported_target_features;
 use rustc_data_structures::fx::FxHashSet;
+use rustc_fs_util::path_to_c_string;
 use rustc_middle::bug;
 use rustc_session::config::PrintRequest;
 use rustc_session::Session;
@@ -13,6 +14,7 @@
 use tracing::debug;
 
 use std::mem;
+use std::path::Path;
 use std::ptr;
 use std::slice;
 use std::str;
@@ -134,9 +136,9 @@ fn llvm_arg_to_arg_name(full_arg: &str) -> &str {
     llvm::LLVMRustSetLLVMOptions(llvm_args.len() as c_int, llvm_args.as_ptr());
 }
 
-pub fn time_trace_profiler_finish(file_name: &str) {
+pub fn time_trace_profiler_finish(file_name: &Path) {
     unsafe {
-        let file_name = CString::new(file_name).unwrap();
+        let file_name = path_to_c_string(file_name);
         llvm::LLVMTimeTraceProfilerFinish(file_name.as_ptr());
     }
 }