86638a
--- rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs.orig	2021-11-29 10:41:02.380100917 -0800
86638a
+++ rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs	2021-11-29 10:53:31.014783112 -0800
86638a
@@ -1485,15 +1485,14 @@
892f9b
 }
892f9b
 
892f9b
 fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
892f9b
-    let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) {
892f9b
+    // Only use PIE if explicity specified.
86638a
+    let explicit_pic =
86638a
+        matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie));
892f9b
+    let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) {
892f9b
         (CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe,
86638a
-        (CrateType::Executable, false, RelocModel::Pic | RelocModel::Pie) => {
86638a
-            LinkOutputKind::DynamicPicExe
86638a
-        }
892f9b
+        (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe,
892f9b
         (CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe,
86638a
-        (CrateType::Executable, true, RelocModel::Pic | RelocModel::Pie) => {
86638a
-            LinkOutputKind::StaticPicExe
86638a
-        }
892f9b
+        (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe,
892f9b
         (CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe,
892f9b
         (_, true, _) => LinkOutputKind::StaticDylib,
892f9b
         (_, false, _) => LinkOutputKind::DynamicDylib,