[clang] 7726ad0 - [PS5] Add basic PS5 driver behavior
Paul Robinson via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 14 12:45:42 PDT 2022
Author: Paul Robinson
Date: 2022-04-14T12:45:33-07:00
New Revision: 7726ad04e2633a843fb9743e5adfbb404446e657
URL: https://github.com/llvm/llvm-project/commit/7726ad04e2633a843fb9743e5adfbb404446e657
DIFF: https://github.com/llvm/llvm-project/commit/7726ad04e2633a843fb9743e5adfbb404446e657.diff
LOG: [PS5] Add basic PS5 driver behavior
This adds a PS5-specific ToolChain subclass, which defines some basic
PS5 driver behavior. Future patches will add more target-specific
driver behavior.
Added:
clang/test/Driver/ps4-ps5-header-search.c
clang/test/Driver/ps4-ps5-linker-non-win.c
clang/test/Driver/ps4-ps5-linker-win.c
clang/test/Driver/ps4-ps5-relax-relocations.c
clang/test/Driver/ps4-ps5-runtime-flags.c
clang/test/Driver/ps4ps5base.c
clang/test/Driver/ps5-sdk-root.c
Modified:
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Clang.cpp
clang/lib/Driver/ToolChains/PS4CPU.cpp
clang/lib/Driver/ToolChains/PS4CPU.h
clang/lib/Lex/InitHeaderSearch.cpp
clang/test/Driver/inhibit-downstream-commands.c
clang/test/Driver/no-integrated-as.c
clang/test/Driver/no-integrated-as.s
Removed:
clang/test/Driver/ps4-header-search.c
clang/test/Driver/ps4-linker-non-win.c
clang/test/Driver/ps4-linker-win.c
clang/test/Driver/ps4-relax-relocations.c
clang/test/Driver/ps4-runtime-flags.c
clang/test/Driver/ps4cpu.c
################################################################################
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 392364ce22bad..8de1a364092dc 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -5672,6 +5672,9 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::PS4:
TC = std::make_unique<toolchains::PS4CPU>(*this, Target, Args);
break;
+ case llvm::Triple::PS5:
+ TC = std::make_unique<toolchains::PS5CPU>(*this, Target, Args);
+ break;
case llvm::Triple::Contiki:
TC = std::make_unique<toolchains::Contiki>(*this, Target, Args);
break;
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index bf47212374ce4..8aefcaeed37dc 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5541,11 +5541,11 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.AddLastArg(CmdArgs, options::OPT_fclang_abi_compat_EQ);
- // Add runtime flag for PS4 when PGO, coverage, or sanitizers are enabled.
- if (RawTriple.isPS4() &&
+ // Add runtime flag for PS4/PS5 when PGO, coverage, or sanitizers are enabled.
+ if (RawTriple.isPS() &&
!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs)) {
- PS4cpu::addProfileRTArgs(TC, Args, CmdArgs);
- PS4cpu::addSanitizerArgs(TC, Args, CmdArgs);
+ PScpu::addProfileRTArgs(TC, Args, CmdArgs);
+ PScpu::addSanitizerArgs(TC, Args, CmdArgs);
}
// Pass options for controlling the default header search paths.
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 154eb78ce207c..3c8798ebbc511 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -29,8 +29,8 @@ static const char *makeArgString(const ArgList &Args, const char *Prefix,
return Args.MakeArgString(Twine(StringRef(Prefix), Base) + Suffix);
}
-void tools::PS4cpu::addProfileRTArgs(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+void tools::PScpu::addProfileRTArgs(const ToolChain &TC, const ArgList &Args,
+ ArgStringList &CmdArgs) {
assert(TC.getTriple().isPS());
auto &PSTC = static_cast<const toolchains::PS4PS5Base &>(TC);
@@ -54,11 +54,11 @@ void tools::PS4cpu::addProfileRTArgs(const ToolChain &TC, const ArgList &Args,
Args, "--dependent-lib=", PSTC.getProfileRTLibName(), ""));
}
-void tools::PS4cpu::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &Args,
- const char *LinkingOutput) const {
+void tools::PScpu::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
auto &TC = static_cast<const toolchains::PS4PS5Base &>(getToolChain());
claimNoWarnArgs(Args);
ArgStringList CmdArgs;
@@ -80,8 +80,8 @@ void tools::PS4cpu::Assemble::ConstructJob(Compilation &C, const JobAction &JA,
Exec, CmdArgs, Inputs, Output));
}
-void tools::PS4cpu::addSanitizerArgs(const ToolChain &TC, const ArgList &Args,
- ArgStringList &CmdArgs) {
+void tools::PScpu::addSanitizerArgs(const ToolChain &TC, const ArgList &Args,
+ ArgStringList &CmdArgs) {
assert(TC.getTriple().isPS());
auto &PSTC = static_cast<const toolchains::PS4PS5Base &>(TC);
PSTC.addSanitizerArgs(Args, CmdArgs, "--dependent-lib=lib", ".a");
@@ -101,11 +101,27 @@ void toolchains::PS4CPU::addSanitizerArgs(const ArgList &Args,
CmdArgs.push_back(arg("SceDbgAddressSanitizer_stub_weak"));
}
-void tools::PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
- const InputInfo &Output,
- const InputInfoList &Inputs,
- const ArgList &Args,
- const char *LinkingOutput) const {
+void toolchains::PS5CPU::addSanitizerArgs(const ArgList &Args,
+ ArgStringList &CmdArgs,
+ const char *Prefix,
+ const char *Suffix) const {
+ auto arg = [&](const char *Name) -> const char * {
+ return makeArgString(Args, Prefix, Name, Suffix);
+ };
+ const SanitizerArgs &SanArgs = getSanitizerArgs(Args);
+ if (SanArgs.needsUbsanRt())
+ CmdArgs.push_back(arg("SceUBSanitizer_nosubmission_stub_weak"));
+ if (SanArgs.needsAsanRt())
+ CmdArgs.push_back(arg("SceAddressSanitizer_nosubmission_stub_weak"));
+ if (SanArgs.needsTsanRt())
+ CmdArgs.push_back(arg("SceThreadSanitizer_nosubmission_stub_weak"));
+}
+
+void tools::PScpu::Link::ConstructJob(Compilation &C, const JobAction &JA,
+ const InputInfo &Output,
+ const InputInfoList &Inputs,
+ const ArgList &Args,
+ const char *LinkingOutput) const {
auto &TC = static_cast<const toolchains::PS4PS5Base &>(getToolChain());
const Driver &D = TC.getDriver();
ArgStringList CmdArgs;
@@ -228,12 +244,18 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
getFilePaths().push_back(std::string(SDKLibDir.str()));
}
-Tool *toolchains::PS4PS5Base::buildAssembler() const {
- return new tools::PS4cpu::Assemble(*this);
+Tool *toolchains::PS4CPU::buildAssembler() const {
+ return new tools::PScpu::Assemble(*this);
+}
+
+Tool *toolchains::PS5CPU::buildAssembler() const {
+ // PS5 does not support an external assembler.
+ getDriver().Diag(clang::diag::err_no_external_assembler);
+ return nullptr;
}
Tool *toolchains::PS4PS5Base::buildLinker() const {
- return new tools::PS4cpu::Link(*this);
+ return new tools::PScpu::Link(*this);
}
SanitizerMask toolchains::PS4PS5Base::getSupportedSanitizers() const {
@@ -245,6 +267,12 @@ SanitizerMask toolchains::PS4PS5Base::getSupportedSanitizers() const {
return Res;
}
+SanitizerMask toolchains::PS5CPU::getSupportedSanitizers() const {
+ SanitizerMask Res = PS4PS5Base::getSupportedSanitizers();
+ Res |= SanitizerKind::Thread;
+ return Res;
+}
+
void toolchains::PS4PS5Base::addClangTargetOptions(
const ArgList &DriverArgs, ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadingKind) const {
@@ -294,3 +322,8 @@ void toolchains::PS4PS5Base::addClangTargetOptions(
toolchains::PS4CPU::PS4CPU(const Driver &D, const llvm::Triple &Triple,
const llvm::opt::ArgList &Args)
: PS4PS5Base(D, Triple, Args, "PS4", "SCE_ORBIS_SDK_DIR") {}
+
+// PS5 toolchain.
+toolchains::PS5CPU::PS5CPU(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args)
+ : PS4PS5Base(D, Triple, Args, "PS5", "SCE_PROSPERO_SDK_DIR") {}
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.h b/clang/lib/Driver/ToolChains/PS4CPU.h
index dbb9c14b6373c..dd6d7df432a4f 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.h
+++ b/clang/lib/Driver/ToolChains/PS4CPU.h
@@ -18,7 +18,8 @@ namespace clang {
namespace driver {
namespace tools {
-namespace PS4cpu {
+namespace PScpu {
+// Functions/classes in this namespace support both PS4 and PS5.
void addProfileRTArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs);
@@ -28,7 +29,7 @@ void addSanitizerArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
public:
- Assemble(const ToolChain &TC) : Tool("PS4cpu::Assemble", "assembler", TC) {}
+ Assemble(const ToolChain &TC) : Tool("PScpu::Assemble", "assembler", TC) {}
bool hasIntegratedCPP() const override { return false; }
@@ -40,7 +41,7 @@ class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {
class LLVM_LIBRARY_VISIBILITY Link : public Tool {
public:
- Link(const ToolChain &TC) : Tool("PS4cpu::Link", "linker", TC) {}
+ Link(const ToolChain &TC) : Tool("PScpu::Link", "linker", TC) {}
bool hasIntegratedCPP() const override { return false; }
bool isLinkJob() const override { return true; }
@@ -50,7 +51,7 @@ class LLVM_LIBRARY_VISIBILITY Link : public Tool {
const llvm::opt::ArgList &TCArgs,
const char *LinkingOutput) const override;
};
-} // end namespace PS4cpu
+} // namespace PScpu
} // namespace tools
namespace toolchains {
@@ -109,7 +110,6 @@ class LLVM_LIBRARY_VISIBILITY PS4PS5Base : public Generic_ELF {
virtual const char *getProfileRTLibName() const = 0;
protected:
- Tool *buildAssembler() const override;
Tool *buildLinker() const override;
};
@@ -135,6 +135,34 @@ class LLVM_LIBRARY_VISIBILITY PS4CPU : public PS4PS5Base {
const char *getProfileRTLibName() const override {
return "libclang_rt.profile-x86_64.a";
}
+
+protected:
+ Tool *buildAssembler() const override;
+};
+
+// PS5-specific Toolchain class.
+class LLVM_LIBRARY_VISIBILITY PS5CPU : public PS4PS5Base {
+public:
+ PS5CPU(const Driver &D, const llvm::Triple &Triple,
+ const llvm::opt::ArgList &Args);
+
+ unsigned GetDefaultDwarfVersion() const override { return 5; }
+
+ SanitizerMask getSupportedSanitizers() const override;
+
+ const char *getLinkerBaseName() const override { return "lld"; }
+ std::string qualifyPSCmdName(StringRef CmdName) const override {
+ return Twine("prospero-", CmdName).str();
+ }
+ void addSanitizerArgs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs, const char *Prefix,
+ const char *Suffix) const override;
+ const char *getProfileRTLibName() const override {
+ return "libclang_rt.profile-x86_64_nosubmission.a";
+ }
+
+protected:
+ Tool *buildAssembler() const override;
};
} // end namespace toolchains
diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp
index 86c6768d0d9fa..158b5667151f6 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -239,6 +239,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
case llvm::Triple::OpenBSD:
case llvm::Triple::NaCl:
case llvm::Triple::PS4:
+ case llvm::Triple::PS5:
case llvm::Triple::ELFIAMCU:
case llvm::Triple::Fuchsia:
break;
@@ -351,11 +352,14 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
case llvm::Triple::ELFIAMCU:
case llvm::Triple::Fuchsia:
break;
- case llvm::Triple::PS4: {
+ case llvm::Triple::PS4:
+ case llvm::Triple::PS5: {
// <isysroot> gets prepended later in AddPath().
std::string BaseSDKPath;
if (!HasSysroot) {
- const char *envValue = getenv("SCE_ORBIS_SDK_DIR");
+ const char *EnvVar = (os == llvm::Triple::PS4) ? "SCE_ORBIS_SDK_DIR"
+ : "SCE_PROSPERO_SDK_DIR";
+ const char *envValue = getenv(EnvVar);
if (envValue)
BaseSDKPath = envValue;
else {
@@ -370,8 +374,7 @@ void InitHeaderSearch::AddDefaultCIncludePaths(const llvm::Triple &triple,
}
}
AddPath(BaseSDKPath + "/target/include", System, false);
- if (triple.isPS4())
- AddPath(BaseSDKPath + "/target/include_common", System, false);
+ AddPath(BaseSDKPath + "/target/include_common", System, false);
break;
}
default:
diff --git a/clang/test/Driver/inhibit-downstream-commands.c b/clang/test/Driver/inhibit-downstream-commands.c
index 43f4480a801a9..b4086bd4d4e2c 100644
--- a/clang/test/Driver/inhibit-downstream-commands.c
+++ b/clang/test/Driver/inhibit-downstream-commands.c
@@ -1,6 +1,6 @@
// RUN: not %clang -no-integrated-as %s 2>&1 | FileCheck %s
// CHECK: error: unknown type name 'invalid'
-// CHECK-NOT: clang: error: assembler command failed
+// CHECK-NOT: clang: error: assembler command failed
// CHECK-NOT: clang: error: linker command failed
-// XFAIL: windows-msvc
+// XFAIL: windows-msvc, ps5
invalid C code!
diff --git a/clang/test/Driver/no-integrated-as.c b/clang/test/Driver/no-integrated-as.c
index 12717158a5cc3..6f45a6050e9fd 100644
--- a/clang/test/Driver/no-integrated-as.c
+++ b/clang/test/Driver/no-integrated-as.c
@@ -12,3 +12,9 @@
// RUN: %clang -target msp430 -### -c %s 2>&1 | FileCheck %s -check-prefix DEFAULT
// DEFAULT-NOT: -no-integrated-as
+
+// RUN: %clang -target x86_64-sie-ps5 -### -no-integrated-as %s -c 2>&1 \
+// RUN: | FileCheck %s -check-prefix PS5
+// RUN: %clang -target x86_64-sie-ps5 -### -no-integrated-as %s -c -x assembler 2>&1 \
+// RUN: | FileCheck %s -check-prefix PS5
+// PS5: there is no external assembler that can be used on this platform
diff --git a/clang/test/Driver/no-integrated-as.s b/clang/test/Driver/no-integrated-as.s
index bf6e69dd81967..16a1f0535cc14 100644
--- a/clang/test/Driver/no-integrated-as.s
+++ b/clang/test/Driver/no-integrated-as.s
@@ -1,6 +1,6 @@
; RUN: %clang -### -no-integrated-as -c %s 2>&1 | FileCheck %s -check-prefix IAS
-; Windows doesn't support no-integrated-as
-; XFAIL: windows-msvc
+; Windows and PS5 don't support no-integrated-as
+; XFAIL: windows-msvc, ps5
;
; Make sure the current file's filename appears in the output.
; We can't generically match on the assembler name, so we just make sure
diff --git a/clang/test/Driver/ps4-linker-win.c b/clang/test/Driver/ps4-linker-win.c
deleted file mode 100644
index 05c8a50ce0e15..0000000000000
--- a/clang/test/Driver/ps4-linker-win.c
+++ /dev/null
@@ -1,19 +0,0 @@
-// This test check that orbis-ld is used for linker all the time. Specifying
-// linker using -fuse-ld causes a error message emitted and compilation fail.
-
-// REQUIRES: system-windows, x86-registered-target
-
-// RUN: mkdir -p %t
-// RUN: touch %t/orbis-ld.exe
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -### 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -shared -### 2>&1 \
-// RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s
-
-// CHECK-PS4-LINKER: \\orbis-ld
-
-// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
-// RUN: | FileCheck --check-prefix=ERROR %s
-
-// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
diff --git a/clang/test/Driver/ps4-header-search.c b/clang/test/Driver/ps4-ps5-header-search.c
similarity index 65%
rename from clang/test/Driver/ps4-header-search.c
rename to clang/test/Driver/ps4-ps5-header-search.c
index 20aaa5f97a749..6848901df5590 100644
--- a/clang/test/Driver/ps4-header-search.c
+++ b/clang/test/Driver/ps4-ps5-header-search.c
@@ -1,11 +1,14 @@
// REQUIRES: x86-registered-target
+/// PS4 and PS5 use the same SDK layout, so use the same tree for both.
// RUN: env SCE_ORBIS_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-scei-ps4 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
+// RUN: env SCE_PROSPERO_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-sie-ps5 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4
// ENVPS4: Inputs/scei-ps4_tree/target/include{{$}}
// ENVPS4: Inputs/scei-ps4_tree/target/include_common{{$}}
// ENVPS4-NOT: /usr/include
// RUN: %clang -isysroot %S/Inputs/scei-ps4_tree -target x86_64-scei-ps4 -E -v %s 2>&1 | FileCheck %s --check-prefix=SYSROOTPS4
+// RUN: %clang -isysroot %S/Inputs/scei-ps4_tree -target x86_64-sie-ps5 -E -v %s 2>&1 | FileCheck %s --check-prefix=SYSROOTPS4
// SYSROOTPS4: "{{[^"]*}}clang{{[^"]*}}"
// SYSROOTPS4: Inputs/scei-ps4_tree/target/include{{$}}
// SYSROOTPS4: Inputs/scei-ps4_tree/target/include_common{{$}}
diff --git a/clang/test/Driver/ps4-linker-non-win.c b/clang/test/Driver/ps4-ps5-linker-non-win.c
similarity index 52%
rename from clang/test/Driver/ps4-linker-non-win.c
rename to clang/test/Driver/ps4-ps5-linker-non-win.c
index 69fb10b9159ce..cd7cd8e11ea07 100644
--- a/clang/test/Driver/ps4-linker-non-win.c
+++ b/clang/test/Driver/ps4-ps5-linker-non-win.c
@@ -1,3 +1,4 @@
+/// Checks proper linker prefixing for PS4 and PS5.
// UNSUPPORTED: system-windows
// REQUIRES: x86-registered-target
@@ -5,15 +6,25 @@
// RUN: rm -f %t/orbis-ld
// RUN: touch %t/orbis-ld
// RUN: chmod +x %t/orbis-ld
+// RUN: rm -f %t/prospero-lld
+// RUN: touch %t/prospero-lld
+// RUN: chmod +x %t/prospero-lld
// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s
// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -shared 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-sie-ps5 %s 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PS5-LINKER %s
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-sie-ps5 %s -shared 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PS5-LINKER %s
// CHECK-PS4-LINKER: /orbis-ld
+// CHECK-PS5-LINKER: /prospero-lld
// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-scei-ps4 %s -fuse-ld=gold 2>&1 \
// RUN: | FileCheck --check-prefix=ERROR %s
+// RUN: env "PATH=%t:%PATH%" %clang -### -target x86_64-sie-ps5 %s -fuse-ld=gold 2>&1 \
+// RUN: | FileCheck --check-prefix=ERROR %s
-// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-scei-ps4'
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-{{(scei|sie)}}-ps{{[45]}}'
diff --git a/clang/test/Driver/ps4-ps5-linker-win.c b/clang/test/Driver/ps4-ps5-linker-win.c
new file mode 100644
index 0000000000000..ca4084d4fccff
--- /dev/null
+++ b/clang/test/Driver/ps4-ps5-linker-win.c
@@ -0,0 +1,27 @@
+// This test checks that orbis-ld is used for PS4 linker all the time, and
+// prospero-lld is used for PS5 linker. Specifying -fuse-ld causes an error.
+
+// REQUIRES: system-windows, x86-registered-target
+
+// RUN: mkdir -p %t
+// RUN: touch %t/orbis-ld.exe
+// RUN: touch %t/prospero-lld.exe
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -shared -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PS4-LINKER %s
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-sie-ps5 %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PS5-LINKER %s
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-sie-ps5 %s -shared -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-PS5-LINKER %s
+
+// CHECK-PS4-LINKER: \\orbis-ld
+// CHECK-PS5-LINKER: \\prospero-lld
+
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-scei-ps4 %s -fuse-ld=gold -### 2>&1 \
+// RUN: | FileCheck --check-prefix=ERROR %s
+// RUN: env "PATH=%t;%PATH%;" %clang -target x86_64-sie-ps5 %s -fuse-ld=gold -### 2>&1 \
+// RUN: | FileCheck --check-prefix=ERROR %s
+
+// ERROR: error: unsupported option '-fuse-ld' for target 'x86_64-{{(scei|sie)}}-ps{{[45]}}'
diff --git a/clang/test/Driver/ps4-relax-relocations.c b/clang/test/Driver/ps4-ps5-relax-relocations.c
similarity index 52%
rename from clang/test/Driver/ps4-relax-relocations.c
rename to clang/test/Driver/ps4-ps5-relax-relocations.c
index b22cd2e8d8640..1c8200a6d58be 100644
--- a/clang/test/Driver/ps4-relax-relocations.c
+++ b/clang/test/Driver/ps4-ps5-relax-relocations.c
@@ -13,6 +13,19 @@
// RUN: %clang -### -x assembler -target x86_64-scei-ps4 -Wa,-mrelax-relocations=no %s -o - 2>&1 | \
// RUN: FileCheck -check-prefix=UNSET %s
+// RUN: %clang -### -target x86_64-sie-ps5 %s -o - 2>&1 | \
+// RUN: FileCheck %s
+// RUN: %clang -### -target x86_64-sie-ps5 -Wa,-mrelax-relocations=yes %s -o - 2>&1 | \
+// RUN: FileCheck %s
+// RUN: %clang -### -target x86_64-sie-ps5 -Wa,-mrelax-relocations=no %s -o - 2>&1 | \
+// RUN: FileCheck -check-prefix=UNSET %s
+// RUN: %clang -### -x assembler -target x86_64-sie-ps5 %s -o - 2>&1 | \
+// RUN: FileCheck %s
+// RUN: %clang -### -x assembler -target x86_64-sie-ps5 -Wa,-mrelax-relocations=yes %s -o - 2>&1 | \
+// RUN: FileCheck %s
+// RUN: %clang -### -x assembler -target x86_64-sie-ps5 -Wa,-mrelax-relocations=no %s -o - 2>&1 | \
+// RUN: FileCheck -check-prefix=UNSET %s
+
// CHECK: "--mrelax-relocations"
// UNSET-NOT: "--mrelax-relocations"
diff --git a/clang/test/Driver/ps4-ps5-runtime-flags.c b/clang/test/Driver/ps4-ps5-runtime-flags.c
new file mode 100644
index 0000000000000..96c9c1244dddc
--- /dev/null
+++ b/clang/test/Driver/ps4-ps5-runtime-flags.c
@@ -0,0 +1,46 @@
+// REQUIRES: x86-registered-target
+//
+/// Test the profile runtime library to be linked for PS4/PS5 compiler.
+/// Check runtime flag --dependent-lib which does not append the default library search path.
+//
+/// PS4 case.
+// RUN: %clang -target x86_64-scei-ps4 --coverage %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fno-profile-arcs -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fno-profile-arcs %s -### 2>&1 | FileCheck -check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-arcs -fno-profile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate=dir %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate=somefile.profraw %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fcs-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
+// RUN: %clang -target x86_64-scei-ps4 -fcs-profile-generate -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
+//
+// CHECK-PS4-PROFILE: "--dependent-lib=libclang_rt.profile-x86_64.a"
+// CHECK-PS4-NO-PROFILE-NOT: "--dependent-lib=libclang_rt.profile-x86_64.a"
+//
+/// PS5 case.
+// RUN: %clang -target x86_64-sie-ps5 --coverage %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fno-profile-arcs -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fno-profile-arcs %s -### 2>&1 | FileCheck -check-prefix=CHECK-PS5-NO-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-arcs -fno-profile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-NO-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-NO-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-generate -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-NO-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-generate=dir %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-NO-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-instr-generate -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-NO-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-generate -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fprofile-instr-generate=somefile.profraw %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fcs-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-PROFILE %s
+// RUN: %clang -target x86_64-sie-ps5 -fcs-profile-generate -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS5-NO-PROFILE %s
+//
+// CHECK-PS5-PROFILE: "--dependent-lib=libclang_rt.profile-x86_64_nosubmission.a"
+// CHECK-PS5-NO-PROFILE-NOT: "--dependent-lib=libclang_rt.profile-x86_64_nosubmission.a"
diff --git a/clang/test/Driver/ps4-runtime-flags.c b/clang/test/Driver/ps4-runtime-flags.c
deleted file mode 100644
index 3131690304dbf..0000000000000
--- a/clang/test/Driver/ps4-runtime-flags.c
+++ /dev/null
@@ -1,24 +0,0 @@
-// REQUIRES: x86-registered-target
-//
-// Test the profile runtime library to be linked for PS4 compiler.
-// Check PS4 runtime flag --dependent-lib which does not append the default library search path.
-//
-// RUN: %clang -target x86_64-scei-ps4 --coverage %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fno-profile-arcs -fprofile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fno-profile-arcs %s -### 2>&1 | FileCheck -check-prefix=CHECK-PS4-NO-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-arcs -fno-profile-arcs %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate=dir %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-generate -fno-profile-instr-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fprofile-instr-generate=somefile.profraw %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fcs-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-PROFILE %s
-// RUN: %clang -target x86_64-scei-ps4 -fcs-profile-generate -fno-profile-generate %s -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-NO-PROFILE %s
-//
-// CHECK-PS4-PROFILE: "--dependent-lib=libclang_rt.profile-x86_64.a"
-// CHECK-PS4-NO-PROFILE-NOT: "--dependent-lib=libclang_rt.profile-x86_64.a"
diff --git a/clang/test/Driver/ps4cpu.c b/clang/test/Driver/ps4ps5base.c
similarity index 55%
rename from clang/test/Driver/ps4cpu.c
rename to clang/test/Driver/ps4ps5base.c
index ac5f3fcdc8441..bd583f88dd6ec 100644
--- a/clang/test/Driver/ps4cpu.c
+++ b/clang/test/Driver/ps4ps5base.c
@@ -1,17 +1,22 @@
// 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.
+// Test that the driver always emits -fno-use-init-array on the PS4/PS5 targets
+// since their 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-sie-ps5 -### 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-sie-ps5 -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
+// RUN: %clang -c %s -target x86_64-sie-ps5 -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'
-
+// CHECK-ERROR: unsupported option '-fuse-init-array' for target 'x86_64-{{(scei|sie)}}-ps{{[45]}}'
diff --git a/clang/test/Driver/ps5-sdk-root.c b/clang/test/Driver/ps5-sdk-root.c
new file mode 100644
index 0000000000000..79f6132afc04d
--- /dev/null
+++ b/clang/test/Driver/ps5-sdk-root.c
@@ -0,0 +1,50 @@
+// REQUIRES: x86-registered-target
+
+/// (Essentially identical to ps4-sdk-root.c except for the target.)
+
+/// Check that PS5 clang doesn't report a warning message when locating
+/// system header files (either by looking at the value of SCE_PROSPERO_SDK_DIR
+/// or relative to the location of the compiler driver), if "-nostdinc",
+/// "--sysroot" or "-isysroot" option is specified on the command line.
+/// Otherwise, check that PS5 clang reports a warning.
+
+// Check that PS5 clang doesn't report a warning message when locating
+// system libraries (either by looking at the value of SCE_PROSPERO_SDK_DIR
+// or relative to the location of the compiler driver), if "-c", "-S", "-E",
+// "--sysroot", "-nostdlib" or "-nodefaultlibs" option is specified on
+// the command line.
+// Otherwise, check that PS5 clang reports a warning.
+
+// Setting up SCE_PROSPERO_SDK_DIR to existing location, which is not a PS4 SDK.
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -isysroot foo -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -nostdinc -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -nostdinc -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -nostdinc -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -nostdinc -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c --sysroot=foo/ -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S --sysroot=foo/ -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E --sysroot=foo/ -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast --sysroot=foo/ -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -isysroot foo -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -isysroot foo -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -isysroot foo -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -isysroot foo -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### --sysroot=foo/ -isysroot foo -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s
+
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -nostdlib -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -nodefaultlibs -target x86_64-sie-ps5 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s
+
+// NO-WARN-NOT: {{warning:|error:}}
+// WARN-SYS-HEADERS: warning: unable to find PS5 system headers directory
+// WARN-ISYSROOT: warning: no such sysroot directory: 'foo'
+// WARN-SYS-LIBS: warning: unable to find PS5 system libraries directory
+// NO-WARN-NOT: {{warning:|error:}}
More information about the cfe-commits
mailing list