8
8
// option. This file may not be copied, modified, or distributed
9
9
// except according to those terms.
10
10
11
+ #![ cfg_attr( not( feature="llvm" ) , allow( dead_code) ) ]
12
+
11
13
use rustc:: hir:: { self , map as hir_map} ;
12
14
use rustc:: hir:: lowering:: lower_crate;
13
15
use rustc:: ich:: Fingerprint ;
@@ -19,8 +21,6 @@ use rustc::session::config::{self, Input, OutputFilenames, OutputType};
19
21
use rustc:: session:: search_paths:: PathKind ;
20
22
use rustc:: lint;
21
23
use rustc:: middle:: { self , stability, reachable} ;
22
- #[ cfg( feature="llvm" ) ]
23
- use rustc:: middle:: dependency_format;
24
24
use rustc:: middle:: privacy:: AccessLevels ;
25
25
use rustc:: mir:: transform:: { MIR_CONST , MIR_VALIDATED , MIR_OPTIMIZED , Passes } ;
26
26
use rustc:: ty:: { self , TyCtxt , Resolutions , GlobalArenas } ;
@@ -33,9 +33,7 @@ use rustc_incremental::{self, IncrementalHashesMap};
33
33
use rustc_resolve:: { MakeGlobMap , Resolver } ;
34
34
use rustc_metadata:: creader:: CrateLoader ;
35
35
use rustc_metadata:: cstore:: { self , CStore } ;
36
- #[ cfg( feature="llvm" ) ]
37
- use rustc_trans:: back:: { link, write} ;
38
- #[ cfg( feature="llvm" ) ]
36
+ use rustc_trans:: back:: write;
39
37
use rustc_trans as trans;
40
38
use rustc_typeck as typeck;
41
39
use rustc_privacy;
@@ -73,11 +71,7 @@ pub fn compile_input(sess: &Session,
73
71
output : & Option < PathBuf > ,
74
72
addl_plugins : Option < Vec < String > > ,
75
73
control : & CompileController ) -> CompileResult {
76
- #[ cfg( feature="llvm" ) ]
77
74
use rustc_trans:: back:: write:: OngoingCrateTranslation ;
78
- #[ cfg( not( feature="llvm" ) ) ]
79
- type OngoingCrateTranslation = ( ) ;
80
-
81
75
macro_rules! controller_entry_point {
82
76
( $point: ident, $tsess: expr, $make_state: expr, $phase_result: expr) => { {
83
77
let state = & mut $make_state;
@@ -94,6 +88,23 @@ pub fn compile_input(sess: &Session,
94
88
} }
95
89
}
96
90
91
+ if cfg ! ( not( feature="llvm" ) ) {
92
+ use rustc:: session:: config:: CrateType ;
93
+ if !sess. opts . debugging_opts . no_trans && sess. opts . output_types . should_trans ( ) {
94
+ sess. err ( "LLVM is not supported by this rustc. Please use -Z no-trans to compile" )
95
+ }
96
+
97
+ if sess. opts . crate_types . iter ( ) . all ( |& t|{
98
+ t != CrateType :: CrateTypeRlib && t != CrateType :: CrateTypeExecutable
99
+ } ) && !sess. opts . crate_types . is_empty ( ) {
100
+ sess. err (
101
+ "LLVM is not supported by this rustc, so non rlib libraries are not supported"
102
+ ) ;
103
+ }
104
+
105
+ sess. abort_if_errors ( ) ;
106
+ }
107
+
97
108
// We need nested scopes here, because the intermediate results can keep
98
109
// large chunks of memory alive and we want to free them as soon as
99
110
// possible to keep the peak memory usage low
@@ -217,7 +228,6 @@ pub fn compile_input(sess: &Session,
217
228
tcx. print_debug_stats ( ) ;
218
229
}
219
230
220
- #[ cfg( feature="llvm" ) ]
221
231
let trans = phase_4_translate_to_llvm ( tcx, analysis, incremental_hashes_map,
222
232
& outputs) ;
223
233
@@ -233,24 +243,13 @@ pub fn compile_input(sess: &Session,
233
243
}
234
244
}
235
245
236
- #[ cfg( not( feature="llvm" ) ) ]
237
- {
238
- let _ = incremental_hashes_map;
239
- sess. err ( & format ! ( "LLVM is not supported by this rustc" ) ) ;
240
- sess. abort_if_errors ( ) ;
241
- unreachable ! ( ) ;
242
- }
243
-
244
- #[ cfg( feature="llvm" ) ]
245
246
Ok ( ( outputs, trans) )
246
247
} ) ??
247
248
} ;
248
249
249
- #[ cfg( not( feature="llvm" ) ) ]
250
- {
251
- let _ = outputs;
252
- let _ = trans;
253
- unreachable ! ( ) ;
250
+ if cfg ! ( not( feature="llvm" ) ) {
251
+ let ( _, _) = ( outputs, trans) ;
252
+ sess. fatal ( "LLVM is not supported by this rustc" ) ;
254
253
}
255
254
256
255
#[ cfg( feature="llvm" ) ]
@@ -393,7 +392,6 @@ pub struct CompileState<'a, 'tcx: 'a> {
393
392
pub resolutions : Option < & ' a Resolutions > ,
394
393
pub analysis : Option < & ' a ty:: CrateAnalysis > ,
395
394
pub tcx : Option < TyCtxt < ' a , ' tcx , ' tcx > > ,
396
- #[ cfg( feature="llvm" ) ]
397
395
pub trans : Option < & ' a trans:: CrateTranslation > ,
398
396
}
399
397
@@ -420,7 +418,6 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
420
418
resolutions : None ,
421
419
analysis : None ,
422
420
tcx : None ,
423
- #[ cfg( feature="llvm" ) ]
424
421
trans : None ,
425
422
}
426
423
}
@@ -509,7 +506,6 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
509
506
}
510
507
}
511
508
512
- #[ cfg( feature="llvm" ) ]
513
509
fn state_after_llvm ( input : & ' a Input ,
514
510
session : & ' tcx Session ,
515
511
out_dir : & ' a Option < PathBuf > ,
@@ -523,7 +519,6 @@ impl<'a, 'tcx> CompileState<'a, 'tcx> {
523
519
}
524
520
}
525
521
526
- #[ cfg( feature="llvm" ) ]
527
522
fn state_when_compilation_done ( input : & ' a Input ,
528
523
session : & ' tcx Session ,
529
524
out_dir : & ' a Option < PathBuf > ,
@@ -942,7 +937,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
942
937
mir:: provide ( & mut local_providers) ;
943
938
reachable:: provide ( & mut local_providers) ;
944
939
rustc_privacy:: provide ( & mut local_providers) ;
945
- #[ cfg( feature="llvm" ) ]
946
940
trans:: provide ( & mut local_providers) ;
947
941
typeck:: provide ( & mut local_providers) ;
948
942
ty:: provide ( & mut local_providers) ;
@@ -955,7 +949,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
955
949
956
950
let mut extern_providers = ty:: maps:: Providers :: default ( ) ;
957
951
cstore:: provide ( & mut extern_providers) ;
958
- #[ cfg( feature="llvm" ) ]
959
952
trans:: provide ( & mut extern_providers) ;
960
953
ty:: provide_extern ( & mut extern_providers) ;
961
954
traits:: provide_extern ( & mut extern_providers) ;
@@ -1102,7 +1095,6 @@ pub fn phase_3_run_analysis_passes<'tcx, F, R>(sess: &'tcx Session,
1102
1095
1103
1096
/// Run the translation phase to LLVM, after which the AST and analysis can
1104
1097
/// be discarded.
1105
- #[ cfg( feature="llvm" ) ]
1106
1098
pub fn phase_4_translate_to_llvm < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
1107
1099
analysis : ty:: CrateAnalysis ,
1108
1100
incremental_hashes_map : IncrementalHashesMap ,
@@ -1112,7 +1104,7 @@ pub fn phase_4_translate_to_llvm<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
1112
1104
1113
1105
time ( time_passes,
1114
1106
"resolving dependency formats" ,
1115
- || dependency_format:: calculate ( tcx) ) ;
1107
+ || :: rustc :: middle :: dependency_format:: calculate ( tcx) ) ;
1116
1108
1117
1109
let translation =
1118
1110
time ( time_passes,
@@ -1147,9 +1139,9 @@ pub fn phase_5_run_llvm_passes(sess: &Session,
1147
1139
pub fn phase_6_link_output ( sess : & Session ,
1148
1140
trans : & trans:: CrateTranslation ,
1149
1141
outputs : & OutputFilenames ) {
1150
- time ( sess. time_passes ( ) ,
1151
- "linking" ,
1152
- || link :: link_binary ( sess , trans , outputs , & trans . crate_name . as_str ( ) ) ) ;
1142
+ time ( sess. time_passes ( ) , "linking" , || {
1143
+ :: rustc_trans :: back :: link :: link_binary ( sess , trans , outputs , & trans . crate_name . as_str ( ) )
1144
+ } ) ;
1153
1145
}
1154
1146
1155
1147
fn escape_dep_filename ( filename : & str ) -> String {
0 commit comments