3824bc
--- rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs.orig	2022-09-24 10:20:14.000000000 -0700
3824bc
+++ rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs	2022-10-05 11:24:21.759564185 -0700
3824bc
@@ -755,7 +755,7 @@
99ab0e
             && cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie")
99ab0e
         {
99ab0e
             info!("linker output: {:?}", out);
99ab0e
-            warn!("Linker does not support -no-pie command line option. Retrying without.");
99ab0e
+            info!("Linker does not support -no-pie command line option. Retrying without.");
99ab0e
             for arg in cmd.take_args() {
99ab0e
                 if arg.to_string_lossy() != "-no-pie" {
99ab0e
                     cmd.arg(arg);
3824bc
@@ -774,7 +774,7 @@
99ab0e
             && cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie")
99ab0e
         {
99ab0e
             info!("linker output: {:?}", out);
99ab0e
-            warn!(
99ab0e
+            info!(
99ab0e
                 "Linker does not support -static-pie command line option. Retrying with -static instead."
99ab0e
             );
99ab0e
             // Mirror `add_(pre,post)_link_objects` to replace CRT objects.
3824bc
@@ -1520,15 +1520,15 @@
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()) {
99ab0e
+    // Only use PIE if explicitly specified.
3824bc
+    #[allow(rustc::bad_opt_access)]
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,