Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 23 additions & 46 deletions third_party/libFuzzer/BUILD.gn
Original file line number Diff line number Diff line change
@@ -1,41 +1,28 @@
# Copyright 2016 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# Copyright 2022 The GPGMM Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("///build/config/sanitizers/sanitizers.gni")

config("warnings") {
config("libfuzzer_flags") {
if (is_clang) {
cflags = [
"-Wno-shadow",

# See crbug.com/932188, libFuzzer does not check the result of write()
# when it does raw printing.
"-Wno-unused-result",
]
}
}

# Engine should be compiled without coverage (infinite loop in trace_cmp).
fuzzing_engine_remove_configs = [
"//build/config/coverage:default_coverage",
"//build/config/sanitizers:default_sanitizer_flags",
]

# Add any sanitizer flags back. In MSAN builds, instrumenting libfuzzer with
# MSAN is necessary since all parts of the binary need to be instrumented for it
# to work. ASAN builds are more subtle: libfuzzer depends on features from the
# C++ STL. If it were not instrumented, templates would be insantiated without
# ASAN from libfuzzer and with ASAN in other TUs. The linker might merge
# instrumented template instantiations with non-instrumented ones (which could
# have a different ABI) in the final binary, which is problematic for TUs
# expecting one particular ABI (https://crbug.com/915422). The other sanitizers
# are added back for the same reason.
fuzzing_engine_add_configs = [
"//build/config/sanitizers:default_sanitizer_flags_but_coverage",
":warnings",
]

source_set("libfuzzer") {
sources = [
"src/FuzzerCrossOver.cpp",
Expand All @@ -50,6 +37,7 @@ source_set("libfuzzer") {
"src/FuzzerIOPosix.cpp",
"src/FuzzerIOWindows.cpp",
"src/FuzzerLoop.cpp",
"src/FuzzerMain.cpp",
"src/FuzzerMerge.cpp",
"src/FuzzerMutate.cpp",
"src/FuzzerSHA1.cpp",
Expand All @@ -62,24 +50,13 @@ source_set("libfuzzer") {
"src/FuzzerUtilWindows.cpp",
]

if (!is_ios) {
sources += [ "src/FuzzerMain.cpp" ]
}

configs -= fuzzing_engine_remove_configs
configs += fuzzing_engine_add_configs

deps = []
if (is_fuchsia) {
deps += [ "//third_party/fuchsia-sdk/sdk:fdio" ]
}
}

if (use_afl) {
source_set("afl_driver") {
sources = [ "src/afl/afl_driver.cpp" ]
configs -= [
"//build/config/coverage:default_coverage",
"//build/config/sanitizers:default_sanitizer_flags",
]

configs -= fuzzing_engine_remove_configs
configs += fuzzing_engine_add_configs
}
configs += [
"//build/config/sanitizers:default_sanitizer_flags_but_coverage",
":libfuzzer_flags",
]
}