microsoft / microsoft/DirectXShaderCompiler
Pathes in depfiles are not correctly escaped
@pborsutzki is already working on this.
Since Apr 29, 2024.
- Dominant language
- C++
- Stars
- 3.7k
- Forks
- 900
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 44
Description
Description
When generating a depfile through any of the -M* switches, the generated output does not contain escaped pathes. Due to the depfile format (output: input0 input1 ...) this can lead to ambiguities in tools that parse these files like the Ninja build system.
Steps to Reproduce
- Use a Windows machine.
- Setup a valid source file, e.g.:
[numthreads(1,1,1)]
void main() {}
- Compile any file using DXC with an
-M*switch while specifying an absolute path to the source file, e.g.dxc -T cs_6_0 -M e:\foo.hlsl. - Get this output:
e:\foo.hlsl: e:\foo.hlsl
Actual Behavior
DXC returns this result: e:\foo.hlsl: e:\foo.hlsl
This result is ambiguous due to the additional colons :. To me, the format of depfiles does not seem to be clearly specified (it seems to be specified "like makefiles"). But other tools (e.g. Ninja build, Slang) avoid the ambiguity by escaping/expecting escaped pathes in depfiles. So a correct output in my opinion would be this:
e\:\\foo.hlsl: e\:\\foo.hlsl
More problems can occur when using other problematic characters for makefiles like whitespace, #, $, \, [ and ].
Environment
- DXC version 1.7.2308
- Host Operating System Windows 10 Enterprise 22H2
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.