79456f
--- rustc-1.48.0-src/compiler/rustc_codegen_ssa/src/back/link.rs.orig	2020-11-16 06:01:53.000000000 -0800
79456f
+++ rustc-1.48.0-src/compiler/rustc_codegen_ssa/src/back/link.rs	2020-11-16 09:37:15.779516797 -0800
79456f
@@ -1185,10 +1185,12 @@
c3bb10
 }
c3bb10
 
c3bb10
 fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
c3bb10
-    let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) {
c3bb10
-        (CrateType::Executable, false, RelocModel::Pic) => LinkOutputKind::DynamicPicExe,
c3bb10
+    // Only use PIE if explicity specified.
c3bb10
+    let explicit_pic = matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic));
c3bb10
+    let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) {
c3bb10
+        (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe,
c3bb10
         (CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe,
c3bb10
-        (CrateType::Executable, true, RelocModel::Pic) => LinkOutputKind::StaticPicExe,
c3bb10
+        (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe,
c3bb10
         (CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe,
c3bb10
         (_, true, _) => LinkOutputKind::StaticDylib,
c3bb10
         (_, false, _) => LinkOutputKind::DynamicDylib,