Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add no-pic debug flag to disable position independent code #11995

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/librustc/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -141,7 +146,7 @@ pub mod write {
llvm::LLVMRustCreateTargetMachine(
T, CPU, Features,
lib::llvm::CodeModelDefault,
lib::llvm::RelocPIC,
pic_mode,
OptLevel,
true,
use_softfp,
Expand Down
5 changes: 5 additions & 0 deletions src/librustc/driver/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ debugging_opts!(
NO_VERIFY,
BORROWCK_STATS,
NO_LANDING_PADS,
NO_PIC,
DEBUG_LLVM,
COUNT_TYPE_SIZES,
META_STATS,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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.
Expand Down