首页 > 解决方案 > bazel 重新编译 protobuf 超出了必要的范围

问题描述

我按照这个例子,它工作正常。

但有时(并非总是)当我更改了一些与 protobuf 和重建完全无关的应用程序级代码时,bazel 会花费所有时间重新编译 protobuf。

有什么建议我可以尝试调试吗?

标签: protocol-buffersbazelprotobuf-c

解决方案


我遇到了同样的问题:protobuf C++ 似乎重新编译了每个构建。构建项目的时间从大约 3 秒缩短到 30 秒。

我正在使用以下命令启动构建:

bazel build -c dbg --config=asan <target>
bazel run -c dbg --config=asan <target>

一旦我删除问题实际上就消失了--config=asan

以下是 asan 的配置方式供参考(行位于文件.bazelrc旁边WORKSPACE

# Address sanitizer
build:asan --strip=never
build:asan --copt -fsanitize=address
build:asan --copt -DADDRESS_SANITIZER
build:asan --copt -DDYNAMIC_ANNOTATIONS_ENABLED=1
build:asan --copt -g
build:asan --copt -fno-omit-frame-pointer
build:asan --copt -fsanitize-address-use-after-scope
build:asan --linkopt -fsanitize=address
build:asan --dynamic_mode=off

推荐阅读