<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Wed, Oct 14, 2015 at 5:25 AM, Filipe Cabecinhas via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: filcab<br>
Date: Wed Oct 14 07:25:43 2015<br>
New Revision: 250293<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=250293&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=250293&view=rev</a><br>
Log:<br>
Bring back r250262: PS4 toolchain<br>
<br>
There was a minor problem with a test. Sorry for the noise yesterday.<br>
<br>
This patch adds missing pieces to clang, including the PS4 toolchain<br>
definition, added warnings, PS4 defaults, and Driver changes needed for<br>
our compiler.<br>
<br>
A patch by Filipe Cabecinhas, Pierre Gousseau and Katya Romanova!<br>
<br>
Differential Revision: <a href="http://reviews.llvm.org/D13482" rel="noreferrer" target="_blank">http://reviews.llvm.org/D13482</a><br>
<br>
Added:<br>
    cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include/.keep<br>
    cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep<br>
    cfe/trunk/test/Driver/no-integrated-as.s<br>
    cfe/trunk/test/Driver/ps4-header-search.c<br>
    cfe/trunk/test/Driver/ps4-linker-non-win.c<br>
    cfe/trunk/test/Driver/ps4-linker-win.c<br>
    cfe/trunk/test/Driver/ps4-pic.c<br>
    cfe/trunk/test/Driver/ps4-sdk-root.c<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td<br>
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td<br>
    cfe/trunk/lib/Driver/Driver.cpp<br>
    cfe/trunk/lib/Driver/ToolChains.cpp<br>
    cfe/trunk/lib/Driver/ToolChains.h<br>
    cfe/trunk/lib/Driver/Tools.cpp<br>
    cfe/trunk/lib/Driver/Tools.h<br>
    cfe/trunk/lib/Frontend/InitHeaderSearch.cpp<br>
    cfe/trunk/test/Driver/debug-options.c<br>
    cfe/trunk/test/Driver/stack-protector.c<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Oct 14 07:25:43 2015<br>
@@ -196,4 +196,18 @@ def warn_target_unsupported_nan2008 : Wa<br>
 def warn_target_unsupported_nanlegacy : Warning<<br>
   "ignoring '-mnan=legacy' option because the '%0' architecture does not support it">,<br>
   InGroup<UnsupportedNan>;<br>
+<br>
+def warn_drv_unable_to_find_directory_expected : Warning<<br>
+  "unable to find %0 directory, expected to be in '%1'">,<br>
+  InGroup<InvalidOrNonExistentDirectory>, DefaultIgnore;<br>
+<br>
+def warn_drv_ps4_force_pic : Warning<<br>
+  "option '%0' was ignored by the PS4 toolchain, using '-fPIC'">,<br>
+  InGroup<OptionIgnored>;<br></blockquote><div><br></div><div>Should this use the existing UnusedCommandLineArgument instead of introducing a new group?</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
+<br>
+def warn_drv_ps4_sdk_dir : Warning<<br>
+  "environment variable SCE_PS4_SDK_DIR is set, but points to invalid or nonexistent directory '%0'">,<br>
+  InGroup<InvalidOrNonExistentDirectory>;<br>
+<br>
+def err_drv_unsupported_linker : Error<"unsupported value '%0' for -linker option">;<br>
 }<br>
<br>
Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)<br>
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Oct 14 07:25:43 2015<br>
@@ -823,3 +823,7 @@ def CudaCompat : DiagGroup<"cuda-compat"<br>
<br>
 // A warning group for things that will change semantics in the future.<br>
 def FutureCompat : DiagGroup<"future-compat">;<br>
+<br>
+def InvalidOrNonExistentDirectory : DiagGroup<"invalid-or-nonexistent-directory">;<br>
+<br>
+def OptionIgnored : DiagGroup<"option-ignored">;<br>
<br>
Modified: cfe/trunk/lib/Driver/Driver.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Driver.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Driver.cpp Wed Oct 14 07:25:43 2015<br>
@@ -2261,6 +2261,9 @@ const ToolChain &Driver::getToolChain(co<br>
     case llvm::Triple::CUDA:<br>
       TC = new toolchains::CudaToolChain(*this, Target, Args);<br>
       break;<br>
+    case llvm::Triple::PS4:<br>
+      TC = new toolchains::PS4CPU(*this, Target, Args);<br>
+      break;<br>
     default:<br>
       // Of these targets, Hexagon is the only one that might have<br>
       // an OS of Linux, in which case it got handled above already.<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains.cpp Wed Oct 14 07:25:43 2015<br>
@@ -4066,3 +4066,77 @@ void WebAssembly::addClangTargetOptions(<br>
                          options::OPT_fno_use_init_array, true))<br>
     CC1Args.push_back("-fuse-init-array");<br>
 }<br>
+<br>
+PS4CPU::PS4CPU(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)<br>
+    : Generic_ELF(D, Triple, Args) {<br>
+  if (Args.hasArg(options::OPT_static))<br>
+    D.Diag(diag::err_drv_unsupported_opt_for_target) << "-static" << "PS4";<br>
+<br>
+  // Determine where to find the PS4 libraries. We use SCE_PS4_SDK_DIR<br>
+  // if it exists; otherwise use the driver's installation path, which<br>
+  // should be <SDK_DIR>/host_tools/bin.<br>
+<br>
+  SmallString<512> PS4SDKDir;<br>
+  if (const char *EnvValue = getenv("SCE_PS4_SDK_DIR")) {<br>
+    if (!llvm::sys::fs::exists(EnvValue))<br>
+      getDriver().Diag(clang::diag::warn_drv_ps4_sdk_dir) << EnvValue;<br>
+    PS4SDKDir = EnvValue;<br>
+  } else {<br>
+    PS4SDKDir = getDriver().Dir;<br>
+    llvm::sys::path::append(PS4SDKDir, "/../../");<br>
+  }<br>
+<br>
+  // By default, the driver won't report a warning if it can't find<br>
+  // PS4's include or lib directories. This behavior could be changed if<br>
+  // -Weverything or -Winvalid-or-nonexistent-directory options are passed.<br>
+  // If -isysroot was passed, use that as the SDK base path.<br>
+  std::string PrefixDir;<br>
+  if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {<br>
+    PrefixDir = A->getValue();<br>
+    if (!llvm::sys::fs::exists(PrefixDir))<br>
+      getDriver().Diag(clang::diag::warn_missing_sysroot) << PrefixDir;<br>
+  } else<br>
+    PrefixDir = PS4SDKDir.str();<br>
+<br>
+  SmallString<512> PS4SDKIncludeDir(PrefixDir);<br>
+  llvm::sys::path::append(PS4SDKIncludeDir, "target/include");<br>
+  if (!Args.hasArg(options::OPT_nostdinc) &&<br>
+      !Args.hasArg(options::OPT_nostdlibinc) &&<br>
+      !Args.hasArg(options::OPT_isysroot) &&<br>
+      !Args.hasArg(options::OPT__sysroot_EQ) &&<br>
+      !llvm::sys::fs::exists(PS4SDKIncludeDir)) {<br>
+    getDriver().Diag(clang::diag::warn_drv_unable_to_find_directory_expected)<br>
+        << "PS4 system headers" << PS4SDKIncludeDir;<br>
+  }<br>
+<br>
+  SmallString<512> PS4SDKLibDir(PS4SDKDir);<br>
+  llvm::sys::path::append(PS4SDKLibDir, "target/lib");<br>
+  if (!Args.hasArg(options::OPT_nostdlib) &&<br>
+      !Args.hasArg(options::OPT_nodefaultlibs) &&<br>
+      !Args.hasArg(options::OPT__sysroot_EQ) && !Args.hasArg(options::OPT_E) &&<br>
+      !Args.hasArg(options::OPT_c) && !Args.hasArg(options::OPT_S) &&<br>
+      !Args.hasArg(options::OPT_emit_ast) &&<br>
+      !llvm::sys::fs::exists(PS4SDKLibDir)) {<br>
+    getDriver().Diag(clang::diag::warn_drv_unable_to_find_directory_expected)<br>
+        << "PS4 system libraries" << PS4SDKLibDir;<br>
+    return;<br>
+  }<br>
+  getFilePaths().push_back(PS4SDKLibDir.str());<br>
+}<br>
+<br>
+Tool *PS4CPU::buildAssembler() const {<br>
+  return new tools::PS4cpu::Assemble(*this);<br>
+}<br>
+<br>
+Tool *PS4CPU::buildLinker() const { return new tools::PS4cpu::Link(*this); }<br>
+<br>
+bool PS4CPU::isPICDefault() const { return true; }<br>
+<br>
+bool PS4CPU::HasNativeLLVMSupport() const { return true; }<br>
+<br>
+SanitizerMask PS4CPU::getSupportedSanitizers() const {<br>
+  SanitizerMask Res = ToolChain::getSupportedSanitizers();<br>
+  Res |= SanitizerKind::Address;<br>
+  Res |= SanitizerKind::Vptr;<br>
+  return Res;<br>
+}<br>
<br>
Modified: cfe/trunk/lib/Driver/ToolChains.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.h?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/ToolChains.h (original)<br>
+++ cfe/trunk/lib/Driver/ToolChains.h Wed Oct 14 07:25:43 2015<br>
@@ -1015,6 +1015,27 @@ private:<br>
                              llvm::opt::ArgStringList &CC1Args) const override;<br>
 };<br>
<br>
+class LLVM_LIBRARY_VISIBILITY PS4CPU : public Generic_ELF {<br>
+public:<br>
+  PS4CPU(const Driver &D, const llvm::Triple &Triple,<br>
+         const llvm::opt::ArgList &Args);<br>
+<br>
+  bool IsMathErrnoDefault() const override { return false; }<br>
+  bool IsObjCNonFragileABIDefault() const override { return true; }<br>
+  bool HasNativeLLVMSupport() const override;<br>
+  bool isPICDefault() const override;<br>
+<br>
+  unsigned GetDefaultStackProtectorLevel(bool KernelOrKext) const override {<br>
+    return 2; // SSPStrong<br>
+  }<br>
+<br>
+  SanitizerMask getSupportedSanitizers() const override;<br>
+<br>
+protected:<br>
+  Tool *buildAssembler() const override;<br>
+  Tool *buildLinker() const override;<br>
+};<br>
+<br>
 } // end namespace toolchains<br>
 } // end namespace driver<br>
 } // end namespace clang<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.cpp (original)<br>
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Oct 14 07:25:43 2015<br>
@@ -3110,15 +3110,23 @@ ParsePICArgs(const ToolChain &ToolChain,<br>
             O.matches(options::OPT_fPIE) || O.matches(options::OPT_fPIC);<br>
       } else {<br>
         PIE = PIC = false;<br>
+        if (Triple.isPS4CPU()) {<br>
+          Arg *ModelArg = Args.getLastArg(options::OPT_mcmodel_EQ);<br>
+          StringRef Model = ModelArg ? ModelArg->getValue() : "";<br>
+          if (Model != "kernel") {<br>
+            PIC = true;<br>
+            ToolChain.getDriver().Diag(diag::warn_drv_ps4_force_pic)<br>
+                << LastPICArg->getSpelling();<br>
+          }<br>
+        }<br>
       }<br>
     }<br>
   }<br>
<br>
-  // Introduce a Darwin-specific hack. If the default is PIC, but the<br>
-  // PIC level would've been set to level 1, force it back to level 2<br>
-  // PIC instead. This matches the behavior of Darwin GCC (based on<br>
-  // chandlerc's informal testing in 2012).<br>
-  if (PIC && ToolChain.getTriple().isOSDarwin())<br>
+  // Introduce a Darwin and PS4-specific hack. If the default is PIC, but the<br>
+  // PIC level would've been set to level 1, force it back to level 2 PIC<br>
+  // instead.<br>
+  if (PIC && (ToolChain.getTriple().isOSDarwin() || Triple.isPS4CPU()))<br>
     IsPICLevelTwo |= ToolChain.isPICDefault();<br>
<br>
   // This kernel flags are a trump-card: they will disable PIC/PIE<br>
@@ -3190,6 +3198,7 @@ void Clang::ConstructJob(Compilation &C,<br>
   bool IsWindowsCygnus =<br>
       getToolChain().getTriple().isWindowsCygwinEnvironment();<br>
   bool IsWindowsMSVC = getToolChain().getTriple().isWindowsMSVCEnvironment();<br>
+  bool IsPS4CPU = getToolChain().getTriple().isPS4CPU();<br>
<br>
   // Check number of inputs for sanity. We need at least one input.<br>
   assert(Inputs.size() >= 1 && "Must have at least one input.");<br>
@@ -3843,8 +3852,10 @@ void Clang::ConstructJob(Compilation &C,<br>
<br>
   // We ignore flags -gstrict-dwarf and -grecord-gcc-switches for now.<br>
   Args.ClaimAllArgs(options::OPT_g_flags_Group);<br>
+<br>
+  // PS4 defaults to no column info<br>
   if (Args.hasFlag(options::OPT_gcolumn_info, options::OPT_gno_column_info,<br>
-                   /*Default*/ true))<br>
+                   /*Default=*/ !IsPS4CPU))<br>
     CmdArgs.push_back("-dwarf-column-info");<br>
<br>
   // FIXME: Move backend command line options to the module.<br>
@@ -3883,7 +3894,8 @@ void Clang::ConstructJob(Compilation &C,<br>
<br>
   // -gdwarf-aranges turns on the emission of the aranges section in the<br>
   // backend.<br>
-  if (Args.hasArg(options::OPT_gdwarf_aranges)) {<br>
+  // Always enabled on the PS4.<br>
+  if (Args.hasArg(options::OPT_gdwarf_aranges) || IsPS4CPU) {<br>
     CmdArgs.push_back("-backend-option");<br>
     CmdArgs.push_back("-generate-arange-section");<br>
   }<br>
@@ -9919,3 +9931,325 @@ void tools::Myriad::Linker::ConstructJob<br>
   C.addCommand(llvm::make_unique<Command>(JA, *this, Args.MakeArgString(Exec),<br>
                                           CmdArgs, Inputs));<br>
 }<br>
+<br>
+void PS4cpu::Assemble::ConstructJob(Compilation &C, const JobAction &JA,<br>
+                                    const InputInfo &Output,<br>
+                                    const InputInfoList &Inputs,<br>
+                                    const ArgList &Args,<br>
+                                    const char *LinkingOutput) const {<br>
+  claimNoWarnArgs(Args);<br>
+  ArgStringList CmdArgs;<br>
+<br>
+  Args.AddAllArgValues(CmdArgs, options::OPT_Wa_COMMA, options::OPT_Xassembler);<br>
+<br>
+  CmdArgs.push_back("-o");<br>
+  CmdArgs.push_back(Output.getFilename());<br>
+<br>
+  assert(Inputs.size() == 1 && "Unexpected number of inputs.");<br>
+  const InputInfo &Input = Inputs[0];<br>
+  assert(Input.isFilename() && "Invalid input.");<br>
+  CmdArgs.push_back(Input.getFilename());<br>
+<br>
+  const char *Exec =<br>
+      Args.MakeArgString(getToolChain().GetProgramPath("ps4-as"));<br>
+  C.addCommand(llvm::make_unique<Command>(JA, *this, Exec, CmdArgs, Inputs));<br>
+}<br>
+<br>
+static void AddPS4ProfileRT(const ToolChain &TC, const ArgList &Args,<br>
+                            ArgStringList &CmdArgs) {<br>
+  if (!(Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,<br>
+                     false) ||<br>
+        Args.hasArg(options::OPT_fprofile_generate) ||<br>
+        Args.hasArg(options::OPT_fprofile_instr_generate) ||<br>
+        Args.hasArg(options::OPT_fcreate_profile) ||<br>
+        Args.hasArg(options::OPT_coverage)))<br>
+    return;<br>
+<br>
+  assert(TC.getTriple().isPS4CPU() &&<br>
+         "Profiling libraries are only implemented for the PS4 CPU");<br>
+  CmdArgs.push_back("-lclang_rt.profile-x86_64");<br>
+}<br>
+<br>
+static void AddPS4SanitizerArgs(const ToolChain &TC, ArgStringList &CmdArgs) {<br>
+  const SanitizerArgs &SanArgs = TC.getSanitizerArgs();<br>
+  if (SanArgs.needsUbsanRt()) {<br>
+    CmdArgs.push_back("-lSceDbgUBSanitizer_stub_weak");<br>
+  }<br>
+  if (SanArgs.needsAsanRt()) {<br>
+    CmdArgs.push_back("-lSceDbgAddressSanitizer_stub_weak");<br>
+  }<br>
+}<br>
+<br>
+static void ConstructPS4LinkJob(const Tool &T, Compilation &C,<br>
+                                const JobAction &JA, const InputInfo &Output,<br>
+                                const InputInfoList &Inputs,<br>
+                                const ArgList &Args,<br>
+                                const char *LinkingOutput) {<br>
+  const toolchains::FreeBSD &ToolChain =<br>
+      static_cast<const toolchains::FreeBSD &>(T.getToolChain());<br>
+  const Driver &D = ToolChain.getDriver();<br>
+  ArgStringList CmdArgs;<br>
+<br>
+  // Silence warning for "clang -g foo.o -o foo"<br>
+  Args.ClaimAllArgs(options::OPT_g_Group);<br>
+  // and "clang -emit-llvm foo.o -o foo"<br>
+  Args.ClaimAllArgs(options::OPT_emit_llvm);<br>
+  // and for "clang -w foo.o -o foo". Other warning options are already<br>
+  // handled somewhere else.<br>
+  Args.ClaimAllArgs(options::OPT_w);<br>
+<br>
+  if (!D.SysRoot.empty())<br>
+    CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));<br>
+<br>
+  if (Args.hasArg(options::OPT_pie))<br>
+    CmdArgs.push_back("-pie");<br>
+<br>
+  if (Args.hasArg(options::OPT_rdynamic))<br>
+    CmdArgs.push_back("-export-dynamic");<br>
+  if (Args.hasArg(options::OPT_shared))<br>
+    CmdArgs.push_back("--oformat=so");<br>
+<br>
+  if (Output.isFilename()) {<br>
+    CmdArgs.push_back("-o");<br>
+    CmdArgs.push_back(Output.getFilename());<br>
+  } else {<br>
+    assert(Output.isNothing() && "Invalid output.");<br>
+  }<br>
+<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_L);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_T_Group);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_e);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_s);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_t);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_r);<br>
+<br>
+  if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))<br>
+    CmdArgs.push_back("--no-demangle");<br>
+<br>
+  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);<br>
+<br>
+  if (Args.hasArg(options::OPT_pthread)) {<br>
+    CmdArgs.push_back("-lpthread");<br>
+  }<br>
+<br>
+  AddPS4ProfileRT(ToolChain, Args, CmdArgs);<br>
+  AddPS4SanitizerArgs(ToolChain, CmdArgs);<br>
+<br>
+  const char *Exec = Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld"));<br>
+<br>
+  C.addCommand(llvm::make_unique<Command>(JA, T, Exec, CmdArgs, Inputs));<br>
+}<br>
+<br>
+static void ConstructGoldLinkJob(const Tool &T, Compilation &C,<br>
+                                 const JobAction &JA, const InputInfo &Output,<br>
+                                 const InputInfoList &Inputs,<br>
+                                 const ArgList &Args,<br>
+                                 const char *LinkingOutput) {<br>
+  const toolchains::FreeBSD &ToolChain =<br>
+      static_cast<const toolchains::FreeBSD &>(T.getToolChain());<br>
+  const Driver &D = ToolChain.getDriver();<br>
+  ArgStringList CmdArgs;<br>
+<br>
+  // Silence warning for "clang -g foo.o -o foo"<br>
+  Args.ClaimAllArgs(options::OPT_g_Group);<br>
+  // and "clang -emit-llvm foo.o -o foo"<br>
+  Args.ClaimAllArgs(options::OPT_emit_llvm);<br>
+  // and for "clang -w foo.o -o foo". Other warning options are already<br>
+  // handled somewhere else.<br>
+  Args.ClaimAllArgs(options::OPT_w);<br>
+<br>
+  if (!D.SysRoot.empty())<br>
+    CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));<br>
+<br>
+  if (Args.hasArg(options::OPT_pie))<br>
+    CmdArgs.push_back("-pie");<br>
+<br>
+  if (Args.hasArg(options::OPT_static)) {<br>
+    CmdArgs.push_back("-Bstatic");<br>
+  } else {<br>
+    if (Args.hasArg(options::OPT_rdynamic))<br>
+      CmdArgs.push_back("-export-dynamic");<br>
+    CmdArgs.push_back("--eh-frame-hdr");<br>
+    if (Args.hasArg(options::OPT_shared)) {<br>
+      CmdArgs.push_back("-Bshareable");<br>
+    } else {<br>
+      CmdArgs.push_back("-dynamic-linker");<br>
+      CmdArgs.push_back("/libexec/ld-elf.so.1");<br>
+    }<br>
+    CmdArgs.push_back("--enable-new-dtags");<br>
+  }<br>
+<br>
+  if (Output.isFilename()) {<br>
+    CmdArgs.push_back("-o");<br>
+    CmdArgs.push_back(Output.getFilename());<br>
+  } else {<br>
+    assert(Output.isNothing() && "Invalid output.");<br>
+  }<br>
+<br>
+  if (!Args.hasArg(options::OPT_nostdlib) &&<br>
+      !Args.hasArg(options::OPT_nostartfiles)) {<br>
+    const char *crt1 = NULL;<br>
+    if (!Args.hasArg(options::OPT_shared)) {<br>
+      if (Args.hasArg(options::OPT_pg))<br>
+        crt1 = "gcrt1.o";<br>
+      else if (Args.hasArg(options::OPT_pie))<br>
+        crt1 = "Scrt1.o";<br>
+      else<br>
+        crt1 = "crt1.o";<br>
+    }<br>
+    if (crt1)<br>
+      CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crt1)));<br>
+<br>
+    CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crti.o")));<br>
+<br>
+    const char *crtbegin = NULL;<br>
+    if (Args.hasArg(options::OPT_static))<br>
+      crtbegin = "crtbeginT.o";<br>
+    else if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))<br>
+      crtbegin = "crtbeginS.o";<br>
+    else<br>
+      crtbegin = "crtbegin.o";<br>
+<br>
+    CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath(crtbegin)));<br>
+  }<br>
+<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_L);<br>
+<br>
+  const ToolChain::path_list Paths = ToolChain.getFilePaths();<br>
+  for (ToolChain::path_list::const_iterator i = Paths.begin(), e = Paths.end();<br>
+       i != e; ++i)<br>
+    CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + *i));<br>
+<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_T_Group);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_e);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_s);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_t);<br>
+  Args.AddAllArgs(CmdArgs, options::OPT_r);<br>
+<br>
+  if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))<br>
+    CmdArgs.push_back("--no-demangle");<br>
+<br>
+  AddLinkerInputs(ToolChain, Inputs, Args, CmdArgs);<br>
+<br>
+  if (!Args.hasArg(options::OPT_nostdlib) &&<br>
+      !Args.hasArg(options::OPT_nodefaultlibs)) {<br>
+    // For PS4, we always want to pass libm, libstdc++ and libkernel<br>
+    // libraries for both C and C++ compilations.<br>
+    CmdArgs.push_back("-lkernel");<br>
+    if (D.CCCIsCXX()) {<br>
+      ToolChain.AddCXXStdlibLibArgs(Args, CmdArgs);<br>
+      if (Args.hasArg(options::OPT_pg))<br>
+        CmdArgs.push_back("-lm_p");<br>
+      else<br>
+        CmdArgs.push_back("-lm");<br>
+    }<br>
+    // FIXME: For some reason GCC passes -lgcc and -lgcc_s before adding<br>
+    // the default system libraries. Just mimic this for now.<br>
+    if (Args.hasArg(options::OPT_pg))<br>
+      CmdArgs.push_back("-lgcc_p");<br>
+    else<br>
+      CmdArgs.push_back("-lcompiler_rt");<br>
+    if (Args.hasArg(options::OPT_static)) {<br>
+      CmdArgs.push_back("-lstdc++");<br>
+    } else if (Args.hasArg(options::OPT_pg)) {<br>
+      CmdArgs.push_back("-lgcc_eh_p");<br>
+    } else {<br>
+      CmdArgs.push_back("--as-needed");<br>
+      CmdArgs.push_back("-lstdc++");<br>
+      CmdArgs.push_back("--no-as-needed");<br>
+    }<br>
+<br>
+    if (Args.hasArg(options::OPT_pthread)) {<br>
+      if (Args.hasArg(options::OPT_pg))<br>
+        CmdArgs.push_back("-lpthread_p");<br>
+      else<br>
+        CmdArgs.push_back("-lpthread");<br>
+    }<br>
+<br>
+    if (Args.hasArg(options::OPT_pg)) {<br>
+      if (Args.hasArg(options::OPT_shared))<br>
+        CmdArgs.push_back("-lc");<br>
+      else {<br>
+        if (Args.hasArg(options::OPT_static)) {<br>
+          CmdArgs.push_back("--start-group");<br>
+          CmdArgs.push_back("-lc_p");<br>
+          CmdArgs.push_back("-lpthread_p");<br>
+          CmdArgs.push_back("--end-group");<br>
+        } else {<br>
+          CmdArgs.push_back("-lc_p");<br>
+        }<br>
+      }<br>
+      CmdArgs.push_back("-lgcc_p");<br>
+    } else {<br>
+      if (Args.hasArg(options::OPT_static)) {<br>
+        CmdArgs.push_back("--start-group");<br>
+        CmdArgs.push_back("-lc");<br>
+        CmdArgs.push_back("-lpthread");<br>
+        CmdArgs.push_back("--end-group");<br>
+      } else {<br>
+        CmdArgs.push_back("-lc");<br>
+      }<br>
+      CmdArgs.push_back("-lcompiler_rt");<br>
+    }<br>
+<br>
+    if (Args.hasArg(options::OPT_static)) {<br>
+      CmdArgs.push_back("-lstdc++");<br>
+    } else if (Args.hasArg(options::OPT_pg)) {<br>
+      CmdArgs.push_back("-lgcc_eh_p");<br>
+    } else {<br>
+      CmdArgs.push_back("--as-needed");<br>
+      CmdArgs.push_back("-lstdc++");<br>
+      CmdArgs.push_back("--no-as-needed");<br>
+    }<br>
+  }<br>
+<br>
+  if (!Args.hasArg(options::OPT_nostdlib) &&<br>
+      !Args.hasArg(options::OPT_nostartfiles)) {<br>
+    if (Args.hasArg(options::OPT_shared) || Args.hasArg(options::OPT_pie))<br>
+      CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtendS.o")));<br>
+    else<br>
+      CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtend.o")));<br>
+    CmdArgs.push_back(Args.MakeArgString(ToolChain.GetFilePath("crtn.o")));<br>
+  }<br>
+<br>
+  AddPS4ProfileRT(ToolChain, Args, CmdArgs);<br>
+  AddPS4SanitizerArgs(ToolChain, CmdArgs);<br>
+<br>
+  const char *Exec =<br>
+#ifdef LLVM_ON_WIN32<br>
+      Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld.gold.exe"));<br>
+#else<br>
+      Args.MakeArgString(ToolChain.GetProgramPath("ps4-ld"));<br>
+#endif<br>
+<br>
+  C.addCommand(llvm::make_unique<Command>(JA, T, Exec, CmdArgs, Inputs));<br>
+}<br>
+<br>
+void PS4cpu::Link::ConstructJob(Compilation &C, const JobAction &JA,<br>
+                                const InputInfo &Output,<br>
+                                const InputInfoList &Inputs,<br>
+                                const ArgList &Args,<br>
+                                const char *LinkingOutput) const {<br>
+  const toolchains::FreeBSD &ToolChain =<br>
+      static_cast<const toolchains::FreeBSD &>(getToolChain());<br>
+  const Driver &D = ToolChain.getDriver();<br>
+  bool PS4Linker;<br>
+  StringRef LinkerOptName;<br>
+  if (const Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {<br>
+    LinkerOptName = A->getValue();<br>
+    if (LinkerOptName != "ps4" && LinkerOptName != "gold")<br>
+      D.Diag(diag::err_drv_unsupported_linker) << LinkerOptName;<br>
+  }<br>
+<br>
+  if (LinkerOptName == "gold")<br>
+    PS4Linker = false;<br>
+  else if (LinkerOptName == "ps4")<br>
+    PS4Linker = true;<br>
+  else<br>
+    PS4Linker = !Args.hasArg(options::OPT_shared);<br>
+<br>
+  if (PS4Linker)<br>
+    ConstructPS4LinkJob(*this, C, JA, Output, Inputs, Args, LinkingOutput);<br>
+  else<br>
+    ConstructGoldLinkJob(*this, C, JA, Output, Inputs, Args, LinkingOutput);<br>
+}<br>
<br>
Modified: cfe/trunk/lib/Driver/Tools.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.h?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Driver/Tools.h (original)<br>
+++ cfe/trunk/lib/Driver/Tools.h Wed Oct 14 07:25:43 2015<br>
@@ -831,6 +831,36 @@ public:<br>
 };<br>
 } // end namespace Myriad<br>
<br>
+namespace PS4cpu {<br>
+class LLVM_LIBRARY_VISIBILITY Assemble : public Tool {<br>
+public:<br>
+  Assemble(const ToolChain &TC)<br>
+      : Tool("PS4cpu::Assemble", "assembler", TC, RF_Full) {}<br>
+<br>
+  virtual bool hasIntegratedCPP() const { return false; }<br>
+<br>
+  virtual void ConstructJob(Compilation &C, const JobAction &JA,<br>
+                            const InputInfo &Output,<br>
+                            const InputInfoList &Inputs,<br>
+                            const llvm::opt::ArgList &TCArgs,<br>
+                            const char *LinkingOutput) const;<br>
+};<br>
+<br>
+class LLVM_LIBRARY_VISIBILITY Link : public Tool {<br>
+public:<br>
+  Link(const ToolChain &TC) : Tool("PS4cpu::Link", "linker", TC, RF_Full) {}<br>
+<br>
+  virtual bool hasIntegratedCPP() const { return false; }<br>
+  virtual bool isLinkJob() const { return true; }<br>
+<br>
+  virtual void ConstructJob(Compilation &C, const JobAction &JA,<br>
+                            const InputInfo &Output,<br>
+                            const InputInfoList &Inputs,<br>
+                            const llvm::opt::ArgList &TCArgs,<br>
+                            const char *LinkingOutput) const;<br>
+};<br>
+} // end namespace PS4cpu<br>
+<br>
 } // end namespace tools<br>
 } // end namespace driver<br>
 } // end namespace clang<br>
<br>
Modified: cfe/trunk/lib/Frontend/InitHeaderSearch.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/InitHeaderSearch.cpp?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Frontend/InitHeaderSearch.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/InitHeaderSearch.cpp Wed Oct 14 07:25:43 2015<br>
@@ -215,6 +215,7 @@ void InitHeaderSearch::AddDefaultCInclud<br>
     case llvm::Triple::OpenBSD:<br>
     case llvm::Triple::Bitrig:<br>
     case llvm::Triple::NaCl:<br>
+    case llvm::Triple::PS4:<br>
       break;<br>
     case llvm::Triple::Win32:<br>
       if (triple.getEnvironment() != llvm::Triple::Cygnus)<br>
@@ -318,6 +319,28 @@ void InitHeaderSearch::AddDefaultCInclud<br>
   case llvm::Triple::RTEMS:<br>
   case llvm::Triple::NaCl:<br>
     break;<br>
+  case llvm::Triple::PS4: {<br>
+    // <isysroot> gets prepended later in AddPath().<br>
+    std::string BaseSDKPath = "";<br>
+    if (!HasSysroot) {<br>
+      const char *envValue = getenv("SCE_PS4_SDK_DIR");<br>
+      if (envValue)<br>
+        BaseSDKPath = envValue;<br>
+      else {<br>
+        // HSOpts.ResourceDir variable contains the location of Clang's<br>
+        // resource files.<br>
+        // Assuming that Clang is configured for PS4 without<br>
+        // --with-clang-resource-dir option, the location of Clang's resource<br>
+        // files is <SDK_DIR>/host_tools/lib/clang<br>
+        SmallString<128> P = StringRef(HSOpts.ResourceDir);<br>
+        llvm::sys::path::append(P, "../../..");<br>
+        BaseSDKPath = P.str();<br>
+      }<br>
+    }<br>
+    AddPath(BaseSDKPath + "/target/include", System, false);<br>
+    if (triple.isPS4CPU())<br>
+      AddPath(BaseSDKPath + "/target/include_common", System, false);<br>
+  }<br>
   default:<br>
     AddPath("/usr/include", ExternCSystem, false);<br>
     break;<br>
<br>
Added: cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include/.keep<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include/.keep?rev=250293&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include/.keep?rev=250293&view=auto</a><br>
==============================================================================<br>
    (empty)<br>
<br>
Added: cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep?rev=250293&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/scei-ps4_tree/target/include_common/.keep?rev=250293&view=auto</a><br>
==============================================================================<br>
    (empty)<br>
<br>
Modified: cfe/trunk/test/Driver/debug-options.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/debug-options.c (original)<br>
+++ cfe/trunk/test/Driver/debug-options.c Wed Oct 14 07:25:43 2015<br>
@@ -27,6 +27,17 @@<br>
 // RUN: %clang -### -c -ggdb3 %s -target x86_64-apple-darwin 2>&1 \<br>
 // RUN:             | FileCheck -check-prefix=G_DARWIN %s<br>
<br>
+// On the PS4, -g defaults to -gno-column-info, and we always generate the<br>
+// arange section.<br>
+// RUN: %clang -### -c %s -target x86_64-scei-ps4 2>&1 \<br>
+// RUN:             | FileCheck -check-prefix=G_PS4 %s<br>
+// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \<br>
+// RUN:             | FileCheck -check-prefix=G_PS4 %s<br>
+// RUN: %clang -### -c %s -g -target x86_64-scei-ps4 2>&1 \<br>
+// RUN:             | FileCheck -check-prefix=NOCI %s<br>
+// RUN: %clang -### -c %s -g -gcolumn-info -target x86_64-scei-ps4 2>&1 \<br>
+// RUN:             | FileCheck -check-prefix=CI %s<br>
+<br>
 // RUN: %clang -### -c -gdwarf-2 %s 2>&1 | FileCheck -check-prefix=G_D2 %s<br>
 //<br>
 // RUN: %clang -### -c -gfoo %s 2>&1 | FileCheck -check-prefix=G_NO %s<br>
@@ -75,7 +86,8 @@<br>
 // RUN: %clang -### -g -gno-column-info %s 2>&1 \<br>
 // RUN:        | FileCheck -check-prefix=NOCI %s<br>
 //<br>
-// RUN: %clang -### -g %s 2>&1 | FileCheck -check-prefix=CI %s<br>
+// RUN: %clang -### -g -target x86_64-unknown-unknown %s 2>&1 \<br>
+//             | FileCheck -check-prefix=CI %s<br>
 //<br>
 // RUN: %clang -### -gmodules %s 2>&1 \<br>
 // RUN:        | FileCheck -check-prefix=GEXTREFS %s<br>
@@ -86,6 +98,9 @@<br>
 // G_DARWIN: "-cc1"<br>
 // G_DARWIN: "-dwarf-version=2"<br>
 //<br>
+// G_PS4: "-cc1"<br>
+// G_PS4: "-generate-arange-section"<br>
+//<br>
 // G_D2: "-cc1"<br>
 // G_D2: "-dwarf-version=2"<br>
 //<br>
<br>
Added: cfe/trunk/test/Driver/no-integrated-as.s<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/no-integrated-as.s?rev=250293&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/no-integrated-as.s?rev=250293&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/no-integrated-as.s (added)<br>
+++ cfe/trunk/test/Driver/no-integrated-as.s Wed Oct 14 07:25:43 2015<br>
@@ -0,0 +1,8 @@<br>
+; RUN: %clang -### -no-integrated-as -c %s 2>&1 | FileCheck %s -check-prefix IAS<br>
+; Windows doesn't support no-integrated-as<br>
+; XFAIL: win32,win64<br>
+;<br>
+; Make sure the current file's filename appears in the output.<br>
+; We can't generically match on the assembler name, so we just make sure<br>
+; the filename is in the output.<br>
+; IAS: no-integrated-as.s<br>
<br>
Added: cfe/trunk/test/Driver/ps4-header-search.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-header-search.c?rev=250293&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-header-search.c?rev=250293&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/ps4-header-search.c (added)<br>
+++ cfe/trunk/test/Driver/ps4-header-search.c Wed Oct 14 07:25:43 2015<br>
@@ -0,0 +1,10 @@<br>
+// REQUIRES: x86-registered-target<br>
+<br>
+// RUN: env SCE_PS4_SDK_DIR=%S/Inputs/scei-ps4_tree %clang -target x86_64-scei-ps4 -E -v %s 2>&1 | FileCheck %s --check-prefix=ENVPS4<br>
+// ENVPS4: Inputs/scei-ps4_tree/target/include{{$}}<br>
+// ENVPS4: Inputs/scei-ps4_tree/target/include_common{{$}}<br>
+<br>
+// RUN: %clang -isysroot %S/Inputs/scei-ps4_tree -target x86_64-scei-ps4 -E -v %s 2>&1 | FileCheck %s --check-prefix=SYSROOTPS4<br>
+// SYSROOTPS4: "{{[^"]*}}clang{{[^"]*}}"<br>
+// SYSROOTPS4: Inputs/scei-ps4_tree/target/include{{$}}<br>
+// SYSROOTPS4: Inputs/scei-ps4_tree/target/include_common{{$}}<br>
<br>
Added: cfe/trunk/test/Driver/ps4-linker-non-win.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-non-win.c?rev=250293&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-non-win.c?rev=250293&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/ps4-linker-non-win.c (added)<br>
+++ cfe/trunk/test/Driver/ps4-linker-non-win.c Wed Oct 14 07:25:43 2015<br>
@@ -0,0 +1,18 @@<br>
+// UNSUPPORTED: system-windows<br>
+// REQUIRES: x86-registered-target<br>
+<br>
+// RUN: touch %T/ps4-ld<br>
+<br>
+// RUN: env "PATH=%T" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=gold 2>&1 \<br>
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s<br>
+// RUN: env "PATH=%T" %clang -### -target x86_64-scei-ps4  %s -shared 2>&1 \<br>
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s<br>
+<br>
+// RUN: env "PATH=%T" %clang -### -target x86_64-scei-ps4  %s 2>&1 \<br>
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s<br>
+// RUN: env "PATH=%T" %clang -### -target x86_64-scei-ps4  %s -fuse-ld=ps4 2>&1 \<br>
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s<br>
+// RUN: env "PATH=%T" %clang -### -target x86_64-scei-ps4  %s -shared \<br>
+// RUN:     -fuse-ld=ps4 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s<br>
+<br>
+// CHECK-PS4-LINKER: ps4-ld<br>
<br>
Added: cfe/trunk/test/Driver/ps4-linker-win.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-win.c?rev=250293&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-linker-win.c?rev=250293&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/ps4-linker-win.c (added)<br>
+++ cfe/trunk/test/Driver/ps4-linker-win.c Wed Oct 14 07:25:43 2015<br>
@@ -0,0 +1,26 @@<br>
+// The full path to the gold linker was not found on Windows because the<br>
+// driver fails to add an .exe extension to the name.<br>
+// We check that gold linker's full name (with an extension) is specified<br>
+// on the command line if -fuse-ld=gold, or -shared with no -fuse-ld option<br>
+// are passed. Otherwise, we check that the PS4's linker's full name is<br>
+// specified.<br>
+<br>
+// REQUIRES: system-windows, x86-registered-target<br>
+<br>
+// RUN: touch %T/ps4-ld.exe<br>
+// RUN: touch %T/ps4-ld.gold.exe<br>
+<br>
+// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -fuse-ld=gold -### 2>&1 \<br>
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s<br>
+// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -shared -### 2>&1 \<br>
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-GOLD %s<br>
+<br>
+// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -### 2>&1 \<br>
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s<br>
+// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -fuse-ld=ps4 -### 2>&1 \<br>
+// RUN:   | FileCheck --check-prefix=CHECK-PS4-LINKER %s<br>
+// RUN: env "PATH=%T" %clang -target x86_64-scei-ps4  %s -shared \<br>
+// RUN:     -fuse-ld=ps4 -### 2>&1 | FileCheck --check-prefix=CHECK-PS4-LINKER %s<br>
+<br>
+// CHECK-PS4-GOLD: ps4-ld.gold.exe<br>
+// CHECK-PS4-LINKER: ps4-ld.exe<br>
<br>
Added: cfe/trunk/test/Driver/ps4-pic.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-pic.c?rev=250293&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-pic.c?rev=250293&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/ps4-pic.c (added)<br>
+++ cfe/trunk/test/Driver/ps4-pic.c Wed Oct 14 07:25:43 2015<br>
@@ -0,0 +1,106 @@<br>
+// REQUIRES: x86-registered-target<br>
+<br>
+// Test the driver's control over the PIC behavior for PS4 compiler.<br>
+// These consist of tests of the relocation model flags and the<br>
+// pic level flags passed to CC1.<br>
+//<br>
+// CHECK-NO-PIC: "-mrelocation-model" "static"<br>
+// CHECK-NO-PIC-NOT: "-pic-level"<br>
+// CHECK-NO-PIC-NOT: "-pie-level"<br>
+//<br>
+// CHECK-DYNAMIC-NO-PIC2: unsupported option '-mdynamic-no-pic'<br>
+// CHECK-DYNAMIC-NO-PIC2: "-mrelocation-model" "dynamic-no-pic"<br>
+//<br>
+// CHECK-PIC2: "-mrelocation-model" "pic"<br>
+// CHECK-PIC2: "-pic-level" "2"<br>
+//<br>
+// CHECK-PIE2: "-mrelocation-model" "pic"<br>
+// CHECK-PIE2: "-pie-level" "2"<br>
+//<br>
+// CHECK-NOPIC-IGNORED: using '-fPIC'<br>
+// CHECK-NOPIC-IGNORED: "-mrelocation-model" "pic"<br>
+// CHECK-NOPIC-IGNORED: "-pic-level" "2"<br>
+//<br>
+// CHECK-DIAG-PIC: option '-fno-PIC' was ignored by the PS4 toolchain, using '-fPIC'<br>
+// CHECK-DIAG-PIE: option '-fno-PIE' was ignored by the PS4 toolchain, using '-fPIC'<br>
+// CHECK-DIAG-pic: option '-fno-pic' was ignored by the PS4 toolchain, using '-fPIC'<br>
+// CHECK-DIAG-pie: option '-fno-pie' was ignored by the PS4 toolchain, using '-fPIC'<br>
+//<br>
+// CHECK-STATIC-ERR: unsupported option '-static' for target 'PS4'<br>
+<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpic -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fPIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpie -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fPIE -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpic -fno-pic -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fPIC -fno-PIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpic -fno-PIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fPIC -fno-pic -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpie -fno-pie -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fPIE -fno-PIE -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpie -fno-PIE -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fPIE -fno-pie -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpie -fno-pic -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpic -fno-pie -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpic -fPIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fPIC -fpic -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpic -fPIE -fpie -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fpie -fPIC -fPIE -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIE2<br>
+//<br>
+// Defaults change for PS4.<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-PIC2<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fno-pic -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fno-PIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NOPIC-IGNORED<br>
+//<br>
+// Disregard any of the PIC-specific flags if we have a trump-card flag.<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -mkernel -fPIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -mdynamic-no-pic -fPIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-DYNAMIC-NO-PIC2<br>
+//<br>
+// -static not supported at all.<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -static -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-STATIC-ERR<br>
+//<br>
+// -fno-PIC etc. is obeyed if -mcmodel=kernel is also present.<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -mcmodel=kernel -fno-PIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -mcmodel=kernel -fno-PIE -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -mcmodel=kernel -fno-pic -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -mcmodel=kernel -fno-pie -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-NO-PIC<br>
+//<br>
+// Verify that we reflect the option the user specified, when we ignore it.<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fno-PIC -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-DIAG-PIC<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fno-PIE -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-DIAG-PIE<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fno-pic -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-DIAG-pic<br>
+// RUN: %clang -c %s -target x86_64-scei-ps4 -fno-pie -### 2>&1 \<br>
+// RUN:   | FileCheck %s --check-prefix=CHECK-DIAG-pie<br>
<br>
Added: cfe/trunk/test/Driver/ps4-sdk-root.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-sdk-root.c?rev=250293&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/ps4-sdk-root.c?rev=250293&view=auto</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/ps4-sdk-root.c (added)<br>
+++ cfe/trunk/test/Driver/ps4-sdk-root.c Wed Oct 14 07:25:43 2015<br>
@@ -0,0 +1,48 @@<br>
+// REQUIRES: x86-registered-target<br>
+<br>
+// Check that ps4-clang doesn't report a warning message when locating<br>
+// system header files (either by looking at the value of SCE_PS4_SDK_DIR<br>
+// or relative to the location of the compiler driver), if "-nostdinc",<br>
+// "--sysroot" or "-isysroot" option is specified on the command line.<br>
+// Otherwise, check that ps4-clang reports a warning.<br>
+<br>
+// Check that clang doesn't report a warning message when locating<br>
+// system libraries (either by looking at the value of SCE_PS4_SDK_DIR<br>
+// or relative to the location of the compiler driver), if "-c", "-S", "-E",<br>
+// "--sysroot", "-nostdlib" or "-nodefaultlibs" option is specified on<br>
+// the command line.<br>
+// Otherwise, check that ps4-clang reports a warning.<br>
+<br>
+// setting up SCE_PS4_SDK_DIR to existing location, which is not a PS4 SDK.<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s<br>
+<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=WARN-SYS-LIBS -check-prefix=NO-WARN %s<br>
+<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -nostdinc -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s<br>
+<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast --sysroot=foo/ -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=NO-WARN %s<br>
+<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -c -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -S -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -E -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -emit-ast -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### --sysroot=foo/ -isysroot foo -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-ISYSROOT -check-prefix=NO-WARN %s<br>
+<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -nostdlib -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s<br>
+// RUN: env SCE_PS4_SDK_DIR=.. %clang -Winvalid-or-nonexistent-directory -### -nodefaultlibs -target x86_64-scei-ps4 %s 2>&1 | FileCheck -check-prefix=WARN-SYS-HEADERS -check-prefix=NO-WARN %s<br>
+<br>
+// NO-WARN-NOT: {{warning:|error:}}<br>
+// WARN-SYS-HEADERS: warning: unable to find PS4 system headers directory<br>
+// WARN-ISYSROOT: warning: no such sysroot directory: 'foo'<br>
+// WARN-SYS-LIBS: warning: unable to find PS4 system libraries directory<br>
+// NO-WARN-NOT: {{warning:|error:}}<br>
<br>
Modified: cfe/trunk/test/Driver/stack-protector.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stack-protector.c?rev=250293&r1=250292&r2=250293&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stack-protector.c?rev=250293&r1=250292&r2=250293&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/test/Driver/stack-protector.c (original)<br>
+++ cfe/trunk/test/Driver/stack-protector.c Wed Oct 14 07:25:43 2015<br>
@@ -23,3 +23,12 @@<br>
 // RUN: %clang -fstack-protector-all -### %s 2>&1 | FileCheck %s -check-prefix=SSP-ALL<br>
 // SSP-ALL: "-stack-protector" "3"<br>
 // SSP-ALL-NOT: "-stack-protector-buffer-size"<br>
+<br>
+// RUN: %clang -target x86_64-scei-ps4 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4<br>
+// RUN: %clang -target x86_64-scei-ps4 -fstack-protector -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4<br>
+// SSP-PS4: "-stack-protector" "2"<br>
+// SSP-PS4-NOT: "-stack-protector-buffer-size"<br>
+<br>
+// RUN: %clang -target x86_64-scei-ps4 -fstack-protector --param ssp-buffer-size=16 -### %s 2>&1 | FileCheck %s -check-prefix=SSP-PS4-BUF<br>
+// SSP-PS4-BUF: "-stack-protector" "2"<br>
+// SSP-PS4-BUF: "-stack-protector-buffer-size" "16"<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>