@@ -61,23 +61,32 @@ pub fn llvm_err(sess: Session, msg: ~str) -> ! {
61
61
62
62
pub fn WriteOutputFile(sess: Session,
63
63
PM: lib::llvm::PassManagerRef, M: ModuleRef,
64
- Triple: *c_char,
64
+ Triple: &str,
65
+ Feature: &str,
66
+ Output: &str,
65
67
// FIXME: When #2334 is fixed, change
66
68
// c_uint to FileType
67
- Output: *c_char, FileType: c_uint,
69
+ FileType: c_uint,
68
70
OptLevel: c_int,
69
71
EnableSegmentedStacks: bool) {
70
72
unsafe {
71
- let result = llvm::LLVMRustWriteOutputFile(
72
- PM,
73
- M,
74
- Triple,
75
- Output,
76
- FileType,
77
- OptLevel,
78
- EnableSegmentedStacks);
79
- if (!result) {
80
- llvm_err(sess, ~" Could not write output") ;
73
+ do str::as_c_str(Triple) |Triple| {
74
+ do str::as_c_str(Feature) |Feature| {
75
+ do str::as_c_str(Output) |Output| {
76
+ let result = llvm::LLVMRustWriteOutputFile(
77
+ PM,
78
+ M,
79
+ Triple,
80
+ Feature,
81
+ Output,
82
+ FileType,
83
+ OptLevel,
84
+ EnableSegmentedStacks);
85
+ if (!result) {
86
+ llvm_err(sess, ~" Could not write output") ;
87
+ }
88
+ }
89
+ }
81
90
}
82
91
}
83
92
}
@@ -310,66 +319,49 @@ pub mod write {
310
319
llvm:: LLVMWriteBitcodeToFile ( llmod, buf)
311
320
} ) ;
312
321
pm = mk_pass_manager ( ) ;
313
- // Save the assembly file if -S is used
314
322
323
+ // Save the assembly file if -S is used
315
324
if output_type == output_type_assembly {
316
- let _: ( ) = str:: as_c_str (
325
+ WriteOutputFile (
326
+ sess,
327
+ pm. llpm ,
328
+ llmod,
317
329
sess. targ_cfg . target_strs . target_triple ,
318
- |buf_t| {
319
- str:: as_c_str ( output. to_str ( ) , |buf_o| {
320
- WriteOutputFile (
321
- sess,
322
- pm. llpm ,
323
- llmod,
324
- buf_t,
325
- buf_o,
326
- lib:: llvm:: AssemblyFile as c_uint ,
327
- CodeGenOptLevel ,
328
- true )
329
- } )
330
- } ) ;
330
+ opts. target_feature ,
331
+ output. to_str ( ) ,
332
+ lib:: llvm:: AssemblyFile as c_uint ,
333
+ CodeGenOptLevel ,
334
+ true ) ;
331
335
}
332
336
333
-
334
337
// Save the object file for -c or --save-temps alone
335
338
// This .o is needed when an exe is built
336
339
if output_type == output_type_object ||
337
340
output_type == output_type_exe {
338
- let _: ( ) = str:: as_c_str (
341
+ WriteOutputFile (
342
+ sess,
343
+ pm. llpm ,
344
+ llmod,
339
345
sess. targ_cfg . target_strs . target_triple ,
340
- |buf_t| {
341
- str:: as_c_str ( output. to_str ( ) , |buf_o| {
342
- WriteOutputFile (
343
- sess,
344
- pm. llpm ,
345
- llmod,
346
- buf_t,
347
- buf_o,
348
- lib:: llvm:: ObjectFile as c_uint ,
349
- CodeGenOptLevel ,
350
- true )
351
- } )
352
- } ) ;
346
+ opts. target_feature ,
347
+ output. to_str ( ) ,
348
+ lib:: llvm:: ObjectFile as c_uint ,
349
+ CodeGenOptLevel ,
350
+ true ) ;
353
351
}
354
352
} else {
355
353
// If we aren't saving temps then just output the file
356
354
// type corresponding to the '-c' or '-S' flag used
357
-
358
- let _: ( ) = str:: as_c_str (
355
+ WriteOutputFile (
356
+ sess,
357
+ pm. llpm ,
358
+ llmod,
359
359
sess. targ_cfg . target_strs . target_triple ,
360
- |buf_t| {
361
- str:: as_c_str ( output. to_str ( ) , |buf_o| {
362
- WriteOutputFile (
363
- sess,
364
- pm. llpm ,
365
- llmod,
366
- buf_t,
367
- buf_o,
368
- FileType as c_uint ,
369
- CodeGenOptLevel ,
370
- true )
371
- } )
372
- } ) ;
360
+ opts. target_feature ,
361
+ output. to_str ( ) ,
362
+ FileType as c_uint ,
363
+ CodeGenOptLevel ,
364
+ true ) ;
373
365
}
374
366
// Clean up and return
375
367
0 commit comments