diff --git a/src/librustc/back/link.rs b/src/librustc/back/link.rs index fc38fa25a2146..29e455affef34 100644 --- a/src/librustc/back/link.rs +++ b/src/librustc/back/link.rs @@ -121,6 +121,11 @@ pub mod write { }) } + let pic_mode = match sess.no_pic() { + true => lib::llvm::RelocDynamicNoPic, + false => lib::llvm::RelocPIC + }; + let OptLevel = match sess.opts.optimize { session::No => lib::llvm::CodeGenLevelNone, session::Less => lib::llvm::CodeGenLevelLess, @@ -141,7 +146,7 @@ pub mod write { llvm::LLVMRustCreateTargetMachine( T, CPU, Features, lib::llvm::CodeModelDefault, - lib::llvm::RelocPIC, + pic_mode, OptLevel, true, use_softfp, diff --git a/src/librustc/driver/session.rs b/src/librustc/driver/session.rs index cebc25c4845d4..5c9ac9efecac3 100644 --- a/src/librustc/driver/session.rs +++ b/src/librustc/driver/session.rs @@ -60,6 +60,7 @@ debugging_opts!( NO_VERIFY, BORROWCK_STATS, NO_LANDING_PADS, + NO_PIC, DEBUG_LLVM, COUNT_TYPE_SIZES, META_STATS, @@ -95,6 +96,7 @@ pub fn debugging_opts_map() -> ~[(&'static str, &'static str, u64)] { ("borrowck-stats", "gather borrowck statistics", BORROWCK_STATS), ("no-landing-pads", "omit landing pads for unwinding", NO_LANDING_PADS), + ("no-pic", "do not produce position independent code", NO_PIC), ("debug-llvm", "enable debug output from LLVM", DEBUG_LLVM), ("count-type-sizes", "count the sizes of aggregate types", COUNT_TYPE_SIZES), @@ -351,6 +353,9 @@ impl Session_ { pub fn no_landing_pads(&self) -> bool { self.debugging_opt(NO_LANDING_PADS) } + pub fn no_pic(&self) -> bool { + self.debugging_opt(NO_PIC) + } // DEPRECATED. This function results in a lot of allocations when they // are not necessary.