@@ -35,6 +35,8 @@ extern crate arena;
35
35
extern crate getopts;
36
36
extern crate graphviz;
37
37
extern crate env_logger;
38
+ #[ cfg( not( feature="llvm" ) ) ]
39
+ extern crate owning_ref;
38
40
extern crate libc;
39
41
extern crate rustc;
40
42
extern crate rustc_allocator;
@@ -70,8 +72,6 @@ use rustc_resolve as resolve;
70
72
use rustc_save_analysis as save;
71
73
use rustc_save_analysis:: DumpHandler ;
72
74
#[ cfg( feature="llvm" ) ]
73
- use rustc_trans:: back:: link;
74
- #[ cfg( feature="llvm" ) ]
75
75
use rustc_trans:: back:: write:: { RELOC_MODEL_ARGS , CODE_GEN_MODEL_ARGS } ;
76
76
use rustc:: dep_graph:: DepGraph ;
77
77
use rustc:: session:: { self , config, Session , build_session, CompileResult } ;
@@ -82,7 +82,7 @@ use rustc::session::{early_error, early_warn};
82
82
use rustc:: lint:: Lint ;
83
83
use rustc:: lint;
84
84
#[ cfg( not( feature="llvm" ) ) ]
85
- use rustc:: middle:: cstore:: MetadataLoader ;
85
+ use rustc:: middle:: cstore:: MetadataLoader as MetadataLoaderTrait ;
86
86
use rustc_metadata:: locator;
87
87
use rustc_metadata:: cstore:: CStore ;
88
88
use rustc:: util:: common:: { time, ErrorReported } ;
@@ -114,6 +114,9 @@ use syntax::feature_gate::{GatedCfg, UnstableFeatures};
114
114
use syntax:: parse:: { self , PResult } ;
115
115
use syntax_pos:: { DUMMY_SP , MultiSpan } ;
116
116
117
+ #[ cfg( not( feature="llvm" ) ) ]
118
+ use owning_ref:: { OwningRef , ErasedBoxRef } ;
119
+
117
120
#[ cfg( test) ]
118
121
pub mod test;
119
122
@@ -174,7 +177,7 @@ pub use NoLLvmMetadataLoader as MetadataLoader;
174
177
pub use rustc_trans:: LlvmMetadataLoader as MetadataLoader ;
175
178
176
179
#[ cfg( not( feature="llvm" ) ) ]
177
- impl MetadataLoader for NoLLvmMetadataLoader {
180
+ impl MetadataLoaderTrait for NoLLvmMetadataLoader {
178
181
fn get_rlib_metadata ( & self , _: & Target , filename : & Path ) -> Result < ErasedBoxRef < [ u8 ] > , String > {
179
182
use std:: fs:: File ;
180
183
use std:: io;
@@ -185,20 +188,20 @@ impl MetadataLoader for NoLLvmMetadataLoader {
185
188
186
189
while let Some ( entry_result) = archive. next_entry ( ) {
187
190
let mut entry = entry_result. map_err ( |e|format ! ( "metadata section read err: {:?}" , e) ) ?;
188
- if entry. header ( ) . identifier ( ) == METADATA_FILENAME {
191
+ if entry. header ( ) . identifier ( ) == "rust.metadata.bin" {
189
192
let mut buf = Vec :: new ( ) ;
190
193
io:: copy ( & mut entry, & mut buf) . unwrap ( ) ;
191
194
let buf: OwningRef < Vec < u8 > , [ u8 ] > = OwningRef :: new ( buf) . into ( ) ;
192
- return Ok ( buf. erase_owner ( ) ) ;
195
+ return Ok ( buf. map_owner_box ( ) . erase_owner ( ) ) ;
193
196
}
194
197
}
195
198
196
199
Err ( "Couldnt find metadata section" . to_string ( ) )
197
200
}
198
201
199
202
fn get_dylib_metadata ( & self ,
200
- target : & Target ,
201
- filename : & Path )
203
+ _target : & Target ,
204
+ _filename : & Path )
202
205
-> Result < ErasedBoxRef < [ u8 ] > , String > {
203
206
panic ! ( "Dylib metadata loading not supported without LLVM" )
204
207
}
@@ -207,6 +210,7 @@ impl MetadataLoader for NoLLvmMetadataLoader {
207
210
// Parse args and run the compiler. This is the primary entry point for rustc.
208
211
// See comments on CompilerCalls below for details about the callbacks argument.
209
212
// The FileLoader provides a way to load files from sources other than the file system.
213
+ #[ cfg_attr( not( feature="llvm" ) , allow( unused_mut) ) ]
210
214
pub fn run_compiler < ' a > ( args : & [ String ] ,
211
215
callbacks : & mut CompilerCalls < ' a > ,
212
216
file_loader : Option < Box < FileLoader + ' static > > ,
@@ -516,6 +520,7 @@ impl<'a> CompilerCalls<'a> for RustcDefaultCalls {
516
520
Compilation :: Continue
517
521
}
518
522
523
+ #[ cfg_attr( not( feature="llvm" ) , allow( unused_mut) ) ]
519
524
fn no_input ( & mut self ,
520
525
matches : & getopts:: Matches ,
521
526
sopts : & config:: Options ,
@@ -743,7 +748,12 @@ impl RustcDefaultCalls {
743
748
}
744
749
let crate_types = driver:: collect_crate_types ( sess, attrs) ;
745
750
for & style in & crate_types {
746
- let fname = rustc_trans_utils:: link:: filename_for_input ( sess, style, & id, & t_outputs) ;
751
+ let fname = rustc_trans_utils:: link:: filename_for_input (
752
+ sess,
753
+ style,
754
+ & id,
755
+ & t_outputs
756
+ ) ;
747
757
println ! ( "{}" ,
748
758
fname. file_name( )
749
759
. unwrap( )
@@ -792,15 +802,15 @@ impl RustcDefaultCalls {
792
802
}
793
803
PrintRequest :: RelocationModels => {
794
804
println ! ( "Available relocation models:" ) ;
795
- #[ cfg( features ="llvm" ) ]
805
+ #[ cfg( feature ="llvm" ) ]
796
806
for & ( name, _) in RELOC_MODEL_ARGS . iter ( ) {
797
807
println ! ( " {}" , name) ;
798
808
}
799
809
println ! ( "" ) ;
800
810
}
801
811
PrintRequest :: CodeModels => {
802
812
println ! ( "Available code models:" ) ;
803
- #[ cfg( features ="llvm" ) ]
813
+ #[ cfg( feature ="llvm" ) ]
804
814
for & ( name, _) in CODE_GEN_MODEL_ARGS . iter ( ) {
805
815
println ! ( " {}" , name) ;
806
816
}
0 commit comments