Skip to content

Conversation

@bd1976bris
Copy link
Collaborator

Our driver warns under various circumstances if SDK directories can't be found.

This warning is not applicable in ThinLTO codegen mode (-fthinlto-index=). Suppress it.

The motivation for doing this is that we sometimes see this warning emitted when DTLTO invokes the compiler on a remote machine to do the LTO backend compilations (with -fthinlto-index=).

Internal Ref: TOOLCHAIN-20592

The PS5 driver warns under various circumstances if SDK directories
can't be found.

This warning is not applicable in ThinLTO codegen mode
(-fthinlto-index=). Suppress it.

The motivation for doing this is that we sometimes see this warning
emitted when DTLTO invokes the compiler on a remote machine to do the
LTO backend compilations (with -fthinlto-index=).

Internal Ref: TOOLCHAIN-20592
@bd1976bris bd1976bris requested a review from jmorse November 12, 2025 12:28
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Nov 12, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 12, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Ben Dunbobbin (bd1976bris)

Changes

Our driver warns under various circumstances if SDK directories can't be found.

This warning is not applicable in ThinLTO codegen mode (-fthinlto-index=). Suppress it.

The motivation for doing this is that we sometimes see this warning emitted when DTLTO invokes the compiler on a remote machine to do the LTO backend compilations (with -fthinlto-index=).

Internal Ref: TOOLCHAIN-20592


Full diff: https://github.com/llvm/llvm-project/pull/167685.diff

3 Files Affected:

  • (modified) clang/lib/Driver/ToolChains/PS4CPU.cpp (+3)
  • (modified) clang/test/Driver/ps4-sdk-root.c (+8)
  • (modified) clang/test/Driver/ps5-sdk-root.c (+8)
diff --git a/clang/lib/Driver/ToolChains/PS4CPU.cpp b/clang/lib/Driver/ToolChains/PS4CPU.cpp
index 6fe18aa4cceba..5b5b5607da69e 100644
--- a/clang/lib/Driver/ToolChains/PS4CPU.cpp
+++ b/clang/lib/Driver/ToolChains/PS4CPU.cpp
@@ -488,6 +488,9 @@ toolchains::PS4PS5Base::PS4PS5Base(const Driver &D, const llvm::Triple &Triple,
   // control of header or library search. If we're not linking, don't check
   // for missing libraries.
   auto CheckSDKPartExists = [&](StringRef Dir, StringRef Desc) {
+    // In ThinLTO code generation mode SDK files are not required.
+    if (Args.hasArgNoClaim(options::OPT_fthinlto_index_EQ))
+      return true;
     if (llvm::sys::fs::exists(Dir))
       return true;
     D.Diag(clang::diag::warn_drv_unable_to_find_directory_expected)
diff --git a/clang/test/Driver/ps4-sdk-root.c b/clang/test/Driver/ps4-sdk-root.c
index 6e5f1e28958ad..7c568a6680f25 100644
--- a/clang/test/Driver/ps4-sdk-root.c
+++ b/clang/test/Driver/ps4-sdk-root.c
@@ -11,6 +11,9 @@
 ///
 /// The default <SDKROOT> for both headers and libraries is taken from the
 /// SCE_ORBIS_SDK_DIR environment variable.
+///
+/// In ThinLTO code generation mode (-fthinlto-index=) SDK files are not required
+/// so all warnings are suppressed.
 
 // RUN: echo "-### -Winvalid-or-nonexistent-directory -target x86_64-scei-ps4" > %t.rsp
 
@@ -31,6 +34,11 @@
 /// headers and libraries.
 // RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %s 2>&1 | FileCheck -check-prefixes=WARN-SYS-HEADERS,WARN-SYS-LIBS,NO-WARN %s
 
+/// -fthinlto-index= warning suppression.
+// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: env SCE_ORBIS_SDK_DIR=.. %clang @%t.rsp %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck -check-prefixes=NO-WARN %s
+
 /// If `-c`, `-S`, `-E` or `-emit-ast` is supplied, the existence check for SDK
 /// libraries is skipped because no linking will be performed. We only expect
 /// warnings about missing headers.
diff --git a/clang/test/Driver/ps5-sdk-root.c b/clang/test/Driver/ps5-sdk-root.c
index 16ef2cc01f5e7..558601d3a2082 100644
--- a/clang/test/Driver/ps5-sdk-root.c
+++ b/clang/test/Driver/ps5-sdk-root.c
@@ -13,6 +13,9 @@
 ///
 /// The default <SDKROOT> for both headers and libraries is taken from the
 /// SCE_PROSPERO_SDK_DIR environment variable.
+///
+/// In ThinLTO code generation mode (-fthinlto-index=) SDK files are not required
+/// so all warnings are suppressed.
 
 // RUN: echo "-### -Winvalid-or-nonexistent-directory -target x86_64-sie-ps5" > %t.rsp
 
@@ -33,6 +36,11 @@
 /// headers and libraries.
 // RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %s 2>&1 | FileCheck -check-prefixes=WARN-SYS-HEADERS,WARN-SYS-LIBS,NO-WARN %s
 
+/// -fthinlto-index= warning suppression.
+// RUN: %clang -O2 %s -flto=thin -c -o %t.o
+// RUN: llvm-lto -thinlto -o %t %t.o
+// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck -check-prefixes=NO-WARN %s
+
 /// If `-c`, `-S`, `-E` or `-emit-ast` is supplied, the existence check for SDK
 /// libraries is skipped because no linking will be performed. We only expect
 /// warnings about missing headers.

/// -fthinlto-index= warning suppression.
// RUN: %clang -O2 %s -flto=thin -c -o %t.o
// RUN: llvm-lto -thinlto -o %t %t.o
// RUN: env SCE_PROSPERO_SDK_DIR=.. %clang @%t.rsp %t.o -fthinlto-index=%t.thinlto.bc 2>&1 | FileCheck -check-prefixes=NO-WARN %s
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it realistic to have -fthinlto-index without also -c?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems unlikely. I don't know what the use-case would be for that.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we add the -c to make this more realistic?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've gone ahead and added it without waiting for your reply. My motivation is to reduce the delay for you here. This way if you approve of the PR in either the 799bcfe state or the d3e82d1 state you can indicate that.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Apologies for not expanding on the reasoning behind my query: since this change is motivated by the use of PS clang for remote codegen in a DTLTO context, it would seem sensible to ensure that situation is covered by the testing.

@bd1976bris bd1976bris merged commit d3a813b into llvm:main Nov 12, 2025
10 checks passed
git-crd pushed a commit to git-crd/crd-llvm-project that referenced this pull request Nov 13, 2025
Our driver warns under various circumstances if SDK directories can't be
found.

This warning is not applicable in ThinLTO codegen mode
(-fthinlto-index=). Suppress it.

The motivation for doing this is that we sometimes see this warning
emitted when DTLTO invokes the compiler on a remote machine to
do the LTO backend compilations (with -fthinlto-index=).

Internal Ref: TOOLCHAIN-20592
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants