File tree Expand file tree Collapse file tree 2 files changed +19
-1
lines changed
Expand file tree Collapse file tree 2 files changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -186,6 +186,22 @@ pub mod write {
186186 }
187187 } ;
188188
189+ let code_model = match sess. opts . cg . code_model . as_slice ( ) {
190+ "default" => llvm:: CodeModelDefault ,
191+ "small" => llvm:: CodeModelSmall ,
192+ "kernel" => llvm:: CodeModelKernel ,
193+ "medium" => llvm:: CodeModelMedium ,
194+ "large" => llvm:: CodeModelLarge ,
195+ _ => {
196+ sess. err ( format ! ( "{} is not a valid code model" ,
197+ sess. opts
198+ . cg
199+ . code_model) . as_slice ( ) ) ;
200+ sess. abort_if_errors ( ) ;
201+ return ;
202+ }
203+ } ;
204+
189205 let tm = sess. targ_cfg
190206 . target_strs
191207 . target_triple
@@ -195,7 +211,7 @@ pub mod write {
195211 target_feature ( sess) . with_c_str ( |features| {
196212 llvm:: LLVMRustCreateTargetMachine (
197213 t, cpu, features,
198- llvm :: CodeModelDefault ,
214+ code_model ,
199215 reloc_model,
200216 opt_level,
201217 true /* EnableSegstk */ ,
Original file line number Diff line number Diff line change @@ -334,6 +334,8 @@ cgoptions!(
334334 "use an external assembler rather than LLVM's integrated one" ) ,
335335 relocation_model: String = ( "pic" . to_string( ) , parse_string,
336336 "choose the relocation model to use (llc -relocation-model for details)" ) ,
337+ code_model: String = ( "default" . to_string( ) , parse_string,
338+ "choose the code model to use (llc -code-model for details)" ) ,
337339 metadata: Vec <String > = ( Vec :: new( ) , parse_list,
338340 "metadata to mangle symbol names with" ) ,
339341 extra_filename: String = ( "" . to_string( ) , parse_string,
You can’t perform that action at this time.
0 commit comments