@@ -31,7 +31,9 @@ use rustc_incremental::{self, IncrementalHashesMap};
3131use rustc_resolve:: { MakeGlobMap , Resolver } ;
3232use rustc_metadata:: creader:: CrateLoader ;
3333use rustc_metadata:: cstore:: { self , CStore } ;
34+ #[ cfg( feature="llvm" ) ]
3435use rustc_trans:: back:: { link, write} ;
36+ #[ cfg( feature="llvm" ) ]
3537use rustc_trans as trans;
3638use rustc_typeck as typeck;
3739use rustc_privacy;
@@ -113,7 +115,8 @@ pub fn compile_input(sess: &Session,
113115 } ;
114116
115117 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) ;
117120 let ExpansionResult { expanded_crate, defs, analysis, resolutions, mut hir_forest } = {
118121 phase_2_configure_and_expand (
119122 sess, & cstore, krate, registry, & crate_name, addl_plugins, control. make_glob_map ,
@@ -206,8 +209,12 @@ pub fn compile_input(sess: &Session,
206209 println ! ( "Pre-trans" ) ;
207210 tcx. print_debug_stats ( ) ;
208211 }
212+
213+ #[ cfg( feature="llvm" ) ]
209214 let trans = phase_4_translate_to_llvm ( tcx, analysis, incremental_hashes_map,
210215 & outputs) ;
216+ #[ cfg( not( feature="llvm" ) ) ]
217+ let trans = { panic ! ( "LLVM not supported by this rustc." ) ; ( ) } ;
211218
212219 if log_enabled ! ( :: log:: LogLevel :: Info ) {
213220 println ! ( "Post-trans" ) ;
@@ -225,34 +232,42 @@ pub fn compile_input(sess: &Session,
225232 } ) ??
226233 } ;
227234
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 ! ( ) ;
231237
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+ }
233243
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) ;
239245
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?;
241251
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) ;
245253
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+ }
249261
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+ ) ;
254268
255- Ok ( ( ) )
269+ Ok ( ( ) )
270+ }
256271}
257272
258273fn keep_hygiene_data ( sess : & Session ) -> bool {
@@ -360,6 +375,7 @@ pub struct CompileState<'a, 'tcx: 'a> {
360375 pub resolutions : Option < & ' a Resolutions > ,
361376 pub analysis : Option < & ' a ty:: CrateAnalysis > ,
362377 pub tcx : Option < TyCtxt < ' a , ' tcx , ' tcx > > ,
378+ #[ cfg( feature="llvm" ) ]
363379 pub trans : Option < & ' a trans:: CrateTranslation > ,
364380}
365381
@@ -386,6 +402,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
386402 resolutions : None ,
387403 analysis : None ,
388404 tcx : None ,
405+ #[ cfg( feature="llvm" ) ]
389406 trans : None ,
390407 }
391408 }
@@ -474,7 +491,7 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
474491 }
475492 }
476493
477-
494+ # [ cfg ( feature= "llvm" ) ]
478495 fn state_after_llvm ( input : & ' a Input ,
479496 session : & ' tcx Session ,
480497 out_dir : & ' a Option < PathBuf > ,
@@ -906,6 +923,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
906923 mir:: provide ( & mut local_providers) ;
907924 reachable:: provide ( & mut local_providers) ;
908925 rustc_privacy:: provide ( & mut local_providers) ;
926+ #[ cfg( feature="llvm" ) ]
909927 trans:: provide ( & mut local_providers) ;
910928 typeck:: provide ( & mut local_providers) ;
911929 ty:: provide ( & mut local_providers) ;
@@ -918,6 +936,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
918936
919937 let mut extern_providers = ty:: maps:: Providers :: default ( ) ;
920938 cstore:: provide ( & mut extern_providers) ;
939+ #[ cfg( feature="llvm" ) ]
921940 trans:: provide ( & mut extern_providers) ;
922941 ty:: provide_extern ( & mut extern_providers) ;
923942 traits:: provide_extern ( & mut extern_providers) ;
@@ -1063,6 +1082,7 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
10631082
10641083/// Run the translation phase to LLVM, after which the AST and analysis can
10651084/// be discarded.
1085+ #[ cfg( feature="llvm" ) ]
10661086pub fn phase_4_translate_to_llvm < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
10671087 analysis : ty:: CrateAnalysis ,
10681088 incremental_hashes_map : IncrementalHashesMap ,
@@ -1084,6 +1104,7 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
10841104
10851105/// Run LLVM itself, producing a bitcode file, assembly file or object file
10861106/// as a side effect.
1107+ #[ cfg( feature="llvm" ) ]
10871108pub fn phase_5_run_llvm_passes ( sess : & Session ,
10881109 trans : write:: OngoingCrateTranslation )
10891110 -> ( CompileResult , trans:: CrateTranslation ) {
@@ -1102,6 +1123,7 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
11021123
11031124/// Run the linker on any artifacts that resulted from the LLVM run.
11041125/// This should produce either a finished executable or library.
1126+ #[ cfg( feature="llvm" ) ]
11051127pub fn phase_6_link_output ( sess : & Session ,
11061128 trans : & trans:: CrateTranslation ,
11071129 outputs : & OutputFilenames ) {
@@ -1123,7 +1145,7 @@ fn write_out_deps(sess: &Session, outputs: &OutputFilenames, crate_name: &str) {
11231145 match * output_type {
11241146 OutputType :: Exe => {
11251147 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) ;
11271149 out_filenames. push ( p) ;
11281150 }
11291151 }
@@ -1233,15 +1255,15 @@ pub fn collect_crate_types(session: &Session, attrs: &[ast::Attribute]) -> Vec<c
12331255 if base. is_empty ( ) {
12341256 base. extend ( attr_types) ;
12351257 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) ) ;
12371259 }
12381260 base. sort ( ) ;
12391261 base. dedup ( ) ;
12401262 }
12411263
12421264 base. into_iter ( )
12431265 . 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) ;
12451267
12461268 if !res {
12471269 session. warn ( & format ! ( "dropping unsupported crate type `{}` for target `{}`" ,
0 commit comments