Skip to content

Rename /P to /Po; make /P match cl.exe behavior#8165

Merged
damyanp merged 9 commits intomicrosoft:mainfrom
damyanp:4611
Mar 13, 2026
Merged

Rename /P to /Po; make /P match cl.exe behavior#8165
damyanp merged 9 commits intomicrosoft:mainfrom
damyanp:4611

Conversation

@damyanp
Copy link
Copy Markdown
Member

@damyanp damyanp commented Feb 18, 2026

Rename the old FXC-style /P flag to /Po (deprecated) and make /P behave like cl.exe: preprocess to .i by default, with /Fi to specify the output filename. The old /Po positional syntax is preserved with a deprecation warning directing users to /P /Fi.

Fixes #4611

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR renames the old FXC-style /P preprocessing flag to /Po (with deprecation warnings) and makes /P behave like cl.exe, which preprocesses to <inputname>.i by default. The change maintains backward compatibility through /Po while aligning DXC's behavior with the widely-used Microsoft C/C++ compiler.

Changes:

  • Added new /Po flag preserving FXC-style preprocessing behavior (deprecated)
  • Updated /P to match cl.exe: defaults to <input>.i, supports /Fi to override
  • Maintained support for old /Po <filename> positional syntax with deprecation warnings

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
include/dxc/Support/HLSLOptions.td Adds /Po flag definition for backward compatibility
lib/DxcSupport/HLSLOptions.cpp Implements separate logic for /P (cl.exe-style) and /Po (FXC-style with deprecation)
tools/clang/unittests/HLSL/OptionsTest.cpp Adds comprehensive unit tests for both /P and /Po behaviors
tools/clang/test/DXC/preprocess.test Adds integration tests verifying preprocessing with /P and /Po
docs/ReleaseNotes.md Documents the command-line interface changes

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/clang/test/DXC/preprocess.test Outdated
Comment thread docs/ReleaseNotes.md Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread tools/clang/unittests/HLSL/OptionsTest.cpp
Comment thread lib/DxcSupport/HLSLOptions.cpp Outdated
@damyanp damyanp marked this pull request as draft February 18, 2026 22:18
@damyanp damyanp marked this pull request as ready for review February 19, 2026 00:27
Copy link
Copy Markdown
Collaborator

@Icohedron Icohedron left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks ok to me!

Comment thread lib/DxcSupport/HLSLOptions.cpp Outdated
@damyanp damyanp requested review from Icohedron and bob80905 March 11, 2026 00:33
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 11, 2026

✅ With the latest revision this PR passed the C/C++ code formatter.

@damyanp
Copy link
Copy Markdown
Member Author

damyanp commented Mar 11, 2026

Gah, I merged the wrong main into this branch. I'm afraid I'm going to have to do a rebase + force push.

damyanp and others added 7 commits March 10, 2026 18:10
Rename the old FXC-style /P flag to /Po (deprecated) and make /P
behave like cl.exe: preprocess to <input>.i by default, with /Fi to
specify the output filename. The old /Po <filename> positional syntax
is preserved with a deprecation warning directing users to /P /Fi.

Fixes microsoft#4611

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Verify /Po deprecation warning is emitted in preprocess.test
- Clarify ReleaseNotes.md: positional syntax is deprecated and moved
  to /Po, not removed entirely

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Update test to use -P -Fi instead of the old -P <filename> syntax,
which was changed to -Po in the previous commit.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add test cases verifying that /P with extra positional arguments
(e.g. -P out.pp input.hlsl) does not emit the deprecation warning
that is specific to /Po. These cases confirm the /P and /Po code
paths are fully independent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the deprecation warning to fire for every /Po usage, not just
the positional-filename case. The warning adapts its suggestion:
- /Po with default output: 'please use /P instead'
- /Po with /Fi or positional filename: 'please use /P /Fi <file> instead'

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Replace bare /P and /Po tests that wrote smoke.i next to the source
file with /P /Fi %t variants that write to the output directory.
The default filename logic is already covered by unit tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the /P and /Po preprocess option handling into a standalone
static helper function, reducing nesting in ReadDxcOpts to a
single line: opts.Preprocess = getPreprocessOutput(Args, Errors);

No behavioral change.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Comment thread docs/ReleaseNotes.md Outdated
@damyanp damyanp requested review from llvm-beanz and tex3d March 12, 2026 17:39
Copy link
Copy Markdown
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks good, and I checked the API wrapper, and it looks like it will be ok, but that wrapper does not use the expected default name.

That would probably be the one improvement I'd recommend, to update this hard-coded name to be based on the pSourceName (<inputname>.i) instead:

LPCWSTR PreprocessArgs[] = {L"-P", L"-Fi", L"preprocessed.hlsl"};

@tex3d
Copy link
Copy Markdown
Contributor

tex3d commented Mar 12, 2026

That would probably be the one improvement I'd recommend, ...

I suppose you could consider this is a separate change, but it did seem related to cleaning up the old behavior.

Copy link
Copy Markdown
Contributor

@tex3d tex3d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this looks fine. Regarding my previous comment, it's unlikely anyone will be seeing or depending on the hard coded file name, it was just something that looked inconsistent with the current default file name for the output. I'm ok with leaving it as-is.

@damyanp damyanp merged commit 054e0f5 into microsoft:main Mar 13, 2026
12 checks passed
@github-project-automation github-project-automation Bot moved this from New to Done in HLSL Roadmap Mar 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Rename /P to /Po and match cl.exe /P behavior

5 participants