Bug 206738 - [CMake] Provide a “tooling build” configuration option
Summary: [CMake] Provide a “tooling build” configuration option
Status: ASSIGNED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CMake (show other bugs)
Version: WebKit Local Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Don Olmstead
URL:
Keywords:
Depends on:
Blocks: 206737
  Show dependency treegraph
 
Reported: 2020-01-24 05:03 PST by Adrian Perez
Modified: 2024-04-23 02:30 PDT (History)
4 users (show)

See Also:


Attachments
WIP Patch (6.90 KB, patch)
2020-05-07 16:24 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
WIP Patch (9.18 KB, patch)
2020-05-07 21:46 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff
WIP Patch (6.35 KB, patch)
2020-05-15 14:16 PDT, Don Olmstead
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Adrian Perez 2020-01-24 05:03:16 PST
I am splitting this out from bug #206737 because I think it will
be uncontroversial. The idea is to have a build option which does
whatever is needed to make standard tools work with a compilation
database (a.k.a. that “compile_commands.json” file).

At least such an option should:

 - Set CMAKE_EXPORT_COMPILE_COMMANDS=ON (yay!)
 - Set ENABLE_DEVELOPER_BUILD=ON (of course!)
 - Set ENABLE_UNIFIED_BUILDS=OFF (because unified builds play
   badly with many third-party tools, ouch!)
 - Define a target which can be used to generate all the needed
   derived sources and copy forwarding headers, so it's possible
   to run “ninja tooling-prepare“ (or similar).
Comment 1 Carlos Alberto Lopez Perez 2020-01-24 06:39:11 PST
(In reply to Adrian Perez from comment #0)
>  - Set ENABLE_UNIFIED_BUILDS=OFF (because unified builds play
>    badly with many third-party tools, ouch!)

Any example of such tools?
Comment 2 Don Olmstead 2020-01-30 09:42:06 PST
(In reply to Carlos Alberto Lopez Perez from comment #1)
> (In reply to Adrian Perez from comment #0)
> >  - Set ENABLE_UNIFIED_BUILDS=OFF (because unified builds play
> >    badly with many third-party tools, ouch!)
> 
> Any example of such tools?

A lot of the clang tools. I'd really like to run include-what-you-use over the codebase. Would also be nice to use clang-tidy especially if we can integrate it into the style checker and maybe even write our own rules.
Comment 3 Adrian Perez 2020-01-31 00:36:15 PST
(In reply to Don Olmstead from comment #2)
> (In reply to Carlos Alberto Lopez Perez from comment #1)
> > (In reply to Adrian Perez from comment #0)
> > >  - Set ENABLE_UNIFIED_BUILDS=OFF (because unified builds play
> > >    badly with many third-party tools, ouch!)
> > 
> > Any example of such tools?
> 
> A lot of the clang tools. I'd really like to run include-what-you-use over
> the codebase. Would also be nice to use clang-tidy especially if we can
> integrate it into the style checker and maybe even write our own rules.

Another (IMO important) one is scan-build, for static analysis.

Also, LSP (Language Server Protocol) plug-ins for editors and IDEs
need a compilation database that reflects what the actual sources
are, without unified sources.
Comment 4 Don Olmstead 2020-05-07 16:24:05 PDT Comment hidden (obsolete)
Comment 5 Don Olmstead 2020-05-07 21:46:08 PDT Comment hidden (obsolete)
Comment 6 Don Olmstead 2020-05-15 14:16:59 PDT
Created attachment 399510 [details]
WIP Patch
Comment 7 Don Olmstead 2020-05-15 14:28:26 PDT
To run the work in progress patch you need to pass a CMake arg, ANALYZERS, and that can be any combination of clang-tidy iwyu and lwyu.

For example here's what my command line looks like for running this on WinCairo.

```
perl .\Tools\Scripts\build-webkit --wincairo --skip-library-update --generate-project-only --cmakeargs='-DANALYZERS="iwyu"'
```

You can specify multiple by doing ; between values.

```
perl .\Tools\Scripts\build-webkit --wincairo --skip-library-update --generate-project-only --cmakeargs='-DANALYZERS="clang-tidy;iwyu"'
```

For OS X users theres brew for getting it installed https://formulae.brew.sh/formula/include-what-you-use
For Linux users theres an apt-get
For Windows users you need to build it yourself
Comment 8 David Kilzer (:ddkilzer) 2020-06-17 18:28:59 PDT
To find issues with uninitialized data members in structs/classes like:
Bug 213173: REGRESSION(r262994): [GTK] More than 100 tests are failing

We can use the following checkers:

optin.cplusplus.UninitializedObject -- clang static analyzer
<https://clang.llvm.org/docs/analyzer/checkers.html#optin-cplusplus-uninitializedobject-c>

cppcoreguidelines-pro-type-member-init -- clang tidy
<https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.html>

(I'm adding this comment here in case we use this to decide which checkers to enable.)