BUILD.gn 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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. group("afl") {
  5. deps = [
  6. ":afl-cmin",
  7. ":afl-fuzz",
  8. ":afl-showmap",
  9. ":afl-tmin",
  10. ":afl_docs",
  11. ":afl_runtime",
  12. ]
  13. }
  14. source_set("afl_runtime") {
  15. # AFL needs this flag to be built with -Werror. This is because it uses u8*
  16. # and char* types interchangeably in its source code. The AFL Makefiles use
  17. # this flag.
  18. cflags = [ "-Wno-pointer-sign" ]
  19. configs -= [
  20. # These functions should not be compiled with sanitizers since they
  21. # are used by the sanitizers.
  22. "//build/config/sanitizers:default_sanitizer_flags",
  23. # Every function in this library should have "default" visibility.
  24. # Thus we turn off flags which make visibility "hidden" for functions
  25. # that do not specify visibility.
  26. # The functions in this library will not conflict with others elsewhere
  27. # because they begin with a double underscore and/or are static.
  28. "//build/config/gcc:symbol_visibility_hidden",
  29. ]
  30. sources = [ "src/llvm_mode/afl-llvm-rt.o.c" ]
  31. }
  32. afl_headers = [
  33. "src/alloc-inl.h",
  34. "src/config.h",
  35. "src/debug.h",
  36. "src/types.h",
  37. "src/hash.h",
  38. ]
  39. config("afl-tool") {
  40. cflags = [
  41. # Include flags from afl's Makefile.
  42. "-O3",
  43. "-funroll-loops",
  44. "-D_FORTIFY_SOURCE=2",
  45. # These flags are necessary to build with -Werror.
  46. "-Wno-sign-compare",
  47. "-Wno-pointer-sign",
  48. # afl_docs copies docs/ to this location.
  49. "-DDOC_PATH=\"$root_build_dir/afl/docs/\"",
  50. # This flag is needed for compilation but is only used for QEMU mode which
  51. # we do not use. Therefore its value is unimportant.
  52. "-DBIN_PATH=\"$root_build_dir\"",
  53. ]
  54. }
  55. copy("afl-cmin") {
  56. # afl-cmin is a bash script used to minimize the corpus, therefore we can just
  57. # copy it over.
  58. sources = [ "src/afl-cmin" ]
  59. outputs = [ "$root_build_dir/{{source_file_part}}" ]
  60. deps = [ ":afl-showmap" ]
  61. }
  62. copy("afl_docs") {
  63. # Copy the docs folder. This is so that we can use a real value for for
  64. # -DDOC_PATH when compiling.
  65. sources = [ "src/docs" ]
  66. outputs = [ "$root_build_dir/afl/{{source_file_part}}" ]
  67. }
  68. executable("afl-fuzz") {
  69. # Used to fuzz programs.
  70. configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
  71. configs += [ ":afl-tool" ]
  72. no_default_deps = true
  73. sources = [ "src/afl-fuzz.c" ]
  74. sources += afl_headers
  75. }
  76. executable("afl-tmin") {
  77. configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
  78. configs += [ ":afl-tool" ]
  79. no_default_deps = true
  80. sources = [ "src/afl-tmin.c" ]
  81. sources += afl_headers
  82. }
  83. executable("afl-showmap") {
  84. configs -= [ "//build/config/sanitizers:default_sanitizer_flags" ]
  85. configs += [ ":afl-tool" ]
  86. no_default_deps = true
  87. sources = [ "src/afl-showmap.c" ]
  88. sources += afl_headers
  89. }