Skip to content

Pathes in depfiles are not correctly escaped #6570

@pborsutzki

Description

@pborsutzki

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

Metadata

Metadata

Assignees

Labels

bugBug, regression, crash

Type

No type

Projects

Status

Triaged

Relationships

None yet

Development

No branches or pull requests

Issue actions