-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[bazel] Use includes
instead of strip_include_prefix
#1803
[bazel] Use includes
instead of strip_include_prefix
#1803
Conversation
google/benchmark#1803 ``` In file included from test/fixed_map_perf_test.cpp:4: bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:1801:25: error: zero as null pointer constant [-Werror,-Wzero-as-null-pointer-constant] 1801 | memory_result(NULL), | ^~~~ | nullptr /usr/lib/llvm-17/lib/clang/17/include/stddef.h:84:18: note: expanded from macro 'NULL' 84 | # define NULL __null | ^ In file included from test/fixed_map_perf_test.cpp:4: bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:378:7: error: 'MemoryManager' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Werror,-Wweak-vtables] 378 | class MemoryManager { | ^ bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:1437:7: error: 'Fixture' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Werror,-Wweak-vtables] 1437 | class Fixture : public internal::Benchmark { | ^ 3 errors generated. ```
google/benchmark#1803 ``` In file included from test/fixed_map_perf_test.cpp:4: bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:1801:25: error: zero as null pointer constant [-Werror,-Wzero-as-null-pointer-constant] 1801 | memory_result(NULL), | ^~~~ | nullptr /usr/lib/llvm-17/lib/clang/17/include/stddef.h:84:18: note: expanded from macro 'NULL' 84 | # define NULL __null | ^ In file included from test/fixed_map_perf_test.cpp:4: bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:378:7: error: 'MemoryManager' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Werror,-Wweak-vtables] 378 | class MemoryManager { | ^ bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:1437:7: error: 'Fixture' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Werror,-Wweak-vtables] 1437 | class Fixture : public internal::Benchmark { | ^ 3 errors generated. ```
i had originally decided to not use thanks so much :) |
looks like precommit has an opinion about ordering of fields. |
When using `includes`, consumers will apply the headers using `-isystem`, instead of `-I`. This will allow diagnostics of consumers to not apply to `benchmark`. More info: https://bazel.build/reference/be/c-cpp#cc_library.includes https://bazel.build/reference/be/c-cpp#cc_library.strip_include_prefix gtest uses `includes` as well: https://github.com/google/googletest/blob/1d17ea141d2c11b8917d2c7d029f1c4e2b9769b2/BUILD.bazel#L120
a53f931
to
4af61d1
Compare
Fixed and verified locally:
|
unrelated failure. thank you for the fix. |
google/benchmark#1803 ``` In file included from test/fixed_map_perf_test.cpp:4: bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:1801:25: error: zero as null pointer constant [-Werror,-Wzero-as-null-pointer-constant] 1801 | memory_result(NULL), | ^~~~ | nullptr /usr/lib/llvm-17/lib/clang/17/include/stddef.h:84:18: note: expanded from macro 'NULL' 84 | # define NULL __null | ^ In file included from test/fixed_map_perf_test.cpp:4: bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:378:7: error: 'MemoryManager' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Werror,-Wweak-vtables] 378 | class MemoryManager { | ^ bazel-out/k8-fastbuild/bin/external/com_google_benchmark/_virtual_includes/benchmark_main/benchmark/benchmark.h:1437:7: error: 'Fixture' has no out-of-line virtual method definitions; its vtable will be emitted in every translation unit [-Werror,-Wweak-vtables] 1437 | class Fixture : public internal::Benchmark { | ^ 3 errors generated. ```
When using
includes
, consumers will apply the headers using-isystem
, instead of-I
. This will allow diagnostics of consumers to not apply tobenchmark
.More info:
https://bazel.build/reference/be/c-cpp#cc_library.includes
https://bazel.build/reference/be/c-cpp#cc_library.strip_include_prefix
gtest uses
includes
as well:https://github.com/google/googletest/blob/1d17ea141d2c11b8917d2c7d029f1c4e2b9769b2/BUILD.bazel#L120