diff options
| author | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-12-13 00:00:00 +0000 |
|---|---|---|
| committer | Tomasz Miąsko <tomasz.miasko@gmail.com> | 2021-12-13 00:00:00 +0000 |
| commit | 3f2a1c9c1726d4d93e3433303262e44faa5910e9 (patch) | |
| tree | 6cbedd77e4dec8a5c56177afe9ddfa7509bab834 /compiler/rustc_codegen_llvm/src/llvm_util.rs | |
| parent | 06a6674a7de1ef7af00b0fcdfa0d77e6c3023a27 (diff) | |
| download | rust-3f2a1c9c1726d4d93e3433303262e44faa5910e9.tar.gz rust-3f2a1c9c1726d4d93e3433303262e44faa5910e9.zip | |
Use `OutputFilenames` to generate output file for `-Zllvm-time-trace`
The resulting profile will include the crate name and will be stored in the `--out-dir` directory. This implementation makes it convenient to use LLVM time trace together with cargo, in the contrast to the previous implementation which would overwrite profiles or store them in `.cargo/registry/..`.
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/llvm_util.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/llvm_util.rs | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/llvm_util.rs b/compiler/rustc_codegen_llvm/src/llvm_util.rs index 79a261244d3..e4935ac431c 100644 --- a/compiler/rustc_codegen_llvm/src/llvm_util.rs +++ b/compiler/rustc_codegen_llvm/src/llvm_util.rs @@ -4,6 +4,7 @@ use libc::c_int; 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 std::ffi::{CStr, CString}; use tracing::debug; use std::mem; +use std::path::Path; use std::ptr; use std::slice; use std::str; @@ -134,9 +136,9 @@ unsafe fn configure_llvm(sess: &Session) { 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()); } } |
