buildbazelbazel-rulesgoogle-benchmark

Google Benchmark: "***WARNING*** Library was built as DEBUG. Timings may be affected."


In ~/install/benchmark, I have checked out Google Benchmark (https://github.com/google/benchmark) and built it in Release mode according to the instructions here.

In ~/personal-projects/benchmarking, I have my own code with a BUILD file and a WORKSPACE file. In the WORKSPACE file, I've got

local_repository(
    name = "com_google_benchmark",
    path = "../../install/benchmark",
)

And in the BUILD file, I have

cc_binary(
    name = "fast_inverse_sqr_root",
    srcs = ["fast_inverse_sqr_root.cpp"],
    deps = [
        "@com_google_benchmark//:benchmark_main",
    ],
)

When I bazel run //fast_inverse_sqr_root, it says: ***WARNING*** Library was built as DEBUG. Timings may be affected.

I've found this related question but that person is using cmake while I'm using Bazel to build my code. I'm not sure what is going on here. Why is it saying the library was built as DEBUG?


Solution

  • Try telling Bazel to compile everything in optimized mode: bazel run -c opt //fast_inverse_sqr_root.