Skip to content

Commit

Permalink
[LLVM-3.9] Configure PIE at the module level instead of compilation u…
Browse files Browse the repository at this point in the history
…nit level

This was deleted here[1] which appears to be replaced by this[2]
which is a new setPIELevel function on the LLVM module itself.

[1]: http://reviews.llvm.org/D19753
[2]: http://reviews.llvm.org/D19671
  • Loading branch information
badboy committed Jul 29, 2016
1 parent dbb4178 commit 9e706f9
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/librustc_llvm/lib.rs
Expand Up @@ -2155,6 +2155,7 @@ extern {

pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
pub fn LLVMRustUnsetComdat(V: ValueRef);
pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
}

// LLVM requires symbols from this library, but apparently they're not printed
Expand Down
1 change: 1 addition & 0 deletions src/librustc_trans/context.rs
Expand Up @@ -352,6 +352,7 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR
let llvm_target = sess.target.target.llvm_target.as_bytes();
let llvm_target = CString::new(llvm_target).unwrap();
llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr());
llvm::LLVMRustSetModulePIELevel(llmod);
(llcx, llmod)
}

Expand Down
10 changes: 10 additions & 0 deletions src/rustllvm/PassWrapper.cpp
Expand Up @@ -188,7 +188,10 @@ LLVMRustCreateTargetMachine(const char *triple,
}

TargetOptions Options;
#if LLVM_VERSION_MINOR <= 8
Options.PositionIndependentExecutable = PositionIndependentExecutable;
#endif

Options.FloatABIType = FloatABI::Default;
if (UseSoftFloat) {
Options.FloatABIType = FloatABI::Soft;
Expand Down Expand Up @@ -411,3 +414,10 @@ extern "C" LLVMTargetDataRef
LLVMRustGetModuleDataLayout(LLVMModuleRef M) {
return wrap(&unwrap(M)->getDataLayout());
}

extern "C" void
LLVMRustSetModulePIELevel(LLVMModuleRef M) {
#if LLVM_VERSION_MINOR >= 9
unwrap(M)->setPIELevel(PIELevel::Level::Default);
#endif
}

0 comments on commit 9e706f9

Please sign in to comment.