Skip to content

build: run linux clang-tidy as remotely cached siso build steps - #53447

Merged
MarshallOfSound merged 12 commits into
mainfrom
build/clang-tidy-siso
Sep 5, 2026
Merged

MarshallOfSound merged 12 commits into
mainfrom
build/clang-tidy-siso

Conversation

@MarshallOfSound

@MarshallOfSound MarshallOfSound commented Sep 3, 2026 •

Copy link
Copy Markdown
Member

Description of Change

Run clang-tidy as siso build steps: one step per shell/ translation unit, shaped like a compile so siso include-scans it, looks it up in the RBE action cache, and runs misses on the worker pool instead of the runner's own cores.

  • script/gen-clang-tidy-ninja.py generates out/<dir>/clang_tidy.ninja from compile_commands.json.
  • build/run-clang-tidy-action.sh is the per-step wrapper (clang-tidy --warnings-as-errors=*, then header deps, then a stamp).
  • build/siso/main.star adds the electron/clang-tidy step rule (copy of build-tools' entry file for now).
  • The clang-tidy CI segment runs e build -f clang_tidy.ninja electron_clang_tidy on all three legs.
leg tidy job before first run (all remote) rerun (all cached)
linux-x64 ~16 min 4.9 min, 342 steps 342/342 cache hits
windows-x64 ~18 min 6.4 min, 344 steps 344/344 cache hits
macos-arm64 ~36 min 10.9 min, 371 steps 371/371 cache hits

Checklist

  • PR description included

Release Notes

Notes: none

Prototype for the linux-x64 leg. Instead of run-clang-tidy.ts walking
shell/ on the runner's own cores, generate one ninja step per translation
unit and let siso treat it like a compile: include-scan the inputs, look
the action up in the RBE cache, and execute misses on the worker pool.

- script/gen-clang-tidy-ninja.py writes out/<dir>/clang_tidy.ninja from
  compile_commands.json: `run-clang-tidy-action.sh <clang++> <flags> -c
  <src> -o <stamp>` per shell/ TU, with a gcc depfile so ninja/siso track
  header deps.
- build/run-clang-tidy-action.sh runs clang-tidy with
  --warnings-as-errors=* (so only clean results are cached), then
  `clang -M` for the depfile, then touches the stamp.
- build/siso/main.star is build-tools' siso entry file plus an
  `electron/clang-tidy` step rule (remote, clang-tidy/.clang-tidy files as
  inputs); the tidy job points ELECTRON_BUILD_TOOLS_MAIN_STAR at it.
- The linux leg of the clang-tidy segment now does `e init --remote-build
  siso`, gn gen with compile commands for //electron:*, generates the
  ninja file and runs `e build -f clang_tidy.ninja electron_clang_tidy`.
  It gets ELECTRON_RBE_JWT for that. mac and win legs are unchanged.

Measured against out/Testing on rbe.notgoma.com: 343 TUs, cold run all
remote in 115 s wall (150 CPU-min of work, bounded by the slowest TU),
fully cached rerun 2.3 s, and a planted finding fails the step with the
diagnostic and is not cached.
- gen-clang-tidy-ninja.py understands clang-cl commands (drops /c, /Fo,
  /Fd, /showIncludes) and emits `deps = msvc` for them, which is also what
  tells siso to parse the command cl-style when scanning for #includes.
- run-clang-tidy-action.sh: for clang-cl, run clang-tidy in cl driver mode
  and report headers via /showIncludes; when the host toolchain isn't
  runnable (macOS binaries on the Linux workers) use the Linux one that
  clang_remote_wrapper stages under Release+Asserts_linux.
- build/siso/main.star: off Linux, run the tidy step through
  clang_remote_wrapper with the Linux clang and clang-tidy as inputs, like
  the clang rules.
- The clang-tidy segment uses the siso path on every platform; on macOS it
  first generates the reclient configs (which fetches the Linux clang) and
  downloads the Linux clang-tidy package next to it.
…ative source path

clang-tidy appends an absolute source path to `-- <flags>` commands, and on the RBE workers that path starts with /worker, which the cl driver parses as a /w option ('no input files'). A compilation database entry keeps the command as written.
A source built by several targets (electron_app and the helper app on macOS) has several compile commands with different flags; picking one by source path was order-dependent and cost two cache misses per run. Key steps on the object path instead.

@dsanders11 dsanders11 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall LGTM, just a few potential footguns that would be nice to clear out. Left an inline comment in addition to these comments.

It's possible to add .clang-tidy configs under subdirectories, it's a pattern that upstream Chromium uses. Since this PR explicitly lists the .clang-tidy files, if a future PR adds a .clang-tidy config in a subdirectory it won't be picked up and it could lead to false negatives in CI. There's potential fixes here to properly handle this, or we detect the creation of these subdirectory configs and force the PR that adds one to also update the list of inputs, but I think we should do one or the other rather than leaving that as a lurking footgun.

I think we should add some comments to make it clear these scripts aren't meant to be run locally, just in CI - maybe even bail out if the CI environment variable isn't set? They're easy to get inaccurate results if you don't run things in the exact right order, so I think we shouldn't make it easy to run locally.

Comment thread build/run-clang-tidy-action.sh Outdated
trap 'rm -rf "$output.compdb"' EXIT
echo "[{\"directory\": \"$PWD\", \"file\": \"$source\", \"arguments\": $(json_list "$clang" "${flags[@]}" "$source")}]" \
> "$output.compdb/compile_commands.json"
"$clang_tidy" -p "$output.compdb" --quiet --header-filter= --warnings-as-errors='*' "$source"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lets set HeaderFilterRegex: '' in .clang-tidy and remove it from this line and script/run-clang-tidy.ts so that they can't diverge - I have a WIP change that'll be changing it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done in c3bcb0e. HeaderFilterRegex: '' is in .clang-tidy now, and both --header-filter flags are gone. They have to change together, because this clang-tidy reports header diagnostics when no filter is set.

dsanders11 pushed a commit to electron/build-tools that referenced this pull request Sep 4, 2026
Adds an electron/clang-tidy step rule for the per-translation-unit steps that electron/script/gen-clang-tidy-ninja.py generates (electron/electron#53447). The steps are shaped like compiles, so siso include-scans them, caches them in the RBE action cache and executes misses remotely. Off Linux they run through clang_remote_wrapper with the Linux clang and clang-tidy, like the clang rules.

The rule only matches the clang_tidy action, so ordinary builds are unaffected.
electron/build-tools#896 carries the electron/clang-tidy rule, so bump the build-tools pin to it and drop the in-repo copy of build-tools' main.star and the ELECTRON_BUILD_TOOLS_MAIN_STAR override. The pin bump also picks up electron/build-tools#895 (retry the initial depot_tools clone).
Both clang-tidy entry points passed their own --header-filter. Set HeaderFilterRegex in .clang-tidy instead so they can't diverge. This clang-tidy reports header diagnostics when no filter is set, so the flags and the config change together.
The steps are only right if compile_commands.json matches the out dir, so the generator now regenerates it instead of trusting an old one. Also say that the generator and the wrapper are CI plumbing, and what a local run needs.
@MarshallOfSound

Copy link
Copy Markdown
Member Author

if a future PR adds a .clang-tidy config in a subdirectory it won't be picked up

Yeah, this was a real hole. A config under electron/shell would apply locally, but it never reached the worker, and it wasn't in the cache key. electron/build-tools#897 globs electron/shell for .clang-tidy files and adds them to the rule's inputs. I tested it with a throwaway electron/shell/app/.clang-tidy. With the current rule the step passes on the worker, and with electron/build-tools#897 it fails. We only need electron/shell, because every TU we check lives there and clang-tidy searches upward from the source file.

I think we should add some comments to make it clear these scripts aren't meant to be run locally

Added in ad5cae9. Most of the ordering footgun was a stale compile_commands.json, so the generator now runs gn gen itself. I didn't add a CI guard. The only other prerequisite is the generated headers, and yarn lint:clang-tidy has the same one. Happy to add the guard if you still want it.

Picks up electron/build-tools#897, which sends any .clang-tidy under electron/shell to the RBE worker and into the cache key.
@MarshallOfSound MarshallOfSound added target/42-x-y PR should also be added to the "42-x-y" branch. target/43-x-y PR should also be added to the "43-x-y" branch. target/44-x-y PR should also be added to the "44-x-y" branch. target/45-x-y PR should also be added to the "45-x-y" branch. labels Sep 4, 2026
@MarshallOfSound
MarshallOfSound enabled auto-merge (squash) September 4, 2026 23:56
@trop

trop Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "44-x-y", please check out #53568

@trop

trop Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "43-x-y", please check out #53569

@trop

trop Bot commented Sep 5, 2026

Copy link
Copy Markdown
Contributor

@MarshallOfSound has manually backported this PR to "42-x-y", please check out #53570

codebytere pushed a commit that referenced this pull request Sep 5, 2026
)

GN writes "/Fo{{output}}" to compile_commands.json with a space before the
substituted path; Chromium's Windows toolchain used that form until 155
switched to "/Fo$output". gen-clang-tidy-ninja.py only handled the
joined form, so with the spaced one every clang-cl entry parsed to an
empty object path, every step got the output ".tidy", and siso rejected
the file with "multiple rules generates .tidy" (seen on the 42/43/44
backports of #53447). Accept both, and fail with the source file name if
an entry has no object path at all.
codebytere pushed a commit that referenced this pull request Sep 5, 2026
* build: run linux clang-tidy as remotely cached siso build steps (#53447)

* build: run linux clang-tidy as remotely cached siso build steps

Prototype for the linux-x64 leg. Instead of run-clang-tidy.ts walking
shell/ on the runner's own cores, generate one ninja step per translation
unit and let siso treat it like a compile: include-scan the inputs, look
the action up in the RBE cache, and execute misses on the worker pool.

- script/gen-clang-tidy-ninja.py writes out/<dir>/clang_tidy.ninja from
  compile_commands.json: `run-clang-tidy-action.sh <clang++> <flags> -c
  <src> -o <stamp>` per shell/ TU, with a gcc depfile so ninja/siso track
  header deps.
- build/run-clang-tidy-action.sh runs clang-tidy with
  --warnings-as-errors=* (so only clean results are cached), then
  `clang -M` for the depfile, then touches the stamp.
- build/siso/main.star is build-tools' siso entry file plus an
  `electron/clang-tidy` step rule (remote, clang-tidy/.clang-tidy files as
  inputs); the tidy job points ELECTRON_BUILD_TOOLS_MAIN_STAR at it.
- The linux leg of the clang-tidy segment now does `e init --remote-build
  siso`, gn gen with compile commands for //electron:*, generates the
  ninja file and runs `e build -f clang_tidy.ninja electron_clang_tidy`.
  It gets ELECTRON_RBE_JWT for that. mac and win legs are unchanged.

Measured against out/Testing on rbe.notgoma.com: 343 TUs, cold run all
remote in 115 s wall (150 CPU-min of work, bounded by the slowest TU),
fully cached rerun 2.3 s, and a planted finding fails the step with the
diagnostic and is not cached.

* build: tidy up the clang-tidy step generator and wrapper

* build: run macOS and Windows clang-tidy through siso too

- gen-clang-tidy-ninja.py understands clang-cl commands (drops /c, /Fo,
  /Fd, /showIncludes) and emits `deps = msvc` for them, which is also what
  tells siso to parse the command cl-style when scanning for #includes.
- run-clang-tidy-action.sh: for clang-cl, run clang-tidy in cl driver mode
  and report headers via /showIncludes; when the host toolchain isn't
  runnable (macOS binaries on the Linux workers) use the Linux one that
  clang_remote_wrapper stages under Release+Asserts_linux.
- build/siso/main.star: off Linux, run the tidy step through
  clang_remote_wrapper with the Linux clang and clang-tidy as inputs, like
  the clang rules.
- The clang-tidy segment uses the siso path on every platform; on macOS it
  first generates the reclient configs (which fetches the Linux clang) and
  downloads the Linux clang-tidy package next to it.

* build: hand clang-tidy a one-entry compile db so clang-cl keeps a relative source path

clang-tidy appends an absolute source path to `-- <flags>` commands, and on the RBE workers that path starts with /worker, which the cl driver parses as a /w option ('no input files'). A compilation database entry keeps the command as written.

* build: upload siso metrics from the clang-tidy job

* build: install the macOS siso binary in the clang-tidy job

* build: one clang-tidy step per object, not per source file

A source built by several targets (electron_app and the helper app on macOS) has several compile commands with different flags; picking one by source path was order-dependent and cost two cache misses per run. Key steps on the object path instead.

* build: sync build/siso/main.star with the current build-tools pin

* build: use build-tools' clang-tidy siso rule

electron/build-tools#896 carries the electron/clang-tidy rule, so bump the build-tools pin to it and drop the in-repo copy of build-tools' main.star and the ELECTRON_BUILD_TOOLS_MAIN_STAR override. The pin bump also picks up electron/build-tools#895 (retry the initial depot_tools clone).

* build: set clang-tidy's header filter in .clang-tidy

Both clang-tidy entry points passed their own --header-filter. Set HeaderFilterRegex in .clang-tidy instead so they can't diverge. This clang-tidy reports header diagnostics when no filter is set, so the flags and the config change together.

* build: run gn gen from gen-clang-tidy-ninja.py

The steps are only right if compile_commands.json matches the out dir, so the generator now regenerates it instead of trusting an old one. Also say that the generator and the wrapper are CI plumbing, and what a local run needs.

* build: bump build-tools for nested .clang-tidy configs

Picks up electron/build-tools#897, which sends any .clang-tidy under electron/shell to the RBE worker and into the cache key.

(cherry picked from commit 599010d)

* ci: drop the e d banner line when building the cipd ensure file

The build-tools revision this branch now pins prints a
'Running "gclient getdep ..."' line from `e d`, which the old one-liner
folded into the package version and made `cipd ensure` fail with
"bad version". Take only the last line, as main does since #52800.

* build: accept "/Fo obj/x.obj" when reading compile_commands.json

GN writes "/Fo{{output}}" to compile_commands.json with a space before the
substituted path, and Chromium's Windows toolchain used that form until
155 switched to "/Fo$output". gen-clang-tidy-ninja.py only handled the
joined form, so on this branch every clang-cl entry parsed to an empty
object path, every step got the output ".tidy", and siso rejected the
file with "multiple rules generates .tidy".
codebytere pushed a commit that referenced this pull request Sep 5, 2026
* build: run linux clang-tidy as remotely cached siso build steps (#53447)

* build: run linux clang-tidy as remotely cached siso build steps

Prototype for the linux-x64 leg. Instead of run-clang-tidy.ts walking
shell/ on the runner's own cores, generate one ninja step per translation
unit and let siso treat it like a compile: include-scan the inputs, look
the action up in the RBE cache, and execute misses on the worker pool.

- script/gen-clang-tidy-ninja.py writes out/<dir>/clang_tidy.ninja from
  compile_commands.json: `run-clang-tidy-action.sh <clang++> <flags> -c
  <src> -o <stamp>` per shell/ TU, with a gcc depfile so ninja/siso track
  header deps.
- build/run-clang-tidy-action.sh runs clang-tidy with
  --warnings-as-errors=* (so only clean results are cached), then
  `clang -M` for the depfile, then touches the stamp.
- build/siso/main.star is build-tools' siso entry file plus an
  `electron/clang-tidy` step rule (remote, clang-tidy/.clang-tidy files as
  inputs); the tidy job points ELECTRON_BUILD_TOOLS_MAIN_STAR at it.
- The linux leg of the clang-tidy segment now does `e init --remote-build
  siso`, gn gen with compile commands for //electron:*, generates the
  ninja file and runs `e build -f clang_tidy.ninja electron_clang_tidy`.
  It gets ELECTRON_RBE_JWT for that. mac and win legs are unchanged.

Measured against out/Testing on rbe.notgoma.com: 343 TUs, cold run all
remote in 115 s wall (150 CPU-min of work, bounded by the slowest TU),
fully cached rerun 2.3 s, and a planted finding fails the step with the
diagnostic and is not cached.

* build: tidy up the clang-tidy step generator and wrapper

* build: run macOS and Windows clang-tidy through siso too

- gen-clang-tidy-ninja.py understands clang-cl commands (drops /c, /Fo,
  /Fd, /showIncludes) and emits `deps = msvc` for them, which is also what
  tells siso to parse the command cl-style when scanning for #includes.
- run-clang-tidy-action.sh: for clang-cl, run clang-tidy in cl driver mode
  and report headers via /showIncludes; when the host toolchain isn't
  runnable (macOS binaries on the Linux workers) use the Linux one that
  clang_remote_wrapper stages under Release+Asserts_linux.
- build/siso/main.star: off Linux, run the tidy step through
  clang_remote_wrapper with the Linux clang and clang-tidy as inputs, like
  the clang rules.
- The clang-tidy segment uses the siso path on every platform; on macOS it
  first generates the reclient configs (which fetches the Linux clang) and
  downloads the Linux clang-tidy package next to it.

* build: hand clang-tidy a one-entry compile db so clang-cl keeps a relative source path

clang-tidy appends an absolute source path to `-- <flags>` commands, and on the RBE workers that path starts with /worker, which the cl driver parses as a /w option ('no input files'). A compilation database entry keeps the command as written.

* build: upload siso metrics from the clang-tidy job

* build: install the macOS siso binary in the clang-tidy job

* build: one clang-tidy step per object, not per source file

A source built by several targets (electron_app and the helper app on macOS) has several compile commands with different flags; picking one by source path was order-dependent and cost two cache misses per run. Key steps on the object path instead.

* build: sync build/siso/main.star with the current build-tools pin

* build: use build-tools' clang-tidy siso rule

electron/build-tools#896 carries the electron/clang-tidy rule, so bump the build-tools pin to it and drop the in-repo copy of build-tools' main.star and the ELECTRON_BUILD_TOOLS_MAIN_STAR override. The pin bump also picks up electron/build-tools#895 (retry the initial depot_tools clone).

* build: set clang-tidy's header filter in .clang-tidy

Both clang-tidy entry points passed their own --header-filter. Set HeaderFilterRegex in .clang-tidy instead so they can't diverge. This clang-tidy reports header diagnostics when no filter is set, so the flags and the config change together.

* build: run gn gen from gen-clang-tidy-ninja.py

The steps are only right if compile_commands.json matches the out dir, so the generator now regenerates it instead of trusting an old one. Also say that the generator and the wrapper are CI plumbing, and what a local run needs.

* build: bump build-tools for nested .clang-tidy configs

Picks up electron/build-tools#897, which sends any .clang-tidy under electron/shell to the RBE worker and into the cache key.

(cherry picked from commit 599010d)

* ci: drop the e d banner line when building the cipd ensure file

The build-tools revision this branch now pins prints a
'Running "gclient getdep ..."' line from `e d`, which the old one-liner
folded into the package version and made `cipd ensure` fail with
"bad version". Take only the last line, as main does since #52800.

* build: accept "/Fo obj/x.obj" when reading compile_commands.json

GN writes "/Fo{{output}}" to compile_commands.json with a space before the
substituted path, and Chromium's Windows toolchain used that form until
155 switched to "/Fo$output". gen-clang-tidy-ninja.py only handled the
joined form, so on this branch every clang-cl entry parsed to an empty
object path, every step got the output ".tidy", and siso rejected the
file with "multiple rules generates .tidy".
codebytere pushed a commit that referenced this pull request Sep 5, 2026
* build: run linux clang-tidy as remotely cached siso build steps (#53447)

* build: run linux clang-tidy as remotely cached siso build steps

Prototype for the linux-x64 leg. Instead of run-clang-tidy.ts walking
shell/ on the runner's own cores, generate one ninja step per translation
unit and let siso treat it like a compile: include-scan the inputs, look
the action up in the RBE cache, and execute misses on the worker pool.

- script/gen-clang-tidy-ninja.py writes out/<dir>/clang_tidy.ninja from
  compile_commands.json: `run-clang-tidy-action.sh <clang++> <flags> -c
  <src> -o <stamp>` per shell/ TU, with a gcc depfile so ninja/siso track
  header deps.
- build/run-clang-tidy-action.sh runs clang-tidy with
  --warnings-as-errors=* (so only clean results are cached), then
  `clang -M` for the depfile, then touches the stamp.
- build/siso/main.star is build-tools' siso entry file plus an
  `electron/clang-tidy` step rule (remote, clang-tidy/.clang-tidy files as
  inputs); the tidy job points ELECTRON_BUILD_TOOLS_MAIN_STAR at it.
- The linux leg of the clang-tidy segment now does `e init --remote-build
  siso`, gn gen with compile commands for //electron:*, generates the
  ninja file and runs `e build -f clang_tidy.ninja electron_clang_tidy`.
  It gets ELECTRON_RBE_JWT for that. mac and win legs are unchanged.

Measured against out/Testing on rbe.notgoma.com: 343 TUs, cold run all
remote in 115 s wall (150 CPU-min of work, bounded by the slowest TU),
fully cached rerun 2.3 s, and a planted finding fails the step with the
diagnostic and is not cached.

* build: tidy up the clang-tidy step generator and wrapper

* build: run macOS and Windows clang-tidy through siso too

- gen-clang-tidy-ninja.py understands clang-cl commands (drops /c, /Fo,
  /Fd, /showIncludes) and emits `deps = msvc` for them, which is also what
  tells siso to parse the command cl-style when scanning for #includes.
- run-clang-tidy-action.sh: for clang-cl, run clang-tidy in cl driver mode
  and report headers via /showIncludes; when the host toolchain isn't
  runnable (macOS binaries on the Linux workers) use the Linux one that
  clang_remote_wrapper stages under Release+Asserts_linux.
- build/siso/main.star: off Linux, run the tidy step through
  clang_remote_wrapper with the Linux clang and clang-tidy as inputs, like
  the clang rules.
- The clang-tidy segment uses the siso path on every platform; on macOS it
  first generates the reclient configs (which fetches the Linux clang) and
  downloads the Linux clang-tidy package next to it.

* build: hand clang-tidy a one-entry compile db so clang-cl keeps a relative source path

clang-tidy appends an absolute source path to `-- <flags>` commands, and on the RBE workers that path starts with /worker, which the cl driver parses as a /w option ('no input files'). A compilation database entry keeps the command as written.

* build: upload siso metrics from the clang-tidy job

* build: install the macOS siso binary in the clang-tidy job

* build: one clang-tidy step per object, not per source file

A source built by several targets (electron_app and the helper app on macOS) has several compile commands with different flags; picking one by source path was order-dependent and cost two cache misses per run. Key steps on the object path instead.

* build: sync build/siso/main.star with the current build-tools pin

* build: use build-tools' clang-tidy siso rule

electron/build-tools#896 carries the electron/clang-tidy rule, so bump the build-tools pin to it and drop the in-repo copy of build-tools' main.star and the ELECTRON_BUILD_TOOLS_MAIN_STAR override. The pin bump also picks up electron/build-tools#895 (retry the initial depot_tools clone).

* build: set clang-tidy's header filter in .clang-tidy

Both clang-tidy entry points passed their own --header-filter. Set HeaderFilterRegex in .clang-tidy instead so they can't diverge. This clang-tidy reports header diagnostics when no filter is set, so the flags and the config change together.

* build: run gn gen from gen-clang-tidy-ninja.py

The steps are only right if compile_commands.json matches the out dir, so the generator now regenerates it instead of trusting an old one. Also say that the generator and the wrapper are CI plumbing, and what a local run needs.

* build: bump build-tools for nested .clang-tidy configs

Picks up electron/build-tools#897, which sends any .clang-tidy under electron/shell to the RBE worker and into the cache key.

(cherry picked from commit 599010d)

* ci: drop the e d banner line when building the cipd ensure file

The build-tools revision this branch now pins prints a
'Running "gclient getdep ..."' line from `e d`, which the old one-liner
folded into the package version and made `cipd ensure` fail with
"bad version". Take only the last line, as main does since #52800.

* build: accept "/Fo obj/x.obj" when reading compile_commands.json

GN writes "/Fo{{output}}" to compile_commands.json with a space before the
substituted path, and Chromium's Windows toolchain used that form until
155 switched to "/Fo$output". gen-clang-tidy-ninja.py only handled the
joined form, so on this branch every clang-cl entry parsed to an empty
object path, every step got the output ".tidy", and siso rejected the
file with "multiple rules generates .tidy".
@trop trop Bot removed the in-flight/42-x-y label Sep 5, 2026
codebytere pushed a commit that referenced this pull request Sep 5, 2026
build: run linux clang-tidy as remotely cached siso build steps (#53447)

* build: run linux clang-tidy as remotely cached siso build steps

Prototype for the linux-x64 leg. Instead of run-clang-tidy.ts walking
shell/ on the runner's own cores, generate one ninja step per translation
unit and let siso treat it like a compile: include-scan the inputs, look
the action up in the RBE cache, and execute misses on the worker pool.

- script/gen-clang-tidy-ninja.py writes out/<dir>/clang_tidy.ninja from
  compile_commands.json: `run-clang-tidy-action.sh <clang++> <flags> -c
  <src> -o <stamp>` per shell/ TU, with a gcc depfile so ninja/siso track
  header deps.
- build/run-clang-tidy-action.sh runs clang-tidy with
  --warnings-as-errors=* (so only clean results are cached), then
  `clang -M` for the depfile, then touches the stamp.
- build/siso/main.star is build-tools' siso entry file plus an
  `electron/clang-tidy` step rule (remote, clang-tidy/.clang-tidy files as
  inputs); the tidy job points ELECTRON_BUILD_TOOLS_MAIN_STAR at it.
- The linux leg of the clang-tidy segment now does `e init --remote-build
  siso`, gn gen with compile commands for //electron:*, generates the
  ninja file and runs `e build -f clang_tidy.ninja electron_clang_tidy`.
  It gets ELECTRON_RBE_JWT for that. mac and win legs are unchanged.

Measured against out/Testing on rbe.notgoma.com: 343 TUs, cold run all
remote in 115 s wall (150 CPU-min of work, bounded by the slowest TU),
fully cached rerun 2.3 s, and a planted finding fails the step with the
diagnostic and is not cached.

* build: tidy up the clang-tidy step generator and wrapper

* build: run macOS and Windows clang-tidy through siso too

- gen-clang-tidy-ninja.py understands clang-cl commands (drops /c, /Fo,
  /Fd, /showIncludes) and emits `deps = msvc` for them, which is also what
  tells siso to parse the command cl-style when scanning for #includes.
- run-clang-tidy-action.sh: for clang-cl, run clang-tidy in cl driver mode
  and report headers via /showIncludes; when the host toolchain isn't
  runnable (macOS binaries on the Linux workers) use the Linux one that
  clang_remote_wrapper stages under Release+Asserts_linux.
- build/siso/main.star: off Linux, run the tidy step through
  clang_remote_wrapper with the Linux clang and clang-tidy as inputs, like
  the clang rules.
- The clang-tidy segment uses the siso path on every platform; on macOS it
  first generates the reclient configs (which fetches the Linux clang) and
  downloads the Linux clang-tidy package next to it.

* build: hand clang-tidy a one-entry compile db so clang-cl keeps a relative source path

clang-tidy appends an absolute source path to `-- <flags>` commands, and on the RBE workers that path starts with /worker, which the cl driver parses as a /w option ('no input files'). A compilation database entry keeps the command as written.

* build: upload siso metrics from the clang-tidy job

* build: install the macOS siso binary in the clang-tidy job

* build: one clang-tidy step per object, not per source file

A source built by several targets (electron_app and the helper app on macOS) has several compile commands with different flags; picking one by source path was order-dependent and cost two cache misses per run. Key steps on the object path instead.

* build: sync build/siso/main.star with the current build-tools pin

* build: use build-tools' clang-tidy siso rule

electron/build-tools#896 carries the electron/clang-tidy rule, so bump the build-tools pin to it and drop the in-repo copy of build-tools' main.star and the ELECTRON_BUILD_TOOLS_MAIN_STAR override. The pin bump also picks up electron/build-tools#895 (retry the initial depot_tools clone).

* build: set clang-tidy's header filter in .clang-tidy

Both clang-tidy entry points passed their own --header-filter. Set HeaderFilterRegex in .clang-tidy instead so they can't diverge. This clang-tidy reports header diagnostics when no filter is set, so the flags and the config change together.

* build: run gn gen from gen-clang-tidy-ninja.py

The steps are only right if compile_commands.json matches the out dir, so the generator now regenerates it instead of trusting an old one. Also say that the generator and the wrapper are CI plumbing, and what a local run needs.

* build: bump build-tools for nested .clang-tidy configs

Picks up electron/build-tools#897, which sends any .clang-tidy under electron/shell to the RBE worker and into the cache key.

(cherry picked from commit 599010d)
@trop trop Bot added merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. and removed in-flight/43-x-y in-flight/44-x-y in-flight/45-x-y labels Sep 5, 2026
claude Bot pushed a commit that referenced this pull request Sep 5, 2026
)

GN writes "/Fo{{output}}" to compile_commands.json with a space before the
substituted path; Chromium's Windows toolchain used that form until 155
switched to "/Fo$output". gen-clang-tidy-ninja.py only handled the
joined form, so with the spaced one every clang-cl entry parsed to an
empty object path, every step got the output ".tidy", and siso rejected
the file with "multiple rules generates .tidy" (seen on the 42/43/44
backports of #53447). Accept both, and fail with the source file name if
an entry has no object path at all.

(cherry picked from commit 2e9208d)
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KsGbFEEncB9pNtHMRTPj5Z
MarshallOfSound pushed a commit that referenced this pull request Sep 5, 2026
)

build: accept "/Fo obj/x.obj" when reading compile_commands.json (#53573)

GN writes "/Fo{{output}}" to compile_commands.json with a space before the
substituted path; Chromium's Windows toolchain used that form until 155
switched to "/Fo$output". gen-clang-tidy-ninja.py only handled the
joined form, so with the spaced one every clang-cl entry parsed to an
empty object path, every step got the output ".tidy", and siso rejected
the file with "multiple rules generates .tidy" (seen on the 42/43/44
backports of #53447). Accept both, and fail with the source file name if
an entry has no object path at all.

(cherry picked from commit 2e9208d)

Claude-Session: https://claude.ai/code/session_01KsGbFEEncB9pNtHMRTPj5Z

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

46-x-y merged/42-x-y PR was merged to the "42-x-y" branch. merged/43-x-y PR was merged to the "43-x-y" branch. merged/44-x-y PR was merged to the "44-x-y" branch. merged/45-x-y PR was merged to the "45-x-y" branch. semver/none

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants