about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/lib.rs30
-rw-r--r--compiler/rustc_codegen_llvm/src/llvm/ffi.rs4
2 files changed, 26 insertions, 8 deletions
diff --git a/compiler/rustc_codegen_llvm/src/lib.rs b/compiler/rustc_codegen_llvm/src/lib.rs
index 713c22ebfeb..c03b2188824 100644
--- a/compiler/rustc_codegen_llvm/src/lib.rs
+++ b/compiler/rustc_codegen_llvm/src/lib.rs
@@ -177,14 +177,32 @@ impl WriteBackendMethods for LlvmCodegenBackend {
     type ThinData = back::lto::ThinData;
     type ThinBuffer = back::lto::ThinBuffer;
     fn print_pass_timings(&self) {
-        unsafe {
-            llvm::LLVMRustPrintPassTimings();
-        }
+        let msg = unsafe {
+            let cstr = llvm::LLVMRustPrintPassTimings();
+            if cstr.is_null() {
+                "failed to get pass timings".into()
+            } else {
+                let timings = CStr::from_ptr(cstr).to_bytes();
+                let timings = String::from_utf8_lossy(timings).to_string();
+                libc::free(cstr as *mut _);
+                timings
+            }
+        };
+        println!("{}", msg);
     }
     fn print_statistics(&self) {
-        unsafe {
-            llvm::LLVMRustPrintStatistics();
-        }
+        let msg = unsafe {
+            let cstr = llvm::LLVMRustPrintStatistics();
+            if cstr.is_null() {
+                "failed to get stats".into()
+            } else {
+                let stats = CStr::from_ptr(cstr).to_bytes();
+                let stats = String::from_utf8_lossy(stats).to_string();
+                libc::free(cstr as *mut _);
+                stats
+            }
+        };
+        println!("{}", msg);
     }
     fn run_link(
         cgcx: &CodegenContext<Self>,
diff --git a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
index 3eb04555749..7cc79d859a3 100644
--- a/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
+++ b/compiler/rustc_codegen_llvm/src/llvm/ffi.rs
@@ -1868,10 +1868,10 @@ extern "C" {
     pub fn LLVMRustGetLastError() -> *const c_char;
 
     /// Print the pass timings since static dtors aren't picking them up.
-    pub fn LLVMRustPrintPassTimings();
+    pub fn LLVMRustPrintPassTimings() -> *const c_char;
 
     /// Print the statistics since static dtors aren't picking them up.
-    pub fn LLVMRustPrintStatistics();
+    pub fn LLVMRustPrintStatistics() -> *const c_char;
 
     pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;