@@ -15,6 +15,7 @@ use llvm;
15
15
use llvm:: archive_ro:: ArchiveRO ;
16
16
use llvm:: { ModuleRef , TargetMachineRef , True , False } ;
17
17
use rustc:: util:: common:: time;
18
+ use rustc:: util:: common:: path2cstr;
18
19
use back:: write:: { ModuleConfig , with_llvm_pmb} ;
19
20
20
21
use libc;
@@ -24,7 +25,9 @@ use std::ffi::CString;
24
25
25
26
pub fn run ( sess : & session:: Session , llmod : ModuleRef ,
26
27
tm : TargetMachineRef , reachable : & [ String ] ,
27
- config : & ModuleConfig ) {
28
+ config : & ModuleConfig ,
29
+ name_extra : & str ,
30
+ output_names : & config:: OutputFilenames ) {
28
31
if sess. opts . cg . prefer_dynamic {
29
32
sess. err ( "cannot prefer dynamic linking when performing LTO" ) ;
30
33
sess. note ( "only 'staticlib' and 'bin' outputs are supported with LTO" ) ;
@@ -124,6 +127,14 @@ pub fn run(sess: &session::Session, llmod: ModuleRef,
124
127
}
125
128
}
126
129
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
+
127
138
// Now we have one massive module inside of llmod. Time to run the
128
139
// LTO-specific optimization passes that LLVM provides.
129
140
//
0 commit comments