[clang] 5db37f3 - Make PS4 use -fno-use-init-array only as the ABI does not support .init_array.
Douglas Yung via cfe-commits
cfe-commits at lists.llvm.org
Thu Mar 26 15:47:03 PDT 2020
Author: Douglas Yung
Date: 2020-03-26T15:45:40-07:00
New Revision: 5db37f3bca3d404b0d7fcbe1dc764ee67665e6c2
URL: https://github.com/llvm/llvm-project/commit/5db37f3bca3d404b0d7fcbe1dc764ee67665e6c2
DIFF: https://github.com/llvm/llvm-project/commit/5db37f3bca3d404b0d7fcbe1dc764ee67665e6c2.diff
LOG: Make PS4 use -fno-use-init-array only as the ABI does not support .init_array.
Reviewed by Paul Robinson
Added:
clang/test/Driver/ps4cpu.c
Modified:
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/lib/Driver/ToolChains/PS4CPU.h
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 9ecbb7241d45..2c0d8d05d7c0 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -434,3 +434,15 @@ SanitizerMask toolchains::PS4CPU::getSupportedSanitizers() const {
Res |= SanitizerKind::Vptr;
return Res;
}
+
+void toolchains::PS4CPU::addClangTargetOptions(
+ const ArgList &DriverArgs,
+ ArgStringList &CC1Args,
+ Action::OffloadKind DeviceOffloadingKind) const {
+ // PS4 does not use init arrays.
+ if (DriverArgs.hasArg(clang::driver::options::OPT_fuse_init_array))
+ getDriver().Diag(clang::diag::err_drv_unsupported_opt_for_target)
+ << "-fuse-init-array" << getTriple().str();
+
+ CC1Args.push_back("-fno-use-init-array");
+}
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.h b/clang/lib/Driver/ToolChains/PS4CPU.h
index c82b0c3a1b56..8fedb6eda0ef 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.h
+++ b/clang/lib/Driver/ToolChains/PS4CPU.h
@@ -88,6 +88,11 @@ class LLVM_LIBRARY_VISIBILITY PS4CPU : public Generic_ELF {
// capable of unit splitting.
bool canSplitThinLTOUnit() const override { return false; }
+ void addClangTargetOptions(
+ const llvm::opt::ArgList &DriverArgs,
+ llvm::opt::ArgStringList &CC1Args,
+ Action::OffloadKind DeviceOffloadingKind) const override;
+
llvm::DenormalMode getDefaultDenormalModeForType(
const llvm::opt::ArgList &DriverArgs,
Action::OffloadKind DeviceOffloadKind,
diff --git a/clang/test/Driver/ps4cpu.c b/clang/test/Driver/ps4cpu.c
new file mode 100644
index 000000000000..ac5f3fcdc844
--- /dev/null
+++ b/clang/test/Driver/ps4cpu.c
@@ -0,0 +1,17 @@
+// REQUIRES: x86-registered-target
+
+// Test that the driver always emits -fno-use-init-array on the PS4 target
+// since its ABI does not support the .init_array section.
+
+// RUN: %clang -c %s -target x86_64-scei-ps4 -### 2>&1 \
+// RUN: | FileCheck %s
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fno-use-init-array -### 2>&1 \
+// RUN: | FileCheck %s
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fuse-init-array -### 2>&1 \
+// RUN: | FileCheck %s --check-prefix=CHECK-ERROR
+
+// CHECK: "-fno-use-init-array"
+// CHECK-NOT: "-fuse-init-array"
+
+// CHECK-ERROR: unsupported option '-fuse-init-array' for target 'x86_64-scei-ps4'
+
More information about the cfe-commits
mailing list