MaskRay created this revision. MaskRay added reviewers: PowerPC, adalava, Bdragon28, sfertile, stefanp. Herald added subscribers: cfe-commits, steven.zhang, shchenz, jsji, kbarton, krytarowski, arichardson, nemanjai, emaste. Herald added a project: clang.
According to D53384 <https://reviews.llvm.org/D53384>, the default was switched from -fno-PIC to -fPIC to work around a -fsanitize=leak bug on big-endian. This gratuitous difference between little-endian and big-endian is undesired, and not acceptable on powerpc64-unknown-freebsd. If -fsanitize=leak still has the problem, we should default to -fPIC/-fPIE only when -fsanitize=leak is specified. powerpc64-ibm-aix is unaffected: it still defaults to -fPIC. powerpc64-linux-musl is unaffected: it still defaults to -fPIE. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D72363 Files: clang/lib/Driver/ToolChains/Gnu.cpp clang/test/Driver/ppc-abi.c Index: clang/test/Driver/ppc-abi.c =================================================================== --- clang/test/Driver/ppc-abi.c +++ clang/test/Driver/ppc-abi.c @@ -28,18 +28,20 @@ // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s // RUN: %clang -target powerpc64-unknown-freebsd13 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s // RUN: %clang -target powerpc64-unknown-freebsd14 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s -// RUN: %clang -target powerpc64-linux-musl %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s +// RUN: %clang -target powerpc64-linux-musl %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE-PIE %s -// CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2" +// CHECK-ELFv1: "-mrelocation-model" "static" // CHECK-ELFv1: "-target-abi" "elfv1" // CHECK-ELFv1-LE: "-mrelocation-model" "static" // CHECK-ELFv1-LE: "-target-abi" "elfv1" -// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2" +// CHECK-ELFv1-QPX: "-mrelocation-model" "static" // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx" // CHECK-ELFv2: "-mrelocation-model" "static" // CHECK-ELFv2: "-target-abi" "elfv2" -// CHECK-ELFv2-BE: "-mrelocation-model" "pic" "-pic-level" "2" +// CHECK-ELFv2-BE: "-mrelocation-model" "static" // CHECK-ELFv2-BE: "-target-abi" "elfv2" +// CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" +// CHECK-ELFv2-BE-PIE: "-target-abi" "elfv2" // RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ELFv1-PIC %s Index: clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -2615,9 +2615,6 @@ switch (getArch()) { case llvm::Triple::x86_64: return getTriple().isOSWindows(); - case llvm::Triple::ppc64: - // Big endian PPC is PIC by default - return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX(); case llvm::Triple::mips64: case llvm::Triple::mips64el: return true;
Index: clang/test/Driver/ppc-abi.c =================================================================== --- clang/test/Driver/ppc-abi.c +++ clang/test/Driver/ppc-abi.c @@ -28,18 +28,20 @@ // RUN: %clang -target powerpc64-unknown-freebsd12 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv1 %s // RUN: %clang -target powerpc64-unknown-freebsd13 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s // RUN: %clang -target powerpc64-unknown-freebsd14 %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s -// RUN: %clang -target powerpc64-linux-musl %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE %s +// RUN: %clang -target powerpc64-linux-musl %s -### 2>&1 | FileCheck --check-prefix=CHECK-ELFv2-BE-PIE %s -// CHECK-ELFv1: "-mrelocation-model" "pic" "-pic-level" "2" +// CHECK-ELFv1: "-mrelocation-model" "static" // CHECK-ELFv1: "-target-abi" "elfv1" // CHECK-ELFv1-LE: "-mrelocation-model" "static" // CHECK-ELFv1-LE: "-target-abi" "elfv1" -// CHECK-ELFv1-QPX: "-mrelocation-model" "pic" "-pic-level" "2" +// CHECK-ELFv1-QPX: "-mrelocation-model" "static" // CHECK-ELFv1-QPX: "-target-abi" "elfv1-qpx" // CHECK-ELFv2: "-mrelocation-model" "static" // CHECK-ELFv2: "-target-abi" "elfv2" -// CHECK-ELFv2-BE: "-mrelocation-model" "pic" "-pic-level" "2" +// CHECK-ELFv2-BE: "-mrelocation-model" "static" // CHECK-ELFv2-BE: "-target-abi" "elfv2" +// CHECK-ELFv2-BE-PIE: "-mrelocation-model" "pic" "-pic-level" "2" "-pic-is-pie" +// CHECK-ELFv2-BE-PIE: "-target-abi" "elfv2" // RUN: %clang -fPIC -target powerpc64-unknown-linux-gnu %s -### -o %t.o 2>&1 \ // RUN: | FileCheck -check-prefix=CHECK-ELFv1-PIC %s Index: clang/lib/Driver/ToolChains/Gnu.cpp =================================================================== --- clang/lib/Driver/ToolChains/Gnu.cpp +++ clang/lib/Driver/ToolChains/Gnu.cpp @@ -2615,9 +2615,6 @@ switch (getArch()) { case llvm::Triple::x86_64: return getTriple().isOSWindows(); - case llvm::Triple::ppc64: - // Big endian PPC is PIC by default - return !getTriple().isOSBinFormatMachO() && !getTriple().isMacOSX(); case llvm::Triple::mips64: case llvm::Triple::mips64el: return true;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits