Skip to content

Commit

Permalink
x
Browse files Browse the repository at this point in the history
  • Loading branch information
ctiller committed Jan 27, 2025
1 parent b4e9cc5 commit 1052731
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 15 deletions.
6 changes: 3 additions & 3 deletions bazel/grpc_deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ def grpc_deps():
# bazel run @com_google_fuzztest//bazel:setup_configs > tools/fuzztest.bazelrc
http_archive(
name = "com_google_fuzztest",
sha256 = "cdf8d8cd3cdc77280a7c59b310edf234e489a96b6e727cb271e7dfbeb9bcca8d",
strip_prefix = "fuzztest-4ecaeb5084a061a862af8f86789ee184cd3d3f18",
sha256 = "c31d122e8b06d1e9cf1edb59d7c6a66ed232101fb9074ad6b74d6282a5768a32",
strip_prefix = "fuzztest-b1d0067a853ff9320d7abe5b2761201b586f66dc",
urls = [
# 2023-05-16
"https://github.com/google/fuzztest/archive/4ecaeb5084a061a862af8f86789ee184cd3d3f18.tar.gz",
"https://github.com/google/fuzztest/archive/b1d0067a853ff9320d7abe5b2761201b586f66dc.tar.gz",
],
)

Expand Down
4 changes: 4 additions & 0 deletions tools/bazel.rc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ common --incompatible_disallow_struct_provider_syntax=false
# for platform-appropriate cxxopts
common --enable_platform_specific_config

# avoid riegeli use for gRPC: fuzztest wants to use it by default, but we don't need
# it in any open source build.
common --@com_google_fuzztest//fuzztest:use_riegeli=false

build:windows --cxxopt='/std:c++17'
build:windows --host_cxxopt='/std:c++17'
build:linux --cxxopt='-std=c++17'
Expand Down
61 changes: 49 additions & 12 deletions tools/fuzztest.bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,11 @@
#
# try-import %workspace%/fuzztest.bazelrc


### Common options.
#
# Do not use directly.

# Compile and link with Address Sanitizer (ASAN).
build:fuzztest-common --linkopt=-fsanitize=address
build:fuzztest-common --copt=-fsanitize=address

# Standard define for "ifdef-ing" any fuzz test specific code.
# Standard define for \"ifdef-ing\" any fuzz test specific code.
build:fuzztest-common --copt=-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION

# In fuzz tests, we want to catch assertion violations even in optimized builds.
Expand All @@ -27,22 +22,64 @@ build:fuzztest-common --copt=-UNDEBUG
# See https://libcxx.llvm.org/UsingLibcxx.html#enabling-the-safe-libc-mode
build:fuzztest-common --copt=-D_LIBCPP_ENABLE_ASSERTIONS=1

### ASan (Address Sanitizer) build configuration.
#
# Use with: --config=asan

build:asan --linkopt=-fsanitize=address
build:asan --copt=-fsanitize=address

# We rely on the following flag instead of the compiler provided
# __has_feature(address_sanitizer) to know that we have an ASAN build even in
# the uninstrumented runtime.
build:asan --copt=-DADDRESS_SANITIZER

### FuzzTest build configuration.
#
# Use with: --config=fuzztest
#
# Note that this configuration includes the ASan configuration.

build:fuzztest --config=asan
build:fuzztest --config=fuzztest-common

# Link statically.
build:fuzztest --dynamic_mode=off

# We rely on the following flag instead of the compiler provided
# __has_feature(address_sanitizer) to know that we have an ASAN build even in
# the uninstrumented runtime.
build:fuzztest --copt=-DADDRESS_SANITIZER
# We apply coverage tracking instrumentation to everything but Centipede and the
# FuzzTest framework itself (including GoogleTest and GoogleMock).
build:fuzztest --copt=-fsanitize-coverage=inline-8bit-counters,trace-cmp,pc-table
build:fuzztest --per_file_copt=common/.*,fuzztest/.*,centipede/.*,-centipede/.*fuzz_target,googletest/.*,googlemock/.*@-fsanitize-coverage=0

### Experimental FuzzTest build configuration.
#
# Use with: --config=fuzztest-experimental
#
# Use this instead of --config=fuzztest when building test binaries to run with
# Centipede. Eventually, this will be consolidated with --config=fuzztest.
# Note that this configuration doesn't include the ASan configuration. If you
# want to use both, you can use --config=fuzztest-experimental --config=asan.

build:fuzztest-experimental --config=fuzztest-common
build:fuzztest-experimental --@com_google_fuzztest//fuzztest:centipede_integration

# Generate line tables for debugging.
build:fuzztest-experimental --copt=-gline-tables-only
build:fuzztest-experimental --strip=never

# Prevent memcmp & co from being inlined.
build:fuzztest-experimental --copt=-fno-builtin

# Disable heap checking.
build:fuzztest-experimental --copt=-DHEAPCHECK_DISABLE

# Link statically.
build:fuzztest-experimental --dynamic_mode=off

# We apply coverage tracking instrumentation to everything but the
# We apply coverage tracking instrumentation to everything but Centipede and the
# FuzzTest framework itself (including GoogleTest and GoogleMock).
build:fuzztest --per_file_copt=+//,-fuzztest/.*,-googletest/.*,-googlemock/.*@-fsanitize-coverage=inline-8bit-counters,-fsanitize-coverage=trace-cmp
# TODO(b/374840534): Add -fsanitize-coverage=control-flow once we start building
# with clang 16+.
build:fuzztest-experimental --copt=-fsanitize-coverage=trace-pc-guard,pc-table,trace-loads,trace-cmp
build:fuzztest-experimental --per_file_copt=common/.*,fuzztest/.*,centipede/.*,-centipede/.*fuzz_target,googletest/.*,googlemock/.*@-fsanitize-coverage=0

0 comments on commit 1052731

Please sign in to comment.