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

Support for "-imacros", filtered out by CodeChecker #3456

Closed
yalfg opened this issue Oct 19, 2021 · 3 comments
Closed

Support for "-imacros", filtered out by CodeChecker #3456

yalfg opened this issue Oct 19, 2021 · 3 comments
Labels
analyzer 📈 Related to the analyze commands (analysis driver) config ⚙️ duplicate 👥

Comments

@yalfg
Copy link

yalfg commented Oct 19, 2021

CodeChecker version 6.15.2 (snap package) filters out the "-imacros" compiler option from a compilation database. This can lead to a compilation failure during analysis, due to missing macro definitions.

When those options are global for a project, it is possible to work around this by adding those options to 2 files, for clangsa and clang-tidy. For clangsa, using CodeChecker "--saargs" option, the content will be lines like:

-imacros /path/to/header/file1.h
...

This amounts to passing the options directly to clang. However clang-tidy does not support this option directly, so a two level bypass is needed. Using "--tidyargs", construct a file with:

--extra-arg-before=-imacros/path/to/header/file1.h
...

This tells CodeChecker to tell clang-tidy to pass the option to the underlying clang compiler two steps down ;)

It would be nice if CodeChecker would not filter out "-imacros " arguments when calling clangsa, as clangsa can support this natively. For clang-tidy it could be possibly to automate the above work-around, but it doesn't preserve the command line ordering. This would require a change in clang-tidy itself to directly support "-imacros". Even if CodeChecker doesn't want to include a half-baked work-around, this issue may help some people.

As a example the Zephyr open source RTOS uses "-macros" for the system configuration.

Thanks

@whisperity
Copy link
Contributor

Hey!

I think we already fixed this as per another user's request, see #3428. I'm not sure which release it went or will go into, the Milestone field says 6.17.1 and the commit is not associated with any branch apart from master.

Could you please try with a newer version, or preferably, for the sake of testing, a self-compiled version of CodeChecker?


As a example the Zephyr open source RTOS uses "-macros" for the system configuration.

@yalfg -macros or -imacros? Was that a typo from your side, or is there actually a -macros flag? Because the entirety of the investigation that led up to #3428 involved that we figured out that we accidentally typod -macros into CodeChecker's source code at an earlier refactoring, which broke the support of this flag...

@whisperity whisperity added analyzer 📈 Related to the analyze commands (analysis driver) config ⚙️ duplicate 👥 question ❔ labels Oct 20, 2021
@yalfg
Copy link
Author

yalfg commented Oct 20, 2021

Yes, it looks like #3428 fixes this and my report is a dupe. I will try to build from source to confirm.

And I made the same typo at the end of my report, it's indeed "-imacros" not "-macros" ;)

@yalfg
Copy link
Author

yalfg commented Oct 20, 2021

Top of tree works fine, it was a dupe. Sorry for the noise...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
analyzer 📈 Related to the analyze commands (analysis driver) config ⚙️ duplicate 👥
Projects
None yet
Development

No branches or pull requests

2 participants