microsoft / microsoft/vscode-cpptools

Exclude arguments from compiler queries that are not relevant to system includes or system defines

Open
#12,106 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

compiler support Feature: Compile Commands Language Service
Dominant language
TypeScript
Stars
6.2k
Forks
1.7k
Avg merge
14h 46m
Merged PRs (30d)
61

Description

Currently, when a compile_commands.json contains many command lines, cpptools will try to evaluate them all, in case multiple different compilers are present, different sysroots are used, or there are other args that may influence the resulting system include paths (or that we do not know will not), in order to accumulate system include paths from all of them for ingestion into the browse database.

There are various arguments (/I/-I, /D/-D, etc.) that we know will not be relevant to the compiler query. When many command lines vary by only those known irrelevant arguments, only one query is required. A problem can arise if there are arguments present that we do not know are not relevant to the query, that are different across many command lines, resulting in an excessive number of compiler queries. Often those are arguments that involve values that refer to the source file path, or some path derived from the source file path.

Opening this issue to track any arguments that could be added to our 'not relevant to a compiler query' list. Note cl is never queried, but clang-cl is, so cl arguments still need to be considered. I think clang-cl support is our biggest gap here.

(using ? as a wildcard)

  • /wd???? (CL)- used to disable compiler warnings. (Though /WX does influence the output of clang-cl)
  • /O?, /Gw? (CL) - Optimization options shouldn't influence system includes or defines.
  • -fno-math-errno (GCC) - There are probably lots of these -f arguments that are irrelevant to the compiler query, but perhaps several that are.

Related: The compiler query logic needs to be aware of which arguments involve additional following (separate) arguments, so we know to not evaluate those additional arguments as separate compiler arguments. Compiler querying issues can often be traced to new arguments added to compilers that involve additional following arguments, which need to be added to our list.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the compiler query logic and how it processes compile_commands.json, paying particular attention to clang-cl and the listed cl-style arguments. Review how arguments with separate following values are handled. Done means the relevant irrelevant arguments and their associated values are excluded from compiler-query variation without changing system include or define results.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, typescript
Domain
compilers, devtools
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.