From de93abe8a0d9dc7878a48f61b9e3ae4a923020f6 Mon Sep 17 00:00:00 2001
From: q66 <daniel@octaforge.org>
Date: Sun, 3 May 2020 18:08:09 +0200
Subject: [PATCH 11/15] Use ELFv2 ABI on all powerpc64 targets

This patches librustc_target so that ELFv2 is used everywhere, matching our
LLVM. While this is not perfect (it does not allow rustc to compile legacy
binaries), rustc never requests specific ABI from llvm in the first place,
so at least match the environment we have.
---
 compiler/rustc_target/src/abi/call/powerpc64.rs          | 9 +--------
 .../rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs | 6 +-----
 2 files changed, 2 insertions(+), 13 deletions(-)

diff --git a/compiler/rustc_target/src/abi/call/powerpc64.rs b/compiler/rustc_target/src/abi/call/powerpc64.rs
index c22ef9c8f..932172b2f 100644
--- a/compiler/rustc_target/src/abi/call/powerpc64.rs
+++ b/compiler/rustc_target/src/abi/call/powerpc64.rs
@@ -119,14 +119,7 @@ where
     Ty: TyAbiInterface<'a, C> + Copy,
     C: HasDataLayout + HasTargetSpec,
 {
-    let abi = if cx.target_spec().env == "musl" {
-        ELFv2
-    } else {
-        match cx.data_layout().endian {
-            Endian::Big => ELFv1,
-            Endian::Little => ELFv2,
-        }
-    };
+    let abi = ELFv2;
 
     if !fn_abi.ret.is_ignore() {
         classify_ret(cx, &mut fn_abi.ret, abi);
diff --git a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs
index 24d5d187e..aa594b02e 100644
--- a/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs
+++ b/compiler/rustc_target/src/spec/powerpc64_unknown_linux_gnu.rs
@@ -1,5 +1,5 @@
 use crate::abi::Endian;
-use crate::spec::{LinkerFlavor, RelroLevel, Target, TargetOptions};
+use crate::spec::{LinkerFlavor, Target, TargetOptions};
 
 pub fn target() -> Target {
     let mut base = super::linux_gnu_base::opts();
@@ -7,10 +7,6 @@ pub fn target() -> Target {
     base.pre_link_args.entry(LinkerFlavor::Gcc).or_default().push("-m64".into());
     base.max_atomic_width = Some(64);
 
-    // ld.so in at least RHEL6 on ppc64 has a bug related to BIND_NOW, so only enable partial RELRO
-    // for now. https://github.com/rust-lang/rust/pull/43170#issuecomment-315411474
-    base.relro_level = RelroLevel::Partial;
-
     Target {
         llvm_target: "powerpc64-unknown-linux-gnu".into(),
         pointer_width: 64,
-- 
2.37.2

