@@ -31,7 +31,9 @@ use rustc_incremental::{self, IncrementalHashesMap};
31
31
use rustc_resolve:: { MakeGlobMap , Resolver } ;
32
32
use rustc_metadata:: creader:: CrateLoader ;
33
33
use rustc_metadata:: cstore:: { self , CStore } ;
34
+ #[ cfg( feature="llvm" ) ]
34
35
use rustc_trans:: back:: { link, write} ;
36
+ #[ cfg( feature="llvm" ) ]
35
37
use rustc_trans as trans;
36
38
use rustc_typeck as typeck;
37
39
use rustc_privacy;
@@ -113,7 +115,8 @@ pub fn compile_input(sess: &Session,
113
115
} ;
114
116
115
117
let outputs = build_output_filenames ( input, outdir, output, & krate. attrs , sess) ;
116
- let crate_name = link:: find_crate_name ( Some ( sess) , & krate. attrs , input) ;
118
+ let crate_name =
119
+ :: rustc_trans_utils:: link:: find_crate_name ( Some ( sess) , & krate. attrs , input) ;
117
120
let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = {
118
121
phase_2_configure_and_expand (
119
122
sess, & cstore, krate, registry, & crate_name, addl_plugins, control. make_glob_map ,
@@ -206,8 +209,12 @@ pub fn compile_input(sess: &Session,
206
209
println ! ( "Pre-trans" ) ;
207
210
tcx. print_debug_stats ( ) ;
208
211
}
212
+
213
+ #[ cfg( feature="llvm" ) ]
209
214
let trans = phase_4_translate_to_llvm ( tcx, analysis, incremental_hashes_map,
210
215
& outputs) ;
216
+ #[ cfg( not( feature="llvm" ) ) ]
217
+ let trans = { panic ! ( "LLVM not supported by this rustc." ) ; ( ) } ;
211
218
212
219
if log_enabled ! ( :: log:: LogLevel :: Info ) {
213
220
println ! ( "Post-trans" ) ;
@@ -225,34 +232,42 @@ pub fn compile_input(sess: &Session,
225
232
} ) ??
226
233
} ;
227
234
228
- if sess. opts . debugging_opts . print_type_sizes {
229
- sess. code_stats . borrow ( ) . print_type_sizes ( ) ;
230
- }
235
+ #[ cfg( not( feature="llvm" ) ) ]
236
+ unreachable ! ( ) ;
231
237
232
- let ( phase5_result, trans) = phase_5_run_llvm_passes ( sess, trans) ;
238
+ #[ cfg( feature="llvm" ) ]
239
+ {
240
+ if sess. opts . debugging_opts . print_type_sizes {
241
+ sess. code_stats . borrow ( ) . print_type_sizes ( ) ;
242
+ }
233
243
234
- controller_entry_point ! ( after_llvm,
235
- sess,
236
- CompileState :: state_after_llvm( input, sess, outdir, output, & trans) ,
237
- phase5_result) ;
238
- phase5_result?;
244
+ let ( phase5_result, trans) = phase_5_run_llvm_passes ( sess, trans) ;
239
245
240
- phase_6_link_output ( sess, & trans, & outputs) ;
246
+ controller_entry_point ! ( after_llvm,
247
+ sess,
248
+ CompileState :: state_after_llvm( input, sess, outdir, output, & trans) ,
249
+ phase5_result) ;
250
+ phase5_result?;
241
251
242
- // Now that we won't touch anything in the incremental compilation directory
243
- // any more, we can finalize it (which involves renaming it)
244
- rustc_incremental:: finalize_session_directory ( sess, trans. link . crate_hash ) ;
252
+ phase_6_link_output ( sess, & trans, & outputs) ;
245
253
246
- if sess. opts . debugging_opts . perf_stats {
247
- sess. print_perf_stats ( ) ;
248
- }
254
+ // Now that we won't touch anything in the incremental compilation directory
255
+ // any more, we can finalize it (which involves renaming it)
256
+ rustc_incremental:: finalize_session_directory ( sess, trans. link . crate_hash ) ;
257
+
258
+ if sess. opts . debugging_opts . perf_stats {
259
+ sess. print_perf_stats ( ) ;
260
+ }
249
261
250
- controller_entry_point ! ( compilation_done,
251
- sess,
252
- CompileState :: state_when_compilation_done( input, sess, outdir, output) ,
253
- Ok ( ( ) ) ) ;
262
+ controller_entry_point ! (
263
+ compilation_done,
264
+ sess,
265
+ CompileState :: state_when_compilation_done( input, sess, outdir, output) ,
266
+ Ok ( ( ) )
267
+ ) ;
254
268
255
- Ok ( ( ) )
269
+ Ok ( ( ) )
270
+ }
256
271
}
257
272
258
273
fn keep_hygiene_data ( sess : & Session ) -> bool {
@@ -360,6 +375,7 @@ pub struct CompileState<'a, 'tcx: 'a> {
360
375
pub resolutions : Option < & ' a Resolutions > ,
361
376
pub analysis : Option < & ' a ty:: CrateAnalysis > ,
362
377
pub tcx : Option < TyCtxt < ' a , ' tcx , ' tcx > > ,
378
+ #[ cfg( feature="llvm" ) ]
363
379
pub trans : Option < & ' a trans:: CrateTranslation > ,
364
380
}
365
381
@@ -386,6 +402,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
386
402
resolutions : None ,
387
403
analysis : None ,
388
404
tcx : None ,
405
+ #[ cfg( feature="llvm" ) ]
389
406
trans : None ,
390
407
}
391
408
}
@@ -474,7 +491,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
474
491
}
475
492
}
476
493
477
-
494
+ # [ cfg ( feature= "llvm" ) ]
478
495
fn state_after_llvm ( input : & ' a Input ,
479
496
session : & ' tcx Session ,
480
497
out_dir : & ' a Option < PathBuf > ,
@@ -906,6 +923,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
906
923
mir:: provide ( & mut local_providers) ;
907
924
reachable:: provide ( & mut local_providers) ;
908
925
rustc_privacy:: provide ( & mut local_providers) ;
926
+ #[ cfg( feature="llvm" ) ]
909
927
trans:: provide ( & mut local_providers) ;
910
928
typeck:: provide ( & mut local_providers) ;
911
929
ty:: provide ( & mut local_providers) ;
@@ -918,6 +936,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
918
936
919
937
let mut extern_providers = ty:: maps:: Providers :: default ( ) ;
920
938
cstore:: provide ( & mut extern_providers) ;
939
+ #[ cfg( feature="llvm" ) ]
921
940
trans:: provide ( & mut extern_providers) ;
922
941
ty:: provide_extern ( & mut extern_providers) ;
923
942
traits:: provide_extern ( & mut extern_providers) ;
@@ -1063,6 +1082,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
1063
1082
1064
1083
/// Run the translation phase to LLVM, after which the AST and analysis can
1065
1084
/// be discarded.
1085
+ #[ cfg( feature="llvm" ) ]
1066
1086
pub fn phase_4_translate_to_llvm < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1067
1087
analysis : ty:: CrateAnalysis ,
1068
1088
incremental_hashes_map : IncrementalHashesMap ,
@@ -1084,6 +1104,7 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1084
1104
1085
1105
/// Run LLVM itself, producing a bitcode file, assembly file or object file
1086
1106
/// as a side effect.
1107
+ #[ cfg( feature="llvm" ) ]
1087
1108
pub fn phase_5_run_llvm_passes ( sess : & Session ,
1088
1109
trans : write:: OngoingCrateTranslation )
1089
1110
-> ( CompileResult , trans:: CrateTranslation ) {
@@ -1102,6 +1123,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
1102
1123
1103
1124
/// Run the linker on any artifacts that resulted from the LLVM run.
1104
1125
/// This should produce either a finished executable or library.
1126
+ #[ cfg( feature="llvm" ) ]
1105
1127
pub fn phase_6_link_output ( sess : & Session ,
1106
1128
trans : & trans:: CrateTranslation ,
1107
1129
outputs : & OutputFilenames ) {
@@ -1123,7 +1145,7 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) {
1123
1145
match * output_type {
1124
1146
OutputType :: Exe => {
1125
1147
for output in sess. crate_types . borrow ( ) . iter ( ) {
1126
- let p = link:: filename_for_input ( sess, * output, crate_name, outputs) ;
1148
+ let p = :: rustc_trans_utils :: link:: filename_for_input ( sess, * output, crate_name, outputs) ;
1127
1149
out_filenames. push ( p) ;
1128
1150
}
1129
1151
}
@@ -1233,15 +1255,15 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
1233
1255
if base. is_empty ( ) {
1234
1256
base. extend ( attr_types) ;
1235
1257
if base. is_empty ( ) {
1236
- base. push ( link:: default_output_for_target ( session) ) ;
1258
+ base. push ( :: rustc_trans_utils :: link:: default_output_for_target ( session) ) ;
1237
1259
}
1238
1260
base. sort ( ) ;
1239
1261
base. dedup ( ) ;
1240
1262
}
1241
1263
1242
1264
base. into_iter ( )
1243
1265
. filter ( |crate_type| {
1244
- let res = !link:: invalid_output_for_target ( session, * crate_type) ;
1266
+ let res = !rustc_trans_utils :: link:: invalid_output_for_target ( session, * crate_type) ;
1245
1267
1246
1268
if !res {
1247
1269
session. warn ( & format ! ( "dropping unsupported crate type `{}` for target `{}`" ,
0 commit comments