I had the same problem: protobuf C++ seemed to recompile each build. Time to build the project went from ~3s to 30s.
I was launching the build with following command:
bazel build -c dbg --config=asan <target>
bazel run -c dbg --config=asan <target>
And problem actually went away once I've removed --config=asan
For reference here is how asan is configured (lines are located in .bazelrc
right next to WORKSPACE
file:
# 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