80296c
--- rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs.orig	2022-09-24 10:20:14.000000000 -0700
80296c
+++ rustc-beta-src/compiler/rustc_codegen_ssa/src/back/link.rs	2022-10-05 11:24:21.759564185 -0700
80296c
@@ -755,7 +755,7 @@
1e9ce7
             && cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie")
1e9ce7
         {
1e9ce7
             info!("linker output: {:?}", out);
1e9ce7
-            warn!("Linker does not support -no-pie command line option. Retrying without.");
1e9ce7
+            info!("Linker does not support -no-pie command line option. Retrying without.");
1e9ce7
             for arg in cmd.take_args() {
1e9ce7
                 if arg.to_string_lossy() != "-no-pie" {
1e9ce7
                     cmd.arg(arg);
80296c
@@ -774,7 +774,7 @@
1e9ce7
             && cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie")
1e9ce7
         {
1e9ce7
             info!("linker output: {:?}", out);
1e9ce7
-            warn!(
1e9ce7
+            info!(
1e9ce7
                 "Linker does not support -static-pie command line option. Retrying with -static instead."
1e9ce7
             );
1e9ce7
             // Mirror `add_(pre,post)_link_objects` to replace CRT objects.
80296c
@@ -1520,15 +1520,15 @@
1e9ce7
 }
1e9ce7
 
1e9ce7
 fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
1e9ce7
-    let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) {
1e9ce7
+    // Only use PIE if explicitly specified.
80296c
+    #[allow(rustc::bad_opt_access)]
1e9ce7
+    let explicit_pic =
1e9ce7
+        matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie));
1e9ce7
+    let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) {
1e9ce7
         (CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe,
1e9ce7
-        (CrateType::Executable, false, RelocModel::Pic | RelocModel::Pie) => {
1e9ce7
-            LinkOutputKind::DynamicPicExe
1e9ce7
-        }
1e9ce7
+        (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe,
1e9ce7
         (CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe,
1e9ce7
-        (CrateType::Executable, true, RelocModel::Pic | RelocModel::Pie) => {
1e9ce7
-            LinkOutputKind::StaticPicExe
1e9ce7
-        }
1e9ce7
+        (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe,
1e9ce7
         (CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe,
1e9ce7
         (_, true, _) => LinkOutputKind::StaticDylib,
1e9ce7
         (_, false, _) => LinkOutputKind::DynamicDylib,