2022-02-03 07:07:15 +00:00
|
|
|
diff --git a/compiler/rustc_codegen_ssa/src/back/link.rs b/compiler/rustc_codegen_ssa/src/back/link.rs
|
2022-12-05 14:58:45 +00:00
|
|
|
index 638b2a7b5a9f..79d4ecf4cb91 100644
|
2022-02-03 07:07:15 +00:00
|
|
|
--- a/compiler/rustc_codegen_ssa/src/back/link.rs
|
|
|
|
+++ b/compiler/rustc_codegen_ssa/src/back/link.rs
|
2022-12-05 14:58:45 +00:00
|
|
|
@@ -763,7 +763,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
2022-02-03 07:07:15 +00:00
|
|
|
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie")
|
|
|
|
{
|
|
|
|
info!("linker output: {:?}", out);
|
|
|
|
- warn!("Linker does not support -no-pie command line option. Retrying without.");
|
|
|
|
+ info!("Linker does not support -no-pie command line option. Retrying without.");
|
|
|
|
for arg in cmd.take_args() {
|
|
|
|
if arg.to_string_lossy() != "-no-pie" {
|
|
|
|
cmd.arg(arg);
|
2022-12-05 14:58:45 +00:00
|
|
|
@@ -782,7 +782,7 @@ fn link_natively<'a, B: ArchiveBuilder<'a>>(
|
2022-02-03 07:07:15 +00:00
|
|
|
&& cmd.get_args().iter().any(|e| e.to_string_lossy() == "-static-pie")
|
|
|
|
{
|
|
|
|
info!("linker output: {:?}", out);
|
|
|
|
- warn!(
|
|
|
|
+ info!(
|
|
|
|
"Linker does not support -static-pie command line option. Retrying with -static instead."
|
|
|
|
);
|
|
|
|
// Mirror `add_(pre,post)_link_objects` to replace CRT objects.
|
2022-12-05 14:58:45 +00:00
|
|
|
@@ -1507,15 +1507,14 @@ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
2022-02-03 07:07:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn link_output_kind(sess: &Session, crate_type: CrateType) -> LinkOutputKind {
|
|
|
|
- let kind = match (crate_type, sess.crt_static(Some(crate_type)), sess.relocation_model()) {
|
|
|
|
+ // Only use PIE if explicitly specified.
|
|
|
|
+ let explicit_pic =
|
|
|
|
+ matches!(sess.opts.cg.relocation_model, Some(RelocModel::Pic | RelocModel::Pie));
|
|
|
|
+ let kind = match (crate_type, sess.crt_static(Some(crate_type)), explicit_pic) {
|
|
|
|
(CrateType::Executable, _, _) if sess.is_wasi_reactor() => LinkOutputKind::WasiReactorExe,
|
|
|
|
- (CrateType::Executable, false, RelocModel::Pic | RelocModel::Pie) => {
|
|
|
|
- LinkOutputKind::DynamicPicExe
|
|
|
|
- }
|
|
|
|
+ (CrateType::Executable, false, true) => LinkOutputKind::DynamicPicExe,
|
|
|
|
(CrateType::Executable, false, _) => LinkOutputKind::DynamicNoPicExe,
|
|
|
|
- (CrateType::Executable, true, RelocModel::Pic | RelocModel::Pie) => {
|
|
|
|
- LinkOutputKind::StaticPicExe
|
|
|
|
- }
|
|
|
|
+ (CrateType::Executable, true, true) => LinkOutputKind::StaticPicExe,
|
|
|
|
(CrateType::Executable, true, _) => LinkOutputKind::StaticNoPicExe,
|
|
|
|
(_, true, _) => LinkOutputKind::StaticDylib,
|
|
|
|
(_, false, _) => LinkOutputKind::DynamicDylib,
|