@@ -15,6 +15,7 @@ use llvm;
1515use llvm:: archive_ro:: ArchiveRO ;
1616use llvm:: { ModuleRef , TargetMachineRef , True , False } ;
1717use rustc:: util:: common:: time;
18+ use rustc:: util:: common:: path2cstr;
1819use back:: write:: { ModuleConfig , with_llvm_pmb} ;
1920
2021use libc;
@@ -24,7 +25,9 @@ use std::ffi::CString;
2425
2526pub fn run ( sess : & session:: Session , llmod : ModuleRef ,
2627 tm : TargetMachineRef , reachable : & [ String ] ,
27- config : & ModuleConfig ) {
28+ config : & ModuleConfig ,
29+ name_extra : & str ,
30+ output_names : & config:: OutputFilenames ) {
2831 if sess. opts . cg . prefer_dynamic {
2932 sess. err ( "cannot prefer dynamic linking when performing LTO" ) ;
3033 sess. note ( "only 'staticlib' and 'bin' outputs are supported with LTO" ) ;
@@ -124,6 +127,14 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
124127 }
125128 }
126129
130+ if sess. opts . cg . save_temps {
131+ let path = output_names. with_extension ( & format ! ( "{}.no-opt.lto.bc" , name_extra) ) ;
132+ let cstr = path2cstr ( & path) ;
133+ unsafe {
134+ llvm:: LLVMWriteBitcodeToFile ( llmod, cstr. as_ptr ( ) ) ;
135+ }
136+ }
137+
127138 // Now we have one massive module inside of llmod. Time to run the
128139 // LTO-specific optimization passes that LLVM provides.
129140 //
0 commit comments