1 |
akien |
1769757 |
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs |
2 |
akien |
1891744 |
index 63207803e327..f5757760c409 100644 |
3 |
akien |
1769757 |
--- a/compiler/rustc_codegen_ssa/src/back/link.rs |
4 |
|
|
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs |
5 |
akien |
1891744 |
@@ -741,7 +741,7 @@ fn link_natively<'a>( |
6 |
akien |
1769757 |
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") |
7 |
|
|
{ |
8 |
|
|
info!("linker output: {:?}", out); |
9 |
|
|
- warn!("Linker does not support -no-pie command line option. Retrying without."); |
10 |
|
|
+ info!("Linker does not support -no-pie command line option. Retrying without."); |
11 |
|
|
for arg in cmd.take_args() { |
12 |
|
|
if arg.to_string_lossy() != "-no-pie" { |
13 |
|
|
cmd.arg(arg); |
14 |
akien |
1891744 |
@@ -760,7 +760,7 @@ fn link_natively<'a>( |
15 |
akien |
1769757 |
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie") |
16 |
|
|
{ |
17 |
|
|
info!("linker output: {:?}", out); |
18 |
|
|
- warn!( |
19 |
|
|
+ info!( |
20 |
|
|
"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. |
23 |
akien |
1891744 |
@@ -1507,15 +1507,15 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
24 |
akien |
1769757 |
} |
25 |
|
|
|
26 |
|
|
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()) { |
28 |
|
|
+ // Only use PIE if explicitly specified. |
29 |
akien |
1891744 |
+ #[cfg_attr(not(bootstrap), allow(rustc::bad_opt_access))] |
30 |
akien |
1769757 |
+ let explicit_pic = |
31 |
|
|
+ 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) { |
33 |
|
|
(CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe, |
34 |
|
|
- (CrateType::Executable, false, RelocModel::Pic | RelocModel::Pie) => { |
35 |
|
|
- LinkOutputKind::DynamicPicExe |
36 |
|
|
- } |
37 |
|
|
+ (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe, |
38 |
|
|
(CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe, |
39 |
|
|
- (CrateType::Executable, true, RelocModel::Pic | RelocModel::Pie) => { |
40 |
|
|
- LinkOutputKind::StaticPicExe |
41 |
|
|
- } |
42 |
|
|
+ (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe, |
43 |
|
|
(CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe, |
44 |
|
|
(_, true, _) => LinkOutputKind::StaticDylib, |
45 |
|
|
(_, false, _) => LinkOutputKind::DynamicDylib, |