Precompile bits/stdc++.h in the runner, and move it to clang-tidy 22
The first publish failed its smoke test: on the production host (2 slow cores) clang-tidy took over 30s on a two-line file and hit the runner's 20s lint limit, and even a trivial build took 4s, nearly all of it parsing <bits/stdc++.h>. The runner image now precompiles that header for g++ (.gch) and clang (.pch) with the flags the runner passes, and the runner uses them when they are there. g++ lint gains -O2 so the build's header matches it. Alpine 3.24's clang-tidy 22 walks far less of the system headers than 3.22's clang-tidy 20. Measured on the host: a build 3.9s to 0.6s, and clang-tidy 32.5s to 4.3s. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
@@ -128,12 +128,14 @@ func runTool(ctx context.Context, ws *workspace, name string, args []string, std
|
||||
// not GCC's JSON: GCC 16 dropped -fdiagnostics-format=json for SARIF,
|
||||
// while the image's GCC 14 has both, and the one-line-per-diagnostic text
|
||||
// is the same on every version. Byte columns, so a tab counts as one
|
||||
// column as it does in the editor.
|
||||
// column as it does in the editor. -O2 as in the build: the precompiled
|
||||
// header only matches the same optimization level, and some warnings
|
||||
// (maybe-uninitialized) only come with it.
|
||||
func lintGCC(ctx context.Context, ws *workspace) []Diagnostic {
|
||||
out := runTool(ctx, ws, "g++", []string{
|
||||
out := runTool(ctx, ws, "g++", withGCCPCH([]string{
|
||||
"g++", "-fsyntax-only", "-fdiagnostics-plain-output", "-fdiagnostics-column-unit=byte",
|
||||
"-std=c++17", "-Wall", "-Wextra", "-DLOCAL", "-I.", "main.cpp",
|
||||
}, "")
|
||||
"-O2", "-std=c++17", "-Wall", "-Wextra", "-DLOCAL", "-I.", "main.cpp",
|
||||
}), "")
|
||||
return parseGCC(out)
|
||||
}
|
||||
|
||||
@@ -185,10 +187,10 @@ func parseGCC(out string) []Diagnostic {
|
||||
// lintTidy runs clang-tidy with the embedded checks. clang-tidy only
|
||||
// reports on the main file unless told otherwise, so headers are quiet.
|
||||
func lintTidy(ctx context.Context, ws *workspace) []Diagnostic {
|
||||
out := runTool(ctx, ws, "clang-tidy", []string{
|
||||
out := runTool(ctx, ws, "clang-tidy", append([]string{
|
||||
"clang-tidy", "main.cpp", "--quiet", "--config=" + tidyConfig,
|
||||
"--", "-std=c++17", "-DLOCAL", "-I.",
|
||||
}, "")
|
||||
}, tidyPCH()...), "")
|
||||
main := filepath.Join(ws.work, "main.cpp")
|
||||
paths := map[string]bool{"main.cpp": true, main: true}
|
||||
if real, err := filepath.EvalSymlinks(main); err == nil {
|
||||
|
||||
Reference in New Issue
Block a user