-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[HLSL] Don't invoke dxv
from clang-dxc
for text output
#135876
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
Conversation
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 llvm#135874.
@llvm/pr-subscribers-hlsl @llvm/pr-subscribers-clang-driver Author: Justin Bogner (bogner) ChangesRunning Fixes #135874. Full diff: https://github.com/llvm/llvm-project/pull/135876.diff 6 Files Affected:
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 -target dxil--shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
-// RUN: %clang -target dxil-unknown-shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
-// RUN: %clang -target dxil--shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
-// RUN: %clang -target dxil-unknown-shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil--shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil-unknown-shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil--shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil-unknown-shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-VALID %s
// Empty shader model
//
|
@llvm/pr-subscribers-clang Author: Justin Bogner (bogner) ChangesRunning Fixes #135874. Full diff: https://github.com/llvm/llvm-project/pull/135876.diff 6 Files Affected:
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 -target dxil--shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
-// RUN: %clang -target dxil-unknown-shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
-// RUN: %clang -target dxil--shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
-// RUN: %clang -target dxil-unknown-shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil--shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil-unknown-shadermodel6.2-pixel %s -S -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil--shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-VALID %s
+// RUN: %clang -target dxil-unknown-shadermodel6.2-library %s -S -o /dev/null 2>&1 | FileCheck --allow-empty --check-prefix=CHECK-VALID %s
// Empty shader model
//
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great! Now I don't have to specify -Vd
when I run clang-dxc without -Fo
:)
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 llvm#135874.
These tests that run In my builds, I'm building with a dynamically linked Previously, we've waived such issues by omitting that kind of tests on Windows (where setting 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 |
I guess another way about it, is to require me to copy in all dependent DLLs into the built |
Ping - any opinion on the above? In theory, we'd have the same issue also for MSVC/clang-cl based builds with I've worked around this issue on my end for now by just manually copying in the host compiler DLL dependencies into the |
Running
clang-dxc
with textual output was emitting various spurious warnings (ifdxv
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.