[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-05-12 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

> These tests that run `env PATH="" %clang_dxc ...` are problematic for my 
> setup for running tests on Windows.
> 
> In my builds, I'm building with a dynamically linked `libc++.dll` provided by 
> my toolchain, which is available in `$PATH`, so the built `bin/clang.exe` 
> requires finding this `libc++.dll` when executed. Normally this works fine, 
> but when invoking tests that do `env PATH="" %clang ...` then `%clang` will 
> run in an environment where it no longer finds its required `libc++.dll` in 
> `$PATH`, and thus fails.
> 
> Previously, we've waived such issues by omitting that kind of tests on 
> Windows (where setting `PATH` also affects where dependent libraries are 
> found) by wrapping `%if !system-windows %{ ... %}` around those bits - see 
> [f5a93c5](https://github.com/llvm/llvm-project/commit/f5a93c5f2a4d0916c975bbf028768d58a29b6b73).

Ping - any opinion on the above?

In theory, we'd have the same issue also for MSVC/clang-cl based builds with 
`/MD` (or `CMAKE_MSVC_RUNTIME_LIBRARY= MultiThreadedDLL`) - however there, the 
compiler support DLLs are found in systemwide default paths, so they're found 
even if running with a cleared `PATH` variable.

I've worked around this issue on my end for now by just manually copying in the 
host compiler DLL dependencies into the `bin` build directory before running 
tests. It works but it's not very pretty. (But if we deem this to be the way to 
go going forward, we should probably revert 
f5a93c5f2a4d0916c975bbf028768d58a29b6b73 as well.)

https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-29 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

These tests that run `env PATH="" %clang_dxc ...` are problematic for my setup 
for running tests on Windows.

In my builds, I'm building with a dynamically linked `libc++.dll` provided by 
my toolchain, which is available in `$PATH`, so the built `bin/clang.exe` 
requires finding this `libc++.dll` when executed. Normally this works fine, but 
when invoking tests that do `env PATH="" %clang ...` then `%clang` will run in 
an environment where it no longer finds its required `libc++.dll` in `$PATH`, 
and thus fails.

Previously, we've waived such issues by omitting that kind of tests on Windows 
(where setting `PATH` also affects where dependent libraries are found) by 
wrapping `%if !system-windows %{ ... %}` around those bits - see 
f5a93c5f2a4d0916c975bbf028768d58a29b6b73.

Would you find it ok to do the same here? As these tests relate to HLSL, 
they're a bit more relevant for running on Windows, but tests clearing `PATH` 
are problematic for builds with a dynamically linked dependency, unfortunately.

https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-29 Thread Martin Storsjö via cfe-commits

mstorsjo wrote:

I guess another way about it, is to require me to copy in all dependent DLLs 
into the built `bin` directory next to `clang.exe` etc. But that's an extra 
step that hasn't been needed so far...

https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-16 Thread Justin Bogner via cfe-commits

https://github.com/bogner closed 
https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-16 Thread Justin Bogner via cfe-commits

https://github.com/bogner updated 
https://github.com/llvm/llvm-project/pull/135876

>From de6d197193e758d649cbebe6d96cd8e5af95d9ac Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Tue, 15 Apr 2025 15:05:21 -0700
Subject: [PATCH 1/2] [HLSL] Don't invoke `dxv` from `clang-dxc` for text
 output

Running `clang-dxc` with textual output was emitting various spurious
warnings (if `dxv` wasn't on your path) or errors (if it was). Avoid
these by not attempting to run this tool when it doesn't make sense to
do so.

Fixes #135874.
---
 clang/lib/Driver/ToolChains/HLSL.cpp|  3 +++
 clang/test/Driver/HLSL/metal-converter.hlsl | 10 ++
 clang/test/Driver/dxc_D.hlsl|  2 +-
 clang/test/Driver/dxc_dxv_path.hlsl |  6 +++---
 clang/test/Driver/dxc_options.hlsl  |  3 +--
 clang/test/Driver/hlsl-lang-targets.hlsl|  8 
 6 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp 
b/clang/lib/Driver/ToolChains/HLSL.cpp
index 22498bff1f251..59e9050af8a76 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -309,6 +309,9 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
 }
 
 bool HLSLToolChain::requiresValidation(DerivedArgList &Args) const {
+  if (!Args.hasArg(options::OPT_dxc_Fo))
+return false;
+
   if (Args.getLastArg(options::OPT_dxc_disable_validation))
 return false;
 
diff --git a/clang/test/Driver/HLSL/metal-converter.hlsl 
b/clang/test/Driver/HLSL/metal-converter.hlsl
index 536f24be6e73b..3c4257b3fbb28 100644
--- a/clang/test/Driver/HLSL/metal-converter.hlsl
+++ b/clang/test/Driver/HLSL/metal-converter.hlsl
@@ -1,11 +1,13 @@
-// RUN: %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | FileCheck %s
-// RUN: %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | FileCheck %s
-// CHECK: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" 
"{{.*}}.mtl"
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
+
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=NO_DXV %s
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=NO_DXV %s
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Vd -Fo 
%t.mtl -### 2>&1 | FileCheck --check-prefix=NO_DXV %s
+// NO_DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" 
"{{.*}}.mtl"
 
 // RUN: %clang_dxc -T cs_6_0 %s -metal -### 2>&1 | FileCheck 
--check-prefix=NO_MTL %s
 // NO_MTL-NOT: metal-shaderconverter
 
-// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
 // RUN: %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=DXV %s
 // DXV: "{{.*}}dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}.dxo"
 // DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.dxo" "-o" "{{.*}}.mtl"
diff --git a/clang/test/Driver/dxc_D.hlsl b/clang/test/Driver/dxc_D.hlsl
index f32a22c503327..5737f0a819d47 100644
--- a/clang/test/Driver/dxc_D.hlsl
+++ b/clang/test/Driver/dxc_D.hlsl
@@ -1,5 +1,5 @@
 // RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
-// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s 
--check-prefix=ERROR
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
 // CHECK:"-D" "TEST=2"
diff --git a/clang/test/Driver/dxc_dxv_path.hlsl 
b/clang/test/Driver/dxc_dxv_path.hlsl
index 55a07f34a648e..65e386f2f35ab 100644
--- a/clang/test/Driver/dxc_dxv_path.hlsl
+++ b/clang/test/Driver/dxc_dxv_path.hlsl
@@ -1,10 +1,10 @@
-// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+// RUN: env PATH="" %clang_dxc -I test -Tlib_6_3 -Fo %T/a.dxo  -### %s 2>&1 | 
FileCheck %s
 
 // Make sure report warning.
 // CHECK:dxv not found
 
-// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
-// DXV_PATH:dxv{{(.exe)?}}" "-" "-o" "{{.*}}.dxo"
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -Fo %T/a.dxo -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}/a.dxo"
 
 // RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s 
--check-prefix=VD
 // VD:"-cc1"{{.*}}"-triple" "dxilv1.3-unknown-shadermodel6.3-library"
diff --git a/clang/test/Driver/dxc_options.hlsl 
b/clang/test/Driver/dxc_options.hlsl
index 09fdba1c3dd5f..5026b75e52688 100644
--- a/clang/test/Driver/dxc_options.hlsl
+++ b/clang/test/Driver/dxc_options.hlsl
@@ -4,5 +4,4 @@
 // RUN: -fdiagnostics-color \
 // RUN: -fno-diagnostics-color \
 // RUN: -fdiagnostics-color=auto \
-// RUN: -Tlib_6_7 -Vd -fdriver-only -- %s 2>&1 |count 0
-
+// RUN: -Tlib_6_7 -fdriver-only -- %s 2>&1 |count 0
diff --git a/clang/test/Driver/hlsl-lang-targets.hlsl 
b/clang/test/Driver/hlsl-lang-targets.hlsl
index 7ce490a66df5f..b321b00548e9b 100644
--- a/clang/te

[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-16 Thread Deric C. via cfe-commits

https://github.com/Icohedron approved this pull request.

This is great! Now I don't have to specify `-Vd` when I run clang-dxc without 
`-Fo` :)

https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-15 Thread Damyan Pepper via cfe-commits

https://github.com/damyanp approved this pull request.


https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-15 Thread Damyan Pepper via cfe-commits


@@ -309,6 +309,9 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
 }
 
 bool HLSLToolChain::requiresValidation(DerivedArgList &Args) const {
+  if (!Args.hasArg(options::OPT_dxc_Fo))
+return false;

damyanp wrote:

Thanks for explaining!

https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-15 Thread Justin Bogner via cfe-commits


@@ -309,6 +309,9 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
 }
 
 bool HLSLToolChain::requiresValidation(DerivedArgList &Args) const {
+  if (!Args.hasArg(options::OPT_dxc_Fo))
+return false;

bogner wrote:

I'm not sure I understand what you mean. The validator runs on the binary dxil 
container - if we're just emitting textual dxil then there's nothing we can run 
the validator on. Currently what happens in that case is that we attempt to run 
the validator but it falls over because the input isn't something it 
understands.

that is,
```
$ ./bin/clang-dxc.exe -T cs_6_2 -Fc x.s e:/tmp/x.hlsl
shader: expected top-level entity
source_filename = "E:/tmp/x.hlsl"
^

clang-dxc: error: dxv command failed with exit code 1 (use -v to see invocation)
```

or if we just output to stdout:
```
$ ./bin/clang-dxc.exe -T cs_6_2 e:/tmp/x.hlsl  >/dev/null
...
The system cannot find the file specified. -
clang-dxc: error: dxv command failed with exit code 1 (use -v to see invocation)
```

https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-15 Thread Damyan Pepper via cfe-commits


@@ -309,6 +309,9 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
 }
 
 bool HLSLToolChain::requiresValidation(DerivedArgList &Args) const {
+  if (!Args.hasArg(options::OPT_dxc_Fo))
+return false;

damyanp wrote:

Doesn't this happen for most of our tests?  I thought we'd want validation to 
generally always be running?

https://github.com/llvm/llvm-project/pull/135876
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang

Author: Justin Bogner (bogner)


Changes

Running `clang-dxc` with textual output was emitting various spurious warnings 
(if `dxv` wasn't on your path) or errors (if it was). Avoid these by not 
attempting to run this tool when it doesn't make sense to do so.

Fixes #135874.

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


6 Files Affected:

- (modified) clang/lib/Driver/ToolChains/HLSL.cpp (+3) 
- (modified) clang/test/Driver/HLSL/metal-converter.hlsl (+6-4) 
- (modified) clang/test/Driver/dxc_D.hlsl (+1-1) 
- (modified) clang/test/Driver/dxc_dxv_path.hlsl (+3-3) 
- (modified) clang/test/Driver/dxc_options.hlsl (+1-2) 
- (modified) clang/test/Driver/hlsl-lang-targets.hlsl (+4-4) 


``diff
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp 
b/clang/lib/Driver/ToolChains/HLSL.cpp
index 22498bff1f251..59e9050af8a76 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -309,6 +309,9 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
 }
 
 bool HLSLToolChain::requiresValidation(DerivedArgList &Args) const {
+  if (!Args.hasArg(options::OPT_dxc_Fo))
+return false;
+
   if (Args.getLastArg(options::OPT_dxc_disable_validation))
 return false;
 
diff --git a/clang/test/Driver/HLSL/metal-converter.hlsl 
b/clang/test/Driver/HLSL/metal-converter.hlsl
index 536f24be6e73b..3c4257b3fbb28 100644
--- a/clang/test/Driver/HLSL/metal-converter.hlsl
+++ b/clang/test/Driver/HLSL/metal-converter.hlsl
@@ -1,11 +1,13 @@
-// RUN: %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | FileCheck %s
-// RUN: %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | FileCheck %s
-// CHECK: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" 
"{{.*}}.mtl"
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
+
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=NO_DXV %s
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=NO_DXV %s
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Vd -Fo 
%t.mtl -### 2>&1 | FileCheck --check-prefix=NO_DXV %s
+// NO_DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" 
"{{.*}}.mtl"
 
 // RUN: %clang_dxc -T cs_6_0 %s -metal -### 2>&1 | FileCheck 
--check-prefix=NO_MTL %s
 // NO_MTL-NOT: metal-shaderconverter
 
-// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
 // RUN: %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=DXV %s
 // DXV: "{{.*}}dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}.dxo"
 // DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.dxo" "-o" "{{.*}}.mtl"
diff --git a/clang/test/Driver/dxc_D.hlsl b/clang/test/Driver/dxc_D.hlsl
index f32a22c503327..5737f0a819d47 100644
--- a/clang/test/Driver/dxc_D.hlsl
+++ b/clang/test/Driver/dxc_D.hlsl
@@ -1,5 +1,5 @@
 // RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
-// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s 
--check-prefix=ERROR
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
 // CHECK:"-D" "TEST=2"
diff --git a/clang/test/Driver/dxc_dxv_path.hlsl 
b/clang/test/Driver/dxc_dxv_path.hlsl
index 55a07f34a648e..65e386f2f35ab 100644
--- a/clang/test/Driver/dxc_dxv_path.hlsl
+++ b/clang/test/Driver/dxc_dxv_path.hlsl
@@ -1,10 +1,10 @@
-// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+// RUN: env PATH="" %clang_dxc -I test -Tlib_6_3 -Fo %T/a.dxo  -### %s 2>&1 | 
FileCheck %s
 
 // Make sure report warning.
 // CHECK:dxv not found
 
-// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
-// DXV_PATH:dxv{{(.exe)?}}" "-" "-o" "{{.*}}.dxo"
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -Fo %T/a.dxo -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}/a.dxo"
 
 // RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s 
--check-prefix=VD
 // VD:"-cc1"{{.*}}"-triple" "dxilv1.3-unknown-shadermodel6.3-library"
diff --git a/clang/test/Driver/dxc_options.hlsl 
b/clang/test/Driver/dxc_options.hlsl
index 09fdba1c3dd5f..5026b75e52688 100644
--- a/clang/test/Driver/dxc_options.hlsl
+++ b/clang/test/Driver/dxc_options.hlsl
@@ -4,5 +4,4 @@
 // RUN: -fdiagnostics-color \
 // RUN: -fno-diagnostics-color \
 // RUN: -fdiagnostics-color=auto \
-// RUN: -Tlib_6_7 -Vd -fdriver-only -- %s 2>&1 |count 0
-
+// RUN: -Tlib_6_7 -fdriver-only -- %s 2>&1 |count 0
diff --git a/clang/test/Driver/hlsl-lang-targets.hlsl 
b/clang/test/Driver/hlsl-lang-targets.hlsl
index 7ce490a66df5f..b321b00548e9b 100644
--- a/clang/test/Driver/hlsl-lang-targets.hlsl
+++ b/clang/test/Driver/hlsl-lang-targets.hlsl
@@ -2,10 +2,10 @@
 
 // Supported targets
 //
-// RUN: %clang -targe

[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-15 Thread via cfe-commits

llvmbot wrote:




@llvm/pr-subscribers-clang-driver

Author: Justin Bogner (bogner)


Changes

Running `clang-dxc` with textual output was emitting various spurious warnings 
(if `dxv` wasn't on your path) or errors (if it was). Avoid these by not 
attempting to run this tool when it doesn't make sense to do so.

Fixes #135874.

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


6 Files Affected:

- (modified) clang/lib/Driver/ToolChains/HLSL.cpp (+3) 
- (modified) clang/test/Driver/HLSL/metal-converter.hlsl (+6-4) 
- (modified) clang/test/Driver/dxc_D.hlsl (+1-1) 
- (modified) clang/test/Driver/dxc_dxv_path.hlsl (+3-3) 
- (modified) clang/test/Driver/dxc_options.hlsl (+1-2) 
- (modified) clang/test/Driver/hlsl-lang-targets.hlsl (+4-4) 


``diff
diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp 
b/clang/lib/Driver/ToolChains/HLSL.cpp
index 22498bff1f251..59e9050af8a76 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -309,6 +309,9 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
 }
 
 bool HLSLToolChain::requiresValidation(DerivedArgList &Args) const {
+  if (!Args.hasArg(options::OPT_dxc_Fo))
+return false;
+
   if (Args.getLastArg(options::OPT_dxc_disable_validation))
 return false;
 
diff --git a/clang/test/Driver/HLSL/metal-converter.hlsl 
b/clang/test/Driver/HLSL/metal-converter.hlsl
index 536f24be6e73b..3c4257b3fbb28 100644
--- a/clang/test/Driver/HLSL/metal-converter.hlsl
+++ b/clang/test/Driver/HLSL/metal-converter.hlsl
@@ -1,11 +1,13 @@
-// RUN: %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | FileCheck %s
-// RUN: %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | FileCheck %s
-// CHECK: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" 
"{{.*}}.mtl"
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
+
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=NO_DXV %s
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=NO_DXV %s
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Vd -Fo 
%t.mtl -### 2>&1 | FileCheck --check-prefix=NO_DXV %s
+// NO_DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" 
"{{.*}}.mtl"
 
 // RUN: %clang_dxc -T cs_6_0 %s -metal -### 2>&1 | FileCheck 
--check-prefix=NO_MTL %s
 // NO_MTL-NOT: metal-shaderconverter
 
-// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
 // RUN: %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=DXV %s
 // DXV: "{{.*}}dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}.dxo"
 // DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.dxo" "-o" "{{.*}}.mtl"
diff --git a/clang/test/Driver/dxc_D.hlsl b/clang/test/Driver/dxc_D.hlsl
index f32a22c503327..5737f0a819d47 100644
--- a/clang/test/Driver/dxc_D.hlsl
+++ b/clang/test/Driver/dxc_D.hlsl
@@ -1,5 +1,5 @@
 // RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
-// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s 
--check-prefix=ERROR
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
 // CHECK:"-D" "TEST=2"
diff --git a/clang/test/Driver/dxc_dxv_path.hlsl 
b/clang/test/Driver/dxc_dxv_path.hlsl
index 55a07f34a648e..65e386f2f35ab 100644
--- a/clang/test/Driver/dxc_dxv_path.hlsl
+++ b/clang/test/Driver/dxc_dxv_path.hlsl
@@ -1,10 +1,10 @@
-// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+// RUN: env PATH="" %clang_dxc -I test -Tlib_6_3 -Fo %T/a.dxo  -### %s 2>&1 | 
FileCheck %s
 
 // Make sure report warning.
 // CHECK:dxv not found
 
-// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
-// DXV_PATH:dxv{{(.exe)?}}" "-" "-o" "{{.*}}.dxo"
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -Fo %T/a.dxo -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}/a.dxo"
 
 // RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s 
--check-prefix=VD
 // VD:"-cc1"{{.*}}"-triple" "dxilv1.3-unknown-shadermodel6.3-library"
diff --git a/clang/test/Driver/dxc_options.hlsl 
b/clang/test/Driver/dxc_options.hlsl
index 09fdba1c3dd5f..5026b75e52688 100644
--- a/clang/test/Driver/dxc_options.hlsl
+++ b/clang/test/Driver/dxc_options.hlsl
@@ -4,5 +4,4 @@
 // RUN: -fdiagnostics-color \
 // RUN: -fno-diagnostics-color \
 // RUN: -fdiagnostics-color=auto \
-// RUN: -Tlib_6_7 -Vd -fdriver-only -- %s 2>&1 |count 0
-
+// RUN: -Tlib_6_7 -fdriver-only -- %s 2>&1 |count 0
diff --git a/clang/test/Driver/hlsl-lang-targets.hlsl 
b/clang/test/Driver/hlsl-lang-targets.hlsl
index 7ce490a66df5f..b321b00548e9b 100644
--- a/clang/test/Driver/hlsl-lang-targets.hlsl
+++ b/clang/test/Driver/hlsl-lang-targets.hlsl
@@ -2,10 +2,10 @@
 
 // Supported targets
 //
-// RUN: %clang

[clang] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output (PR #135876)

2025-04-15 Thread Justin Bogner via cfe-commits

https://github.com/bogner created 
https://github.com/llvm/llvm-project/pull/135876

Running `clang-dxc` with textual output was emitting various spurious warnings 
(if `dxv` wasn't on your path) or errors (if it was). Avoid these by not 
attempting to run this tool when it doesn't make sense to do so.

Fixes #135874.

>From de6d197193e758d649cbebe6d96cd8e5af95d9ac Mon Sep 17 00:00:00 2001
From: Justin Bogner 
Date: Tue, 15 Apr 2025 15:05:21 -0700
Subject: [PATCH] [HLSL] Don't invoke `dxv` from `clang-dxc` for text output

Running `clang-dxc` with textual output was emitting various spurious
warnings (if `dxv` wasn't on your path) or errors (if it was). Avoid
these by not attempting to run this tool when it doesn't make sense to
do so.

Fixes #135874.
---
 clang/lib/Driver/ToolChains/HLSL.cpp|  3 +++
 clang/test/Driver/HLSL/metal-converter.hlsl | 10 ++
 clang/test/Driver/dxc_D.hlsl|  2 +-
 clang/test/Driver/dxc_dxv_path.hlsl |  6 +++---
 clang/test/Driver/dxc_options.hlsl  |  3 +--
 clang/test/Driver/hlsl-lang-targets.hlsl|  8 
 6 files changed, 18 insertions(+), 14 deletions(-)

diff --git a/clang/lib/Driver/ToolChains/HLSL.cpp 
b/clang/lib/Driver/ToolChains/HLSL.cpp
index 22498bff1f251..59e9050af8a76 100644
--- a/clang/lib/Driver/ToolChains/HLSL.cpp
+++ b/clang/lib/Driver/ToolChains/HLSL.cpp
@@ -309,6 +309,9 @@ HLSLToolChain::TranslateArgs(const DerivedArgList &Args, 
StringRef BoundArch,
 }
 
 bool HLSLToolChain::requiresValidation(DerivedArgList &Args) const {
+  if (!Args.hasArg(options::OPT_dxc_Fo))
+return false;
+
   if (Args.getLastArg(options::OPT_dxc_disable_validation))
 return false;
 
diff --git a/clang/test/Driver/HLSL/metal-converter.hlsl 
b/clang/test/Driver/HLSL/metal-converter.hlsl
index 536f24be6e73b..3c4257b3fbb28 100644
--- a/clang/test/Driver/HLSL/metal-converter.hlsl
+++ b/clang/test/Driver/HLSL/metal-converter.hlsl
@@ -1,11 +1,13 @@
-// RUN: %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | FileCheck %s
-// RUN: %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | FileCheck %s
-// CHECK: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" 
"{{.*}}.mtl"
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
+
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=NO_DXV %s
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s -metal -Vd -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=NO_DXV %s
+// RUN: env PATH="" %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Vd -Fo 
%t.mtl -### 2>&1 | FileCheck --check-prefix=NO_DXV %s
+// NO_DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.obj" "-o" 
"{{.*}}.mtl"
 
 // RUN: %clang_dxc -T cs_6_0 %s -metal -### 2>&1 | FileCheck 
--check-prefix=NO_MTL %s
 // NO_MTL-NOT: metal-shaderconverter
 
-// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv
 // RUN: %clang_dxc -T cs_6_0 %s --dxv-path=%T -metal -Fo %t.mtl -### 2>&1 | 
FileCheck --check-prefix=DXV %s
 // DXV: "{{.*}}dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}.dxo"
 // DXV: "{{.*}}metal-shaderconverter{{(.exe)?}}" "{{.*}}.dxo" "-o" "{{.*}}.mtl"
diff --git a/clang/test/Driver/dxc_D.hlsl b/clang/test/Driver/dxc_D.hlsl
index f32a22c503327..5737f0a819d47 100644
--- a/clang/test/Driver/dxc_D.hlsl
+++ b/clang/test/Driver/dxc_D.hlsl
@@ -1,5 +1,5 @@
 // RUN: %clang_dxc -DTEST=2 -Tlib_6_7 -### %s 2>&1 | FileCheck %s
-// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s -fcgl -Fo - | FileCheck %s 
--check-prefix=ERROR
+// RUN: %clang_dxc -DTEST=2  -Tlib_6_7 %s | FileCheck %s --check-prefix=ERROR
 
 // Make sure -D send to cc1.
 // CHECK:"-D" "TEST=2"
diff --git a/clang/test/Driver/dxc_dxv_path.hlsl 
b/clang/test/Driver/dxc_dxv_path.hlsl
index 55a07f34a648e..65e386f2f35ab 100644
--- a/clang/test/Driver/dxc_dxv_path.hlsl
+++ b/clang/test/Driver/dxc_dxv_path.hlsl
@@ -1,10 +1,10 @@
-// RUN: %clang_dxc -I test -Tlib_6_3  -### %s 2>&1 | FileCheck %s
+// RUN: env PATH="" %clang_dxc -I test -Tlib_6_3 -Fo %T/a.dxo  -### %s 2>&1 | 
FileCheck %s
 
 // Make sure report warning.
 // CHECK:dxv not found
 
-// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
-// DXV_PATH:dxv{{(.exe)?}}" "-" "-o" "{{.*}}.dxo"
+// RUN: echo "dxv" > %T/dxv && chmod 754 %T/dxv && %clang_dxc --dxv-path=%T %s 
-Tlib_6_3 -Fo %T/a.dxo -### 2>&1 | FileCheck %s --check-prefix=DXV_PATH
+// DXV_PATH:dxv{{(.exe)?}}" "{{.*}}.obj" "-o" "{{.*}}/a.dxo"
 
 // RUN: %clang_dxc -I test -Vd -Tlib_6_3  -### %s 2>&1 | FileCheck %s 
--check-prefix=VD
 // VD:"-cc1"{{.*}}"-triple" "dxilv1.3-unknown-shadermodel6.3-library"
diff --git a/clang/test/Driver/dxc_options.hlsl 
b/clang/test/Driver/dxc_options.hlsl
index 09fdba1c3dd5f..5026b75e52688 100644
--- a/clang/test/Driver/dxc_options.hlsl
+++ b/clang/test/Driver/dxc_options.hlsl
@@ -4,5 +4,4 @@
 // RUN: -fdiagnostics-color \
 // RUN: -fno-diagnostics-color \
 // RUN: -fdiagnostics-color=auto \
-// RUN: -Tlib_6_7 -Vd -fdriver-onl