1 |
--- rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs.orig 2021-11-29 10:41:02.380100917 -0800 |
2 |
+++ rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs 2021-11-29 10:53:31.014783112 -0800 |
3 |
@@ -1485,15 +1485,14 @@ |
4 |
} |
5 |
|
6 |
fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind { |
7 |
- let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) { |
8 |
+ // Only use PIE if explicity specified. |
9 |
+ let explicit_pic = |
10 |
+ matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie)); |
11 |
+ let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) { |
12 |
(CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe, |
13 |
- (CrateType::Executable, false, RelocModel::Pic | RelocModel::Pie) => { |
14 |
- LinkOutputKind::DynamicPicExe |
15 |
- } |
16 |
+ (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe, |
17 |
(CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe, |
18 |
- (CrateType::Executable, true, RelocModel::Pic | RelocModel::Pie) => { |
19 |
- LinkOutputKind::StaticPicExe |
20 |
- } |
21 |
+ (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe, |
22 |
(CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe, |
23 |
(_, true, _) => LinkOutputKind::StaticDylib, |
24 |
(_, false, _) => LinkOutputKind::DynamicDylib, |