Skip to content

Commit 9e706f9

Browse files
committed
[LLVM-3.9] Configure PIE at the module level instead of compilation unit 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
1 parent dbb4178 commit 9e706f9

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-0
lines changed

src/librustc_llvm/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,6 +2155,7 @@ extern {
21552155

21562156
pub fn LLVMRustSetComdat(M: ModuleRef, V: ValueRef, Name: *const c_char);
21572157
pub fn LLVMRustUnsetComdat(V: ValueRef);
2158+
pub fn LLVMRustSetModulePIELevel(M: ModuleRef);
21582159
}
21592160

21602161
// LLVM requires symbols from this library, but apparently they're not printed

src/librustc_trans/context.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ unsafe fn create_context_and_module(sess: &Session, mod_name: &str) -> (ContextR
352352
let llvm_target = sess.target.target.llvm_target.as_bytes();
353353
let llvm_target = CString::new(llvm_target).unwrap();
354354
llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr());
355+
llvm::LLVMRustSetModulePIELevel(llmod);
355356
(llcx, llmod)
356357
}
357358

src/rustllvm/PassWrapper.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,10 @@ LLVMRustCreateTargetMachine(const char *triple,
188188
}
189189

190190
TargetOptions Options;
191+
#if LLVM_VERSION_MINOR <= 8
191192
Options.PositionIndependentExecutable = PositionIndependentExecutable;
193+
#endif
194+
192195
Options.FloatABIType = FloatABI::Default;
193196
if (UseSoftFloat) {
194197
Options.FloatABIType = FloatABI::Soft;
@@ -411,3 +414,10 @@ extern "C" LLVMTargetDataRef
411414
LLVMRustGetModuleDataLayout(LLVMModuleRef M) {
412415
return wrap(&unwrap(M)->getDataLayout());
413416
}
417+
418+
extern "C" void
419+
LLVMRustSetModulePIELevel(LLVMModuleRef M) {
420+
#if LLVM_VERSION_MINOR >= 9
421+
unwrap(M)->setPIELevel(PIELevel::Level::Default);
422+
#endif
423+
}

0 commit comments

Comments
 (0)