diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2021-10-01 09:18:16 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-01 09:18:16 -0700 |
| commit | 6f1e93058137eb606cbee5ef778d30b379903f7c (patch) | |
| tree | 1840b8bb51958a08a03e4a76d5ce698ff07d58c6 /compiler/rustc_codegen_llvm/src/context.rs | |
| parent | 37df2753fc52ff80625430aa7e8cdcdc6f16e362 (diff) | |
| parent | 198d90786b9fb429928d70c423bad5d65374a532 (diff) | |
| download | rust-6f1e93058137eb606cbee5ef778d30b379903f7c.tar.gz rust-6f1e93058137eb606cbee5ef778d30b379903f7c.zip | |
Rollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkov
Add `pie` as another `relocation-model` value MCP: https://github.com/rust-lang/compiler-team/issues/461
Diffstat (limited to 'compiler/rustc_codegen_llvm/src/context.rs')
| -rw-r--r-- | compiler/rustc_codegen_llvm/src/context.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/compiler/rustc_codegen_llvm/src/context.rs b/compiler/rustc_codegen_llvm/src/context.rs index 52a12b2fd81..7bdbec11d60 100644 --- a/compiler/rustc_codegen_llvm/src/context.rs +++ b/compiler/rustc_codegen_llvm/src/context.rs @@ -195,11 +195,14 @@ pub unsafe fn create_module( let llvm_target = SmallCStr::new(&sess.target.llvm_target); llvm::LLVMRustSetNormalizedTarget(llmod, llvm_target.as_ptr()); - if sess.relocation_model() == RelocModel::Pic { + let reloc_model = sess.relocation_model(); + if matches!(reloc_model, RelocModel::Pic | RelocModel::Pie) { llvm::LLVMRustSetModulePICLevel(llmod); // PIE is potentially more effective than PIC, but can only be used in executables. // If all our outputs are executables, then we can relax PIC to PIE. - if sess.crate_types().iter().all(|ty| *ty == CrateType::Executable) { + if reloc_model == RelocModel::Pie + || sess.crate_types().iter().all(|ty| *ty == CrateType::Executable) + { llvm::LLVMRustSetModulePIELevel(llmod); } } |
