1
- import libc:: { c_int, c_uint} ;
1
+ import libc:: { c_int, c_uint, c_char } ;
2
2
import driver:: session;
3
3
import session:: session;
4
4
import lib:: llvm:: llvm;
@@ -32,6 +32,21 @@ fn llvm_err(sess: session, msg: ~str) -> ! unsafe {
32
32
} else { sess. fatal ( msg + ~": " + str::unsafe::from_c_str(cstr)); }
33
33
}
34
34
35
+ fn WriteOutputFile(sess:session,
36
+ PM: lib::llvm::PassManagerRef, M: ModuleRef,
37
+ Triple: *c_char,
38
+ // FIXME: When #2334 is fixed, change
39
+ // c_uint to FileType
40
+ Output: *c_char, FileType: c_uint,
41
+ OptLevel: c_int,
42
+ EnableSegmentedStacks: bool) {
43
+ let result = llvm::LLVMRustWriteOutputFile(
44
+ PM, M, Triple, Output, FileType, OptLevel, EnableSegmentedStacks);
45
+ if (!result) {
46
+ llvm_err(sess, " Could not write output") ;
47
+ }
48
+ }
49
+
35
50
mod write {
36
51
fn is_object_or_assembly_or_exe ( ot : output_type ) -> bool {
37
52
if ot == output_type_assembly || ot == output_type_object ||
@@ -161,7 +176,8 @@ mod write {
161
176
sess. targ_cfg . target_strs . target_triple ,
162
177
|buf_t| {
163
178
str:: as_c_str ( output, |buf_o| {
164
- llvm:: LLVMRustWriteOutputFile (
179
+ WriteOutputFile (
180
+ sess,
165
181
pm. llpm ,
166
182
llmod,
167
183
buf_t,
@@ -182,7 +198,8 @@ mod write {
182
198
sess. targ_cfg . target_strs . target_triple ,
183
199
|buf_t| {
184
200
str:: as_c_str ( output, |buf_o| {
185
- llvm:: LLVMRustWriteOutputFile (
201
+ WriteOutputFile (
202
+ sess,
186
203
pm. llpm ,
187
204
llmod,
188
205
buf_t,
@@ -201,7 +218,8 @@ mod write {
201
218
sess. targ_cfg . target_strs . target_triple ,
202
219
|buf_t| {
203
220
str:: as_c_str ( output, |buf_o| {
204
- llvm:: LLVMRustWriteOutputFile (
221
+ WriteOutputFile (
222
+ sess,
205
223
pm. llpm ,
206
224
llmod,
207
225
buf_t,
0 commit comments