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

Does Codechecker Supports hooking MSBuild like it does for the Makefile? #3846

Closed
VenoVeno opened this issue Feb 22, 2023 · 9 comments
Closed

Comments

@VenoVeno
Copy link

Codecheckers takes all the GCC Commands and forwards to Clang Compiler.
Can it be done for the same way for MSBuild?

@bruntib
Copy link
Contributor

bruntib commented Feb 22, 2023

The command CodeChecker log is capturing exec() calls and logs the compiler invocations. The possible compiler names are listed in CC_LOGGER_GCC_LIKE environment variable. For further details see this documentation: https://github.com/Ericsson/codechecker/blob/master/docs/analyzer/user_guide.md#log
However, currently Microsoft platform is not supported by CodeChecker.

@VenoVeno
Copy link
Author

Hi bruntib.
Thanks for your reply.

Is it possible to compile MSVC devloped Source with Clang compiler?
As mentioned Clang supports MSVC? link.

@bruntib
Copy link
Contributor

bruntib commented Feb 22, 2023

Hi,

CodeChecker does some transformation of (mainly) gcc build commands: https://github.com/Ericsson/codechecker/blob/master/analyzer/codechecker_analyzer/buildlog/log_parser.py
I'm not sure how this works together with MSVC. It might work, but we don't support MSVC compatibility. It would be interesting to hear your experiences with it. And if it turns out that MSVC also works together with CodeChecker, then we can consider supporting it in the future.

Thanks!

@VenoVeno
Copy link
Author

Hi,

Clang also doesn't provide full support for MSVC. llvm/llvm-project#59997
Tried the experimental flags like -fms-compatibility, -fdelayed-template-parsing, -fms-extensions

And if it turns out that MSVC also works together with CodeChecker, then we can consider supporting it in the future.

That's good to know. 🤞

@whisperity
Copy link
Contributor

@VenoVeno If you can craft a compilation database without using our logger, either by using and emitting it from CMake or looking how MSBuild can generate a compilation database, CodeChecker might be capable of running the analysis, see #555. If you gather some experience here we would be happy to hear — as far as I understand, none of us in the team use Windows for development, so Windows support has not been in scope for us for quite a while.

Whether Clang itself can consume some specific Windows or 3rd-party library on Windows is not solvable from CodeChecker's side; unless there is some magic flag that we need to inject to Clang that's not present in the original compilation database — that's all we can do…

@whisperity whisperity added analyzer 📈 Related to the analyze commands (analysis driver) ld-logger 📃 platform-Windows 🖥 labels Feb 23, 2023
@VenoVeno
Copy link
Author

Hi, @whisperity

If you can craft a compilation database without using our logger, either by using and emitting it from CMake or looking how MSBuild can generate a compilation database.

Though MSBuild emits compilation database, it will invoke the Visual Studio as it is a compiler.

CodeChecker might be capable of running the analysis

If so, does Codechecker supports the compiler argument parsing? I don't have any idea about how the arguments are parsed. Some arguments like /GS /I /W3 /D. Codechecker won't parse these arguments right? The arguments are required for MSVC Project to build.

If you gather some experience here we would be happy to hear

The AST is generated by the Clang Compiler, forwarding all the (GCC, G++) arguments in the format of Clang compiler understanding. Correct me if i'm wrong about it. If that's the case though i manage to get the compilation database, still the AST generation requires compilation Ref here. The MSVC Code should be able to parse by the Clang Compiler, whereas Clang doesn't have full support for the MSVC Source 😞

llvm/llvm-project#59997

unless there is some magic flag that we need to inject to Clang that's not present in the original compilation database

If Clang have a fault tolerant parser using any flags to generate AST it would be better but it doesn't have one llvm/llvm-project#59700.

@whisperity
Copy link
Contributor

If so, does Codechecker supports the compiler argument parsing? I don't have any idea about how the arguments are parsed. Some arguments like /GS /I /W3 /D. Codechecker won't parse these arguments right? The arguments are required for MSVC Project to build.

Okay, that's a game-breaking thing on our end. And I have no idea what those flags mean, so it would definitely require non-trivial effort to rewrite an MSVC compile command onto a GCC (or Clang) compile command.

The MSVC Code should be able to parse by the Clang Compiler, whereas Clang doesn't have full support for the MSVC Source 😞

This is unfortunately out of our hands (at least in the CodeChecker project). The best we could do (but do not do right now) is to craft the compile command necessary to at least call Clang with some sensible input parameters. If despite this effort Clang can't parse the input and start the analysis, then what CodeChecker will do (and actually does if the original project is working on Linux but somehow fail the analysis) is to report which source files could not be analysed. And if some parts of the project do analyse, we can show results from that part at least.

@whisperity
Copy link
Contributor

(I close this question purely to ensure we have the meta-discussion about Windows continuously in #555 instead.)

@whisperity whisperity closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
@VenoVeno
Copy link
Author

It would definitely require non-trivial effort to rewrite an MSVC compile command onto a GCC (or Clang) compile command.

Yes. That needs lot of effort in implementing all possibles.

The best we could do (but do not do right now) is to craft the compile command necessary to at least call Clang with some sensible input parameters. If despite this effort Clang can't parse the input and start the analysis.

I agree.

And if some parts of the project do analyse, we can show results from that part at least.

As most of the files are Visual C++ implementation with windows Windows SDK and API dependency, all the source parsing failed.

Anyways. Thanks for the awesome tool. 👏

@VenoVeno VenoVeno reopened this Feb 24, 2023
@whisperity whisperity closed this as not planned Won't fix, can't repro, duplicate, stale Feb 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants