Tidy ups for code gen options help
Remove duplication code gen options and updated help to reflect changes.
This commit is contained in:
parent
87ed467077
commit
6aee1e2a67
3 changed files with 38 additions and 28 deletions
|
@ -604,9 +604,9 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
|||
lto: bool = (false, parse_bool,
|
||||
"perform LLVM link-time optimizations"),
|
||||
target_cpu: Option<String> = (None, parse_opt_string,
|
||||
"select target processor (llc -mcpu=help for details)"),
|
||||
"select target processor (rustc --print target-cpus for details)"),
|
||||
target_feature: String = ("".to_string(), parse_string,
|
||||
"target specific attributes (llc -mattr=help for details)"),
|
||||
"target specific attributes (rustc --print target-features for details)"),
|
||||
passes: Vec<String> = (Vec::new(), parse_list,
|
||||
"a list of extra LLVM passes to run (space separated)"),
|
||||
llvm_args: Vec<String> = (Vec::new(), parse_list,
|
||||
|
@ -630,9 +630,9 @@ options! {CodegenOptions, CodegenSetter, basic_codegen_options,
|
|||
no_redzone: Option<bool> = (None, parse_opt_bool,
|
||||
"disable the use of the redzone"),
|
||||
relocation_model: Option<String> = (None, parse_opt_string,
|
||||
"choose the relocation model to use (llc -relocation-model for details)"),
|
||||
"choose the relocation model to use (rustc --print relocation-models for details)"),
|
||||
code_model: Option<String> = (None, parse_opt_string,
|
||||
"choose the code model to use (llc -code-model for details)"),
|
||||
"choose the code model to use (rustc --print code-models for details)"),
|
||||
metadata: Vec<String> = (Vec::new(), parse_list,
|
||||
"metadata to mangle symbol names with"),
|
||||
extra_filename: String = ("".to_string(), parse_string,
|
||||
|
@ -993,7 +993,8 @@ pub fn rustc_short_optgroups() -> Vec<RustcOptGroup> {
|
|||
"[asm|llvm-bc|llvm-ir|obj|link|dep-info]"),
|
||||
opt::multi_s("", "print", "Comma separated list of compiler information to \
|
||||
print on stdout",
|
||||
"[crate-name|file-names|sysroot|cfg|target-list]"),
|
||||
"[crate-name|file-names|sysroot|cfg|target-list|target-cpus|\
|
||||
target-features|relocation-models|code-models]"),
|
||||
opt::flagmulti_s("g", "", "Equivalent to -C debuginfo=2"),
|
||||
opt::flagmulti_s("O", "", "Equivalent to -C opt-level=2"),
|
||||
opt::opt_s("o", "", "Write output to <filename>", "FILENAME"),
|
||||
|
|
|
@ -69,7 +69,7 @@ use pretty::{PpMode, UserIdentifiedItem};
|
|||
use rustc_resolve as resolve;
|
||||
use rustc_save_analysis as save;
|
||||
use rustc_trans::back::link;
|
||||
use rustc_trans::back::write::create_target_machine;
|
||||
use rustc_trans::back::write::{create_target_machine, RELOC_MODEL_ARGS, CODE_GEN_MODEL_ARGS};
|
||||
use rustc::dep_graph::DepGraph;
|
||||
use rustc::session::{self, config, Session, build_session, CompileResult};
|
||||
use rustc::session::config::{Input, PrintRequest, OutputType, ErrorOutputType};
|
||||
|
@ -676,19 +676,18 @@ impl RustcDefaultCalls {
|
|||
unsafe { llvm::LLVMRustPrintTargetFeatures(tm); }
|
||||
}
|
||||
PrintRequest::RelocationModels => {
|
||||
println!("Available relocation models:\n");
|
||||
println!(" pic");
|
||||
println!(" static");
|
||||
println!(" default");
|
||||
println!(" dynamic-no-pic\n");
|
||||
println!("Available relocation models:");
|
||||
for &(name, _) in RELOC_MODEL_ARGS.iter() {
|
||||
println!(" {}", name);
|
||||
}
|
||||
println!("");
|
||||
}
|
||||
PrintRequest::CodeModels => {
|
||||
println!("Available code models:\n");
|
||||
println!(" default");
|
||||
println!(" small");
|
||||
println!(" kernel");
|
||||
println!(" medium");
|
||||
println!(" large\n");
|
||||
println!("Available code models:");
|
||||
for &(name, _) in CODE_GEN_MODEL_ARGS.iter(){
|
||||
println!(" {}", name);
|
||||
}
|
||||
println!("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,6 +33,21 @@ use std::sync::mpsc::channel;
|
|||
use std::thread;
|
||||
use libc::{c_uint, c_void};
|
||||
|
||||
pub const RELOC_MODEL_ARGS : [(&'static str, llvm::RelocMode); 4] = [
|
||||
("pic", llvm::RelocPIC),
|
||||
("static", llvm::RelocStatic),
|
||||
("default", llvm::RelocDefault),
|
||||
("dynamic-no-pic", llvm::RelocDynamicNoPic),
|
||||
];
|
||||
|
||||
pub const CODE_GEN_MODEL_ARGS : [(&'static str, llvm::CodeGenModel); 5] = [
|
||||
("default", llvm::CodeModelDefault),
|
||||
("small", llvm::CodeModelSmall),
|
||||
("kernel", llvm::CodeModelKernel),
|
||||
("medium", llvm::CodeModelMedium),
|
||||
("large", llvm::CodeModelLarge),
|
||||
];
|
||||
|
||||
pub fn llvm_err(handler: &errors::Handler, msg: String) -> ! {
|
||||
match llvm::last_error() {
|
||||
Some(err) => panic!(handler.fatal(&format!("{}: {}", msg, err))),
|
||||
|
@ -156,11 +171,9 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
|||
Some(ref s) => &s[..],
|
||||
None => &sess.target.target.options.relocation_model[..],
|
||||
};
|
||||
let reloc_model = match reloc_model_arg {
|
||||
"pic" => llvm::RelocPIC,
|
||||
"static" => llvm::RelocStatic,
|
||||
"default" => llvm::RelocDefault,
|
||||
"dynamic-no-pic" => llvm::RelocDynamicNoPic,
|
||||
let reloc_model = match RELOC_MODEL_ARGS.iter().find(
|
||||
|&&arg| arg.0 == reloc_model_arg) {
|
||||
Some(x) => x.1,
|
||||
_ => {
|
||||
sess.err(&format!("{:?} is not a valid relocation mode",
|
||||
sess.opts
|
||||
|
@ -186,12 +199,9 @@ pub fn create_target_machine(sess: &Session) -> TargetMachineRef {
|
|||
None => &sess.target.target.options.code_model[..],
|
||||
};
|
||||
|
||||
let code_model = match code_model_arg {
|
||||
"default" => llvm::CodeModelDefault,
|
||||
"small" => llvm::CodeModelSmall,
|
||||
"kernel" => llvm::CodeModelKernel,
|
||||
"medium" => llvm::CodeModelMedium,
|
||||
"large" => llvm::CodeModelLarge,
|
||||
let code_model = match CODE_GEN_MODEL_ARGS.iter().find(
|
||||
|&&arg| arg.0 == code_model_arg) {
|
||||
Some(x) => x.1,
|
||||
_ => {
|
||||
sess.err(&format!("{:?} is not a valid code model",
|
||||
sess.opts
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue