[clang] 9b3323d - Revert "[PS4/PS5] Tidy up driver warnings finding the SDK"

Paul Robinson via cfe-commits cfe-commits at lists.llvm.org
Mon Jul 17 10:33:16 PDT 2023


Author: Paul Robinson
Date: 2023-07-17T10:30:44-07:00
New Revision: 9b3323d39f635db870de958f067c672f54d7b192

URL: https://github.com/llvm/llvm-project/commit/9b3323d39f635db870de958f067c672f54d7b192
DIFF: https://github.com/llvm/llvm-project/commit/9b3323d39f635db870de958f067c672f54d7b192.diff

LOG: Revert "[PS4/PS5] Tidy up driver warnings finding the SDK"

This reverts commit ba9a7f73a12e75b005bfec359ddc37999b1d38c0.

Bot failures due to enabling the warning by default.
e.g. https://lab.llvm.org/buildbot/#/builders/139/builds/45263

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticDriverKinds.td
    clang/lib/Driver/ToolChains/PS4CPU.cpp
    clang/test/Driver/frame-pointer-elim.c
    clang/test/Driver/ps4-ps5-visibility-dllstorageclass.c

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index c84aa94ddbb44f..d10262826bf292 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -575,13 +575,17 @@ def err_drv_unsupported_fpatchable_function_entry_argument : Error<
   "the second argument of '-fpatchable-function-entry' must be smaller than the first argument">;
 
 def warn_drv_unable_to_find_directory_expected : Warning<
-  "unable to find %0 directory, expected to be in '%1' found via %2">,
-  InGroup<InvalidOrNonExistentDirectory>;
+  "unable to find %0 directory, expected to be in '%1'">,
+  InGroup<InvalidOrNonExistentDirectory>, DefaultIgnore;
 
 def warn_drv_ps_force_pic : Warning<
   "option '%0' was ignored by the %1 toolchain, using '-fPIC'">,
   InGroup<OptionIgnored>;
 
+def warn_drv_ps_sdk_dir : Warning<
+  "environment variable '%0' is set, but points to invalid or nonexistent directory '%1'">,
+  InGroup<InvalidOrNonExistentDirectory>;
+
 def err_drv_defsym_invalid_format : Error<"defsym must be of the form: sym=value: %0">;
 def err_drv_defsym_invalid_symval : Error<"value is not an integer: %0">;
 def warn_drv_msvc_not_found : Warning<

diff  --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 2f43d33bf0f1c8..37006dc5d7ed8b 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -256,23 +256,30 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
     D.Diag(clang::diag::err_drv_unsupported_opt_for_target)
         << "-static" << Platform;
 
-  // Determine where to find the PS4/PS5 libraries.
+  // Determine where to find the PS4/PS5 libraries. We use the EnvVar
+  // if it exists; otherwise use the driver's installation path, which
+  // should be <SDK_DIR>/host_tools/bin.
+
+  SmallString<512> SDKDir;
+  if (const char *EnvValue = getenv(EnvVar)) {
+    if (!llvm::sys::fs::exists(EnvValue))
+      D.Diag(clang::diag::warn_drv_ps_sdk_dir) << EnvVar << EnvValue;
+    SDKDir = EnvValue;
+  } else {
+    SDKDir = D.Dir;
+    llvm::sys::path::append(SDKDir, "/../../");
+  }
+
+  // By default, the driver won't report a warning if it can't find the
+  // SDK include or lib directories. This behavior could be changed if
+  // -Weverything or -Winvalid-or-nonexistent-directory options are passed.
   // If -isysroot was passed, use that as the SDK base path.
-  // If not, we use the EnvVar if it exists; otherwise use the driver's
-  // installation path, which should be <SDK_DIR>/host_tools/bin.
-  SmallString<80> Whence;
   if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
     SDKRootDir = A->getValue();
     if (!llvm::sys::fs::exists(SDKRootDir))
       D.Diag(clang::diag::warn_missing_sysroot) << SDKRootDir;
-    Whence = A->getSpelling();
-  } else if (const char *EnvValue = getenv(EnvVar)) {
-    SDKRootDir = EnvValue;
-    Whence = { "environment variable '", EnvVar, "'" };
-  } else {
-    SDKRootDir = D.Dir + "/../../";
-    Whence = "compiler's location";
-  }
+  } else
+    SDKRootDir = std::string(SDKDir.str());
 
   SmallString<512> SDKIncludeDir(SDKRootDir);
   llvm::sys::path::append(SDKIncludeDir, "target/include");
@@ -282,7 +289,7 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
       !Args.hasArg(options::OPT__sysroot_EQ) &&
       !llvm::sys::fs::exists(SDKIncludeDir)) {
     D.Diag(clang::diag::warn_drv_unable_to_find_directory_expected)
-        << Twine(Platform, " system headers").str() << SDKIncludeDir << Whence;
+        << Twine(Platform, " system headers").str() << SDKIncludeDir;
   }
 
   SmallString<512> SDKLibDir(SDKRootDir);
@@ -294,7 +301,7 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
       !Args.hasArg(options::OPT_emit_ast) &&
       !llvm::sys::fs::exists(SDKLibDir)) {
     D.Diag(clang::diag::warn_drv_unable_to_find_directory_expected)
-        << Twine(Platform, " system libraries").str() << SDKLibDir << Whence;
+        << Twine(Platform, " system libraries").str() << SDKLibDir;
     return;
   }
   getFilePaths().push_back(std::string(SDKLibDir.str()));

diff  --git a/clang/test/Driver/frame-pointer-elim.c b/clang/test/Driver/frame-pointer-elim.c
index a4abe0d90a40bd..71aca66c46ba77 100644
--- a/clang/test/Driver/frame-pointer-elim.c
+++ b/clang/test/Driver/frame-pointer-elim.c
@@ -1,8 +1,8 @@
-// KEEP-ALL-NOT:  warning: argument unused
+// KEEP-ALL-NOT:  warning:
 // KEEP-ALL:      "-mframe-pointer=all"
-// KEEP-NON-LEAF-NOT: warning: argument unused
+// KEEP-NON-LEAF-NOT: warning:
 // KEEP-NON-LEAF: "-mframe-pointer=non-leaf"
-// KEEP-NONE-NOT: warning: argument unused
+// KEEP-NONE-NOT: warning:
 // KEEP-NONE:     "-mframe-pointer=none"
 
 // On Linux x86, omit frame pointer when optimization is enabled.

diff  --git a/clang/test/Driver/ps4-ps5-visibility-dllstorageclass.c b/clang/test/Driver/ps4-ps5-visibility-dllstorageclass.c
index 430827805a8fda..1a54990da47643 100644
--- a/clang/test/Driver/ps4-ps5-visibility-dllstorageclass.c
+++ b/clang/test/Driver/ps4-ps5-visibility-dllstorageclass.c
@@ -52,7 +52,7 @@
 // REDEFINE:     --implicit-check-not=-fvisibility-nodllstorageclass \
 // REDEFINE:     --implicit-check-not=-fvisibility-externs-dllimport \
 // REDEFINE:     --implicit-check-not=-fvisibility-externs-nodllstorageclass \
-// REDEFINE:     --implicit-check-not="warning: argument unused"
+// REDEFINE:     --implicit-check-not=warning:
 // REDEFINE: %{triple} = x86_64-scei-ps4
 // RUN: %{run}
 // REDEFINE: %{triple} = x86_64-sie-ps5


        


More information about the cfe-commits mailing list