auto merge of #13340 : FlaPer87/rust/code-model, r=cmr

Rust currently defaults to `RelocPIC` regardless. This patch adds a new
codegen option that allows choosing different relocation-model. The
available models are:

    - default (Use the target-specific default model)
    - static
    - pic
    - no-pic

For a more detailed information use `llc --help`
This commit is contained in:
bors 2014-04-06 07:06:36 -07:00
commit 02c81fe2b5
5 changed files with 43 additions and 1 deletions

View file

@ -152,13 +152,26 @@ pub mod write {
(sess.targ_cfg.os == abi::OsMacos &&
sess.targ_cfg.arch == abi::X86_64);
let reloc_model = match sess.opts.cg.relocation_model.as_slice() {
"pic" => lib::llvm::RelocPIC,
"static" => lib::llvm::RelocStatic,
"default" => lib::llvm::RelocDefault,
"dynamic-no-pic" => lib::llvm::RelocDynamicNoPic,
_ => {
sess.err(format!("{} is not a valid relocation mode",
sess.opts.cg.relocation_model));
sess.abort_if_errors();
return;
}
};
let tm = sess.targ_cfg.target_strs.target_triple.with_c_str(|t| {
sess.opts.cg.target_cpu.with_c_str(|cpu| {
target_feature(sess).with_c_str(|features| {
llvm::LLVMRustCreateTargetMachine(
t, cpu, features,
lib::llvm::CodeModelDefault,
lib::llvm::RelocPIC,
reloc_model,
opt_level,
true,
use_softfp,