BUILD.gn 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # Copyright 2016 The Chromium Authors. All rights reserved.
  2. # Use of this source code is governed by a BSD-style license that can be
  3. # found in the LICENSE file.
  4. import("///build/config/sanitizers/sanitizers.gni")
  5. config("warnings") {
  6. if (is_clang) {
  7. cflags = [
  8. "-Wno-shadow",
  9. # See crbug.com/932188, libFuzzer does not check the result of write()
  10. # when it does raw printing.
  11. "-Wno-unused-result",
  12. ]
  13. }
  14. }
  15. # Engine should be compiled without coverage (infinite loop in trace_cmp).
  16. fuzzing_engine_remove_configs = [
  17. "//build/config/coverage:default_coverage",
  18. "//build/config/sanitizers:default_sanitizer_flags",
  19. ]
  20. # Add any sanitizer flags back. In MSAN builds, instrumenting libfuzzer with
  21. # MSAN is necessary since all parts of the binary need to be instrumented for it
  22. # to work. ASAN builds are more subtle: libfuzzer depends on features from the
  23. # C++ STL. If it were not instrumented, templates would be insantiated without
  24. # ASAN from libfuzzer and with ASAN in other TUs. The linker might merge
  25. # instrumented template instantiations with non-instrumented ones (which could
  26. # have a different ABI) in the final binary, which is problematic for TUs
  27. # expecting one particular ABI (https://crbug.com/915422). The other sanitizers
  28. # are added back for the same reason.
  29. fuzzing_engine_add_configs = [
  30. "//build/config/sanitizers:default_sanitizer_flags_but_coverage",
  31. ":warnings",
  32. ]
  33. source_set("libfuzzer") {
  34. sources = [
  35. "src/FuzzerCrossOver.cpp",
  36. "src/FuzzerDataFlowTrace.cpp",
  37. "src/FuzzerDriver.cpp",
  38. "src/FuzzerExtFunctionsDlsym.cpp",
  39. "src/FuzzerExtFunctionsWeak.cpp",
  40. "src/FuzzerExtFunctionsWindows.cpp",
  41. "src/FuzzerExtraCounters.cpp",
  42. "src/FuzzerFork.cpp",
  43. "src/FuzzerIO.cpp",
  44. "src/FuzzerIOPosix.cpp",
  45. "src/FuzzerIOWindows.cpp",
  46. "src/FuzzerLoop.cpp",
  47. "src/FuzzerMerge.cpp",
  48. "src/FuzzerMutate.cpp",
  49. "src/FuzzerSHA1.cpp",
  50. "src/FuzzerTracePC.cpp",
  51. "src/FuzzerUtil.cpp",
  52. "src/FuzzerUtilDarwin.cpp",
  53. "src/FuzzerUtilFuchsia.cpp",
  54. "src/FuzzerUtilLinux.cpp",
  55. "src/FuzzerUtilPosix.cpp",
  56. "src/FuzzerUtilWindows.cpp",
  57. ]
  58. if (!is_ios) {
  59. sources += [ "src/FuzzerMain.cpp" ]
  60. }
  61. configs -= fuzzing_engine_remove_configs
  62. configs += fuzzing_engine_add_configs
  63. deps = []
  64. if (is_fuchsia) {
  65. deps += [ "//third_party/fuchsia-sdk/sdk:fdio" ]
  66. }
  67. }
  68. if (use_afl) {
  69. source_set("afl_driver") {
  70. sources = [ "src/afl/afl_driver.cpp" ]
  71. configs -= fuzzing_engine_remove_configs
  72. configs += fuzzing_engine_add_configs
  73. }
  74. }