Skip to content

Conversation

@s-perron
Copy link
Contributor

Changes the driver to assume input file with an unknown extension are
HLSL source files instead of object files.

Fixes #137370

Changes the driver to assume input file with an unknown extension are
HLSL source files instead of object files.

Fixes llvm#137370
@s-perron s-perron requested a review from llvm-beanz April 25, 2025 18:07
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' labels Apr 25, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 25, 2025

@llvm/pr-subscribers-clang-driver

Author: Steven Perron (s-perron)

Changes

Changes the driver to assume input file with an unknown extension are
HLSL source files instead of object files.

Fixes #137370


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

2 Files Affected:

  • (modified) clang/lib/Driver/Driver.cpp (+2)
  • (added) clang/test/Driver/dxc_I.test (+4)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 2b8c6e35263b1..a648cc928afdc 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3001,6 +3001,8 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
               Ty = types::TY_CXX;
             else if (CCCIsCPP() || CCGenDiagnostics)
               Ty = types::TY_C;
+            else if (IsDXCMode())
+              Ty = types::TY_HLSL;
             else
               Ty = types::TY_Object;
           }
diff --git a/clang/test/Driver/dxc_I.test b/clang/test/Driver/dxc_I.test
new file mode 100644
index 0000000000000..e88537c6b1ab8
--- /dev/null
+++ b/clang/test/Driver/dxc_I.test
@@ -0,0 +1,4 @@
+// RUN: %clang_dxc -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+
+// Make sure a non `.hlsl` file is considered an HLSL source file in dxc mode.
+// CHECK: "-x" "hlsl" "{{.*}}/dxc_I.test"

@llvmbot
Copy link
Member

llvmbot commented Apr 25, 2025

@llvm/pr-subscribers-clang

Author: Steven Perron (s-perron)

Changes

Changes the driver to assume input file with an unknown extension are
HLSL source files instead of object files.

Fixes #137370


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

2 Files Affected:

  • (modified) clang/lib/Driver/Driver.cpp (+2)
  • (added) clang/test/Driver/dxc_I.test (+4)
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index 2b8c6e35263b1..a648cc928afdc 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -3001,6 +3001,8 @@ void Driver::BuildInputs(const ToolChain &TC, DerivedArgList &Args,
               Ty = types::TY_CXX;
             else if (CCCIsCPP() || CCGenDiagnostics)
               Ty = types::TY_C;
+            else if (IsDXCMode())
+              Ty = types::TY_HLSL;
             else
               Ty = types::TY_Object;
           }
diff --git a/clang/test/Driver/dxc_I.test b/clang/test/Driver/dxc_I.test
new file mode 100644
index 0000000000000..e88537c6b1ab8
--- /dev/null
+++ b/clang/test/Driver/dxc_I.test
@@ -0,0 +1,4 @@
+// RUN: %clang_dxc -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+
+// Make sure a non `.hlsl` file is considered an HLSL source file in dxc mode.
+// CHECK: "-x" "hlsl" "{{.*}}/dxc_I.test"

@s-perron s-perron merged commit cc0cf72 into llvm:main Apr 29, 2025
11 checks passed
@s-perron s-perron deleted the file_extension branch April 30, 2025 13:53
IanWood1 pushed a commit to IanWood1/llvm-project that referenced this pull request May 6, 2025
Changes the driver to assume input file with an unknown extension are
HLSL source files instead of object files.

Fixes llvm#137370
GeorgeARM pushed a commit to GeorgeARM/llvm-project that referenced this pull request May 7, 2025
Changes the driver to assume input file with an unknown extension are
HLSL source files instead of object files.

Fixes llvm#137370
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.

[HLSL][SPIRV] Allow source files with extensions other than .hlsl in dxc mode.

3 participants