Support alternate solution for bazel based C++ builds
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 需要澄清
- 活跃度
- 冷清
- 技术栈
- cpp
- 领域
- build-system
调研方向
先从链接的 CodeQL 文档和现有的 Bazel 工作流开始,然后确定 CLI 在创建数据库期间需要哪些构建信息。比较提议的 compile_commands.json、clang indexstore、Kythe 和 scip-clang 方案,包括远程执行和缓存方面的限制。当定义了一个受支持的替代方案,并且其文档和验证要求明确后,即可视为完成。
由索引模型根据 Issue 内容生成。
描述
Currently the codeql documentation contains this example for use with bazel based projects:
# Navigate to the Bazel workspace.
# Before building, remove cached objects
# and stop all running Bazel server processes.
bazel clean --expunge
# Build using the following Bazel flags, to help CodeQL detect the build:
# `--spawn_strategy=local`: build locally, instead of using a distributed build
# `--nouse_action_cache`: turn off build caching, which might prevent recompilation of source code
# `--noremote_accept_cached`, `--noremote_upload_local_results`: avoid using a remote cache
# `--disk_cache=`: avoid using a disk cache. Note that a disk cache is no longer considered a remote cache as of Bazel 6.
codeql database create new-database --language=<language> \
--command='bazel build --spawn_strategy=local --nouse_action_cache --noremote_accept_cached --noremote_upload_local_results --disk_cache= //path/to/package:target'
# After building, stop all running Bazel server processes.
# This ensures future build commands start in a clean Bazel server process
# without CodeQL attached.
bazel shutdown
The gist of this is that you must start from scratch and build the whole project on the local machine without any caching. For many projects that moved to bazel moving away from this model was one of the core motivations. For large builds that rely on caching / remote execution, it may no longer be feasible to run the entire build on 1 machine, even if it's only on a scheduled cadence. Moreover the user might not even host the infrastructure to do this anymore, as all of their actual developer and CI builds go through remote execution.
It would be great if there was another way to communicate the necessary information to codeql, in a way that could work alongside bazel's model.
I can't tell from the documentation what the codeql CLI is actually pulling from the build, and I imagine it's quite in depth, but I assume there are other models that could work for providing the same information for certain types of builds.
For example for C++ some natural alternatives (from the user perspective) would be to:
- produce a compile_commands.json, which is also used in many other developer workflows like C++ LSPs
- produce a clang indexstore, which can be used as a query-able database for the project
- produce a kythe index
- produce a scip-clang index
Each of these options would work better in the bazel model, since indexes could be produced remotely, and cached, and compile_commands.json should already be supported for developer workflows.
related:
- 主要语言
- CodeQL
- 星标
- 10.1k
- 派生
- 2.1k
- 平均合并
- 2 天 10 小时
- 30 天内合并 PR
- 134
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
github/codeql 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 84/100
-
难度 2/5 1-3 小时 新手友好度 82/100
-
难度 2/5 1-3 小时 新手友好度 78/100
-
false-positive
难度 2/5 1-3 小时 新手友好度 70/100
-
false-positive
难度 3/5 1-2 天 新手友好度 68/100
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 70/100
conda-forge/nccl-feedstock#166 ·
-
难度 2/5 1-3 小时 新手友好度 82/100
dsx-ai-factory/infra-controller#6694 ·
-
bug build
难度 2/5 1-3 小时 新手友好度 88/100
facebookincubator/velox#19143 ·
-
难度 2/5 1-3 小时 新手友好度 88/100
pydantic/pydantic-ai#8636 ·
-
0.kind: enhancement 9.needs: package (update)
难度 2/5 1-3 小时 新手友好度 74/100