1 |
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs |
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs |
2 |
index 638b2a7b5a9f..79d4ecf4cb91 100644 |
index 63207803e327..f5757760c409 100644 |
3 |
--- a/compiler/rustc_codegen_ssa/src/back/link.rs |
--- a/compiler/rustc_codegen_ssa/src/back/link.rs |
4 |
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs |
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs |
5 |
@@ -763,7 +763,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( |
@@ -741,7 +741,7 @@ fn link_natively<'a>( |
6 |
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") |
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") |
7 |
{ |
{ |
8 |
info!("linker output: {:?}", out); |
info!("linker output: {:?}", out); |
11 |
for arg in cmd.take_args() { |
for arg in cmd.take_args() { |
12 |
if arg.to_string_lossy() != "-no-pie" { |
if arg.to_string_lossy() != "-no-pie" { |
13 |
cmd.arg(arg); |
cmd.arg(arg); |
14 |
@@ -782,7 +782,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>( |
@@ -760,7 +760,7 @@ fn link_natively<'a>( |
15 |
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie") |
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie") |
16 |
{ |
{ |
17 |
info!("linker output: {:?}", out); |
info!("linker output: {:?}", out); |
20 |
"Linker does not support -static-pie command line option. Retrying with -static instead." |
"Linker does not support -static-pie command line option. Retrying with -static instead." |
21 |
); |
); |
22 |
// Mirror `add_(pre,post)_link_objects` to replace CRT objects. |
// Mirror `add_(pre,post)_link_objects` to replace CRT objects. |
23 |
@@ -1507,15 +1507,14 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
@@ -1507,15 +1507,15 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
24 |
} |
} |
25 |
|
|
26 |
fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind { |
fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind { |
27 |
- let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) { |
- let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) { |
28 |
+ // Only use PIE if explicitly specified. |
+ // Only use PIE if explicitly specified. |
29 |
|
+ #[cfg_attr(not(bootstrap), allow(rustc::bad_opt_access))] |
30 |
+ let explicit_pic = |
+ let explicit_pic = |
31 |
+ matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie)); |
+ matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie)); |
32 |
+ let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) { |
+ let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) { |