Skip to content
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

Clang-CL 15.x reporting warning when using /clang:-xc #59307

Closed
dgehriger opened this issue Dec 2, 2022 · 9 comments
Closed

Clang-CL 15.x reporting warning when using /clang:-xc #59307

dgehriger opened this issue Dec 2, 2022 · 9 comments
Assignees
Labels
clang-cl `clang-cl` driver. Don't use for other compiler parts confirmed Verified by a second party

Comments

@dgehriger
Copy link

dgehriger commented Dec 2, 2022

OS: Windows

Unlike previous versions, when running clang-cl.exe version 15.x as follows from a cmd.exe prompt:

clang-cl /WX /clang:-xc /clang:-E /clang:-dM nul

It outputs the following warning:

clang-cl: error: '-x c' after last input file has no effect [-Werror,-Wunused-command-line-argument]

Expected outcome is no error, and dumping of preprocessor variables.

Among other things, this prevents clang-cl 15.x from being used by Visual Studio Code's C++ extension for Intellisense.

@EugeneZelenko EugeneZelenko added clang-cl `clang-cl` driver. Don't use for other compiler parts and removed new issue labels Dec 2, 2022
@efriedma-quic
Copy link
Collaborator

As a workaround, the following should work on both old and new versions of clang-cl:

clang-cl /WX /TC /E /clang:-dM nul

@AaronBallman
Copy link
Collaborator

@Fznamznon -- I assigned this one to you because I figured it was one you might be able to knock out pretty quickly, but if you don't feel like it, feel free to unassign yourself. :-)

@Fznamznon
Copy link
Contributor

For some reason -x c argument gets bigger index than input file argument in cl mode. Not sure why yet.

@Fznamznon
Copy link
Contributor

Fznamznon commented Jan 27, 2023

Ah, I see. In cl mode /clang: arguments are parsed and appended at the end of the list. I would suggest just to not emit a warning in cl mode since it was implemented to match gcc behavior anyway (e2a1f8e).
Another thing comes in mind that if all clang: arguments go to the end of list, clang:-x doesn't make sense at all, which is actually we get warning about just not with the right words.

@AaronBallman
Copy link
Collaborator

@MaskRay -- is it expected that all /clang: arguments are appended? That seems likely to cause a fair amount of confusion in practice, but perhaps I'm missing something.

@Fznamznon
Copy link
Contributor

In case silencing the warning in cl mode sounds okay-ish, I've prepared https://reviews.llvm.org/D142757 . Otherwise if we want to emit a correct warning in cl mode, we need to change how to /clang: arguments are processed and for that I'm not sure I have enough driver experience to do quickly.

@MaskRay
Copy link
Member

MaskRay commented Jan 29, 2023

The error is emitted as intended. /clang:-xc nul is handled like nul -xc and the -xc does not take effect.
This likely has been the case since https://reviews.llvm.org/D53457 added /clang: in 2018-11. therefore I don't think the new feature has a legitimate use case.
It's difficult to use interleaved semantics instead of appending semantics.

So simply ignoring the error in CL mode (https://reviews.llvm.org/D142757) looks wrong to me.
I think we should just report an error for /clang:-xc. Left a comment on the patch about the change.

@huangqinjin
Copy link
Contributor

clang-cl -help shows that -x is supported directly. But clang-cl -x c++-module report an error

unsupported option '-x c++-module'; did you mean '/TC' or '/TP'?

Unfortunately there is no coresponding flag to specify C++20 Modules.

@huangqinjin
Copy link
Contributor

clang-cl -help shows that -x is supported directly.

It was added by #68921 to support CUDA/HIP. Looks to me -x should be supported for all languages. I've opened #88006.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-cl `clang-cl` driver. Don't use for other compiler parts confirmed Verified by a second party
Projects
None yet
Development

No branches or pull requests

7 participants