8a888b
--- rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs.orig	2021-03-09 10:40:09.755485845 -0800
8a888b
+++ rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs	2021-03-09 10:44:51.257426181 -0800
8a888b
@@ -1279,11 +1279,13 @@
872d83
 }
872d83
 
872d83
 fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
872d83
-    let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) {
872d83
+    // Only use PIE if explicity specified.
872d83
+    let explicit_pic = matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic));
872d83
+    let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) {
8a888b
         (CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe,
8a888b
-        (CrateType::Executable, false, RelocModel::Pic) => LinkOutputKind::DynamicPicExe,
872d83
+        (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe,
872d83
         (CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe,
872d83
-        (CrateType::Executable, true, RelocModel::Pic) => LinkOutputKind::StaticPicExe,
872d83
+        (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe,
872d83
         (CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe,
872d83
         (_, true, _) => LinkOutputKind::StaticDylib,
872d83
         (_, false, _) => LinkOutputKind::DynamicDylib,