Skip to content

Commit 11e82e9

Browse files
authored
Revert "Add FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION to fuzzer mode and enable DCHECKs under fuzzing (#5489)" (#5580)
This reverts commit 1889ee3. We have identified that this is causing ODR violations, because the `fuzzer` feature is being added `cc_fuzz_test` targets, and thus any includes they make, but not to the rest of the build. Any include that is seen from both places has ODR violations if it branches on FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION. We need to apply fuzzer globally when building fuzz targets somehow, or not set different defines in fuzzer.
1 parent 0b530de commit 11e82e9

File tree

3 files changed

+12
-24
lines changed

3 files changed

+12
-24
lines changed

bazel/cc_toolchains/clang_cc_toolchain_config.bzl

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -661,20 +661,12 @@ def _impl(ctx):
661661

662662
fuzzer = feature(
663663
name = "fuzzer",
664-
flag_sets = [
665-
flag_set(
666-
actions = all_compile_actions + all_link_actions,
667-
flag_groups = [flag_group(flags = [
668-
"-fsanitize=fuzzer-no-link",
669-
])],
670-
),
671-
flag_set(
672-
actions = all_compile_actions,
673-
flag_groups = [flag_group(flags = [
674-
"-DFUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION",
675-
])],
676-
),
677-
],
664+
flag_sets = [flag_set(
665+
actions = all_compile_actions + all_link_actions,
666+
flag_groups = [flag_group(flags = [
667+
"-fsanitize=fuzzer-no-link",
668+
])],
669+
)],
678670
)
679671

680672
# Clang HARDENED_MODE has 4 possible values:

common/check.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,8 @@ namespace Carbon {
2424
CARBON_INTERNAL_CHECK_CONDITION(condition) \
2525
? (void)0 : CARBON_INTERNAL_CHECK(condition __VA_OPT__(, ) __VA_ARGS__)
2626

27-
// DCHECK calls CHECK in debug or fuzzing mode, and does nothing otherwise.
28-
//
29-
// Note FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION is a standard define coming
30-
// from LibFuzzer: https://llvm.org/docs/LibFuzzer.html
31-
#if !defined(NDEBUG) || defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)
27+
// DCHECK calls CHECK in debug mode, and does nothing otherwise.
28+
#ifndef NDEBUG
3229
#define CARBON_DCHECK(condition, ...) \
3330
CARBON_CHECK(condition __VA_OPT__(, ) __VA_ARGS__)
3431
#else

common/raw_hashtable_metadata_group.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -480,12 +480,11 @@ class MetadataGroup : public Printable<MetadataGroup> {
480480
friend class BenchmarkSimdMetadataGroup;
481481

482482
// All SIMD variants that we have an implementation for should be enabled for
483-
// debugging and fuzzing. This lets us maintain a SIMD implementation even if
484-
// it is not used due to performance reasons, and easily re-enable it if the
485-
// performance changes.
483+
// debugging. This lets us maintain a SIMD implementation even if it is not
484+
// used due to performance reasons, and easily re-enable it if the performance
485+
// changes.
486486
static constexpr bool DebugSimd =
487-
#if (!defined(NDEBUG) || defined(FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION)) && \
488-
(CARBON_NEON_SIMD_SUPPORT || CARBON_X86_SIMD_SUPPORT)
487+
#if !defined(NDEBUG) && (CARBON_NEON_SIMD_SUPPORT || CARBON_X86_SIMD_SUPPORT)
489488
true;
490489
#else
491490
false;

0 commit comments

Comments
 (0)