Make PS4 use -fno-use-init-array only as the ABI does not support .init_array.

Reviewed by Paul Robinson
This commit is contained in:
Douglas Yung 2020-03-26 15:45:40 -07:00
parent b0da094983
commit 5db37f3bca
3 changed files with 34 additions and 0 deletions

View File

@ -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");
}

View File

@ -88,6 +88,11 @@ public:
// 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,

View File

@ -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'