Skip to content

[HLSL] Allow non .hlsl files as source files #137378

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 29, 2025
Merged

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
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
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
Ankur-0429 pushed a commit to Ankur-0429/llvm-project that referenced this pull request May 9, 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