Bug 1316274 - Fuzzing mode: Move fuzz/ to GYP, remove Makefiles and manifests r=franziskus
authorTim Taubert <ttaubert@mozilla.com>
Fri, 11 Nov 2016 16:00:39 +0100
changeset 12833 4c34f083d93d7c515e30ff514710f48c7844af65
parent 12832 d423162c2f1498f68a7422c2ca7a0d4589d2cfb1
child 12834 0d5d0574e512693c3c31e34ee9f194272e0a8516
push id1760
push userttaubert@mozilla.com
push dateFri, 11 Nov 2016 15:35:52 +0000
reviewersfranziskus
bugs1316274
Bug 1316274 - Fuzzing mode: Move fuzz/ to GYP, remove Makefiles and manifests r=franziskus Differential Revision: https://nss-review.dev.mozaws.net/D52 * * * fixup From ab8763469977a338a61d610ed69ef045244630f3 Mon Sep 17 00:00:00 2001
build.sh
fuzz/Makefile
fuzz/cert_target.cc
fuzz/clone_libfuzzer.sh
fuzz/common.mk
fuzz/fuzz.gyp
fuzz/libFuzzer/Makefile
fuzz/libFuzzer/config.mk
fuzz/libFuzzer/libFuzzer.gyp
fuzz/libFuzzer/manifest.mn
fuzz/manifest.mn
fuzz/nssfuzz.cc
fuzz/nssfuzz/Makefile
fuzz/nssfuzz/cert_target.cc
fuzz/nssfuzz/manifest.mn
fuzz/nssfuzz/nssfuzz.cc
fuzz/nssfuzz/pkcs8_target.cc
fuzz/nssfuzz/registry.h
fuzz/nssfuzz/shared.h
fuzz/nssfuzz/spki_target.cc
fuzz/pkcs8_target.cc
fuzz/registry.h
fuzz/shared.h
fuzz/spki_target.cc
manifest.mn
nss.gyp
--- a/build.sh
+++ b/build.sh
@@ -80,29 +80,33 @@ check_sanitizer()
 enable_fuzz()
 {
     nspr_sanitizer asan
     nspr_sanitizer ubsan
     nspr_sanitizer sancov edge
     gyp_params+=(-Duse_asan=1)
     gyp_params+=(-Duse_ubsan=1)
     gyp_params+=(-Duse_sancov=edge)
+
     # Adding debug symbols even for opt builds.
     nspr_opt+=(--enable-debug-symbols)
+
+    # Clone libFuzzer repository.
+    $cwd/fuzz/clone_libfuzzer.sh &>/dev/null
 }
 
 # parse command line arguments
 while [ $# -gt 0 ]; do
     case $1 in
         -c) clean=1 ;;
         -g) rebuild_gyp=1 ;;
         -j) ninja_params+=(-j "$2"); shift ;;
         -v) ninja_params+=(-v) ;;
         --test) gyp_params+=(-Dtest_build=1) ;;
-        --fuzz) gyp_params+=(-Dtest_build=1 -Dfuzz=1); check_sanitizer; enable_fuzz ;;
+        --fuzz) gyp_params+=(-Dtest_build=1 -Dfuzz=1); enable_fuzz ;;
         --scan-build) scanbuild=(scan-build) ;;
         --scan-build=?*) scanbuild=(scan-build -o "${1#*=}") ;;
         --opt|-o) opt_build=1 ;;
         -m32|--m32) build_64=0 ;;
         --asan) gyp_params+=(-Duse_asan=1); nspr_sanitizer asan ;;
         --ubsan) gyp_params+=(-Duse_ubsan=1); nspr_sanitizer ubsan ;;
         --sancov) gyp_params+=(-Duse_sancov=edge); nspr_sanitizer sancov edge ;;
         --sancov=?*) gyp_params+=(-Duse_sancov="${1#*=}"); nspr_sanitizer sancov "${1#*=}" ;;
deleted file mode 100644
--- a/fuzz/Makefile
+++ /dev/null
@@ -1,42 +0,0 @@
-#! gmake
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#######################################################################
-# (1) Include initial platform-independent assignments (MANDATORY).   #
-#######################################################################
-
-include manifest.mn
-
-#######################################################################
-# (2) Include "global" configuration information. (OPTIONAL)          #
-#######################################################################
-
-include $(CORE_DEPTH)/coreconf/config.mk
-
-#######################################################################
-# (3) Include "component" configuration information. (OPTIONAL)       #
-#######################################################################
-
-
-#######################################################################
-# (4) Include "local" platform-dependent assignments (OPTIONAL).      #
-#######################################################################
-
-
-#######################################################################
-# (5) Execute "global" rules. (OPTIONAL)                              #
-#######################################################################
-
-include $(CORE_DEPTH)/coreconf/rules.mk
-
-#######################################################################
-# (6) Execute "component" rules. (OPTIONAL)                           #
-#######################################################################
-
-
-#######################################################################
-# (7) Execute "local" rules. (OPTIONAL).                              #
-#######################################################################
rename from fuzz/nssfuzz/cert_target.cc
rename to fuzz/cert_target.cc
--- a/fuzz/clone_libfuzzer.sh
+++ b/fuzz/clone_libfuzzer.sh
@@ -1,9 +1,9 @@
 #!/bin/sh
 
 cd $(dirname $0)
 mkdir tmp/
 git clone -q https://chromium.googlesource.com/chromium/llvm-project/llvm/lib/Fuzzer tmp/
-mv tmp/.git libFuzzer
+mv tmp/.git libFuzzer/
 rm -fr tmp
 cd libFuzzer
 git reset --hard 4333f2ca71eb7951fcafcdcb111012fbe25c5e7e
deleted file mode 100644
--- a/fuzz/common.mk
+++ /dev/null
@@ -1,10 +0,0 @@
-#! gmake
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-MKPROG = $(CCC)
-MKSHLIB = $(CCC) $(DSO_LDOPTS) $(DARWIN_SDK_SHLIBFLAGS)
-
-CXXFLAGS += -std=c++11
new file mode 100644
--- /dev/null
+++ b/fuzz/fuzz.gyp
@@ -0,0 +1,33 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+{
+  'includes': [
+    '../coreconf/config.gypi',
+    '../cmd/platlibs.gypi'
+  ],
+  'targets': [
+    {
+      'target_name': 'nssfuzz',
+      'type': 'executable',
+      'sources': [
+        'cert_target.cc',
+        'pkcs8_target.cc',
+        'spki_target.cc',
+        'nssfuzz.cc',
+      ],
+      'dependencies': [
+        '<(DEPTH)/exports.gyp:nss_exports',
+        '<(DEPTH)/fuzz/libFuzzer/libFuzzer.gyp:libFuzzer'
+      ]
+    }
+  ],
+  'target_defaults': {
+    'include_dirs': [
+      'libFuzzer',
+    ],
+  },
+  'variables': {
+    'module': 'nss',
+  }
+}
deleted file mode 100644
--- a/fuzz/libFuzzer/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-#! gmake
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#######################################################################
-# (1) Include initial platform-independent assignments (MANDATORY).   #
-#######################################################################
-
-include manifest.mn
-
-#######################################################################
-# (2) Include "global" configuration information. (OPTIONAL)          #
-#######################################################################
-
-include $(CORE_DEPTH)/coreconf/config.mk
-
-#######################################################################
-# (3) Include "component" configuration information. (OPTIONAL)       #
-#######################################################################
-
-include config.mk
-
-include ../common.mk
-
-#######################################################################
-# (4) Include "local" platform-dependent assignments (OPTIONAL).      #
-#######################################################################
-
-
-#######################################################################
-# (5) Execute "global" rules. (OPTIONAL)                              #
-#######################################################################
-
-include $(CORE_DEPTH)/coreconf/rules.mk
-
-#######################################################################
-# (6) Execute "component" rules. (OPTIONAL)                           #
-#######################################################################
-
-
-#######################################################################
-# (7) Execute "local" rules. (OPTIONAL).                              #
-#######################################################################
deleted file mode 100644
--- a/fuzz/libFuzzer/config.mk
+++ /dev/null
@@ -1,14 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# According to the LLVM docs, LibFuzzer isn't supposed to be built with any
-# sanitizer flags and in fact, building it with ASan coverage currently causes
-# Clang 3.9+ to crash, so we filter out all sanitizer-related flags here.
-CXXFLAGS := $(filter-out -fsanitize%,$(CXXFLAGS))
-CFLAGS := $(filter-out -fsanitize%,$(CFLAGS))
-LDFLAGS := $(filter-out -fsanitize%,$(LDFLAGS))
-DARWIN_SDK_SHLIBFLAGS := $(filter-out -fsanitize%,$(DARWIN_SDK_SHLIBFLAGS))
-
-CXXFLAGS += -g -O2
new file mode 100644
--- /dev/null
+++ b/fuzz/libFuzzer/libFuzzer.gyp
@@ -0,0 +1,36 @@
+# This Source Code Form is subject to the terms of the Mozilla Public
+# License, v. 2.0. If a copy of the MPL was not distributed with this
+# file, You can obtain one at http://mozilla.org/MPL/2.0/.
+{
+  'includes': [
+    '../../coreconf/config.gypi'
+  ],
+  'targets': [
+    {
+      'target_name': 'libFuzzer',
+      'type': 'static_library',
+      'sources': [
+        'FuzzerCrossOver.cpp',
+        'FuzzerDriver.cpp',
+        'FuzzerExtFunctionsDlsym.cpp',
+        'FuzzerExtFunctionsWeak.cpp',
+        'FuzzerIO.cpp',
+        'FuzzerLoop.cpp',
+        'FuzzerMutate.cpp',
+        'FuzzerSHA1.cpp',
+        'FuzzerTracePC.cpp',
+        'FuzzerTraceState.cpp',
+        'FuzzerUtil.cpp',
+        'FuzzerUtilDarwin.cpp',
+        'FuzzerUtilLinux.cpp',
+      ],
+      'cflags': [
+        '-O2',
+      ],
+      'cflags/': [
+        ['exclude', '-fsanitize='],
+        ['exclude', '-fsanitize-'],
+      ]
+    }
+  ],
+}
deleted file mode 100644
--- a/fuzz/libFuzzer/manifest.mn
+++ /dev/null
@@ -1,26 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-CORE_DEPTH = ../..
-DEPTH      = ../..
-MODULE = nss
-
-CPPSRCS = \
-      FuzzerCrossOver.cpp \
-      FuzzerDriver.cpp \
-      FuzzerExtFunctionsDlsym.cpp \
-      FuzzerExtFunctionsWeak.cpp \
-      FuzzerIO.cpp \
-      FuzzerLoop.cpp \
-      FuzzerMutate.cpp \
-      FuzzerSHA1.cpp \
-      FuzzerTracePC.cpp \
-      FuzzerTraceState.cpp \
-      FuzzerUtil.cpp \
-      FuzzerUtilDarwin.cpp \
-      FuzzerUtilLinux.cpp \
-      $(NULL)
-
-LIBRARY_NAME = Fuzzer
-LIBRARY_VERSION = 1
deleted file mode 100644
--- a/fuzz/manifest.mn
+++ /dev/null
@@ -1,8 +0,0 @@
-# 
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-CORE_DEPTH = ..
-DEPTH      = ..
-
-DIRS = libFuzzer nssfuzz
rename from fuzz/nssfuzz/nssfuzz.cc
rename to fuzz/nssfuzz.cc
deleted file mode 100644
--- a/fuzz/nssfuzz/Makefile
+++ /dev/null
@@ -1,45 +0,0 @@
-#! gmake
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-#######################################################################
-# (1) Include initial platform-independent assignments (MANDATORY).   #
-#######################################################################
-
-include manifest.mn
-
-#######################################################################
-# (2) Include "global" configuration information. (OPTIONAL)          #
-#######################################################################
-
-include $(CORE_DEPTH)/coreconf/config.mk
-
-#######################################################################
-# (3) Include "component" configuration information. (OPTIONAL)       #
-#######################################################################
-
-include $(CORE_DEPTH)/cmd/platlibs.mk
-
-include ../common.mk
-
-#######################################################################
-# (4) Include "local" platform-dependent assignments (OPTIONAL).      #
-#######################################################################
-
-
-#######################################################################
-# (5) Execute "global" rules. (OPTIONAL)                              #
-#######################################################################
-
-include $(CORE_DEPTH)/coreconf/rules.mk
-
-#######################################################################
-# (6) Execute "component" rules. (OPTIONAL)                           #
-#######################################################################
-
-
-#######################################################################
-# (7) Execute "local" rules. (OPTIONAL).                              #
-#######################################################################
deleted file mode 100644
--- a/fuzz/nssfuzz/manifest.mn
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-CORE_DEPTH = ../..
-DEPTH      = ../..
-MODULE = nss
-
-CPPSRCS = \
-      cert_target.cc \
-      pkcs8_target.cc \
-      spki_target.cc \
-      nssfuzz.cc \
-      $(NULL)
-
-INCLUDES += -I$(CORE_DEPTH)/fuzz/libFuzzer
-
-REQUIRES = nspr nss
-
-PROGRAM = nssfuzz
-
-EXTRA_LIBS = $(DIST)/lib/$(LIB_PREFIX)Fuzzer.$(LIB_SUFFIX)
-
-USE_STATIC_LIBS = 1
rename from fuzz/nssfuzz/pkcs8_target.cc
rename to fuzz/pkcs8_target.cc
rename from fuzz/nssfuzz/registry.h
rename to fuzz/registry.h
rename from fuzz/nssfuzz/shared.h
rename to fuzz/shared.h
rename from fuzz/nssfuzz/spki_target.cc
rename to fuzz/spki_target.cc
--- a/manifest.mn
+++ b/manifest.mn
@@ -6,12 +6,8 @@ CORE_DEPTH = .
 DEPTH      = .
 
 IMPORTS =	nspr20/v4.8 \
 		$(NULL)
 
 RELEASE = nss
 
 DIRS = coreconf lib cmd gtests
-
-ifdef FUZZ
-DIRS += fuzz
-endif
--- a/nss.gyp
+++ b/nss.gyp
@@ -228,24 +228,31 @@
             }],
           ],
         },
       ],
     }],
     [ 'fuzz==1', {
       'targets': [
         {
-          'target_name': 'fuzz',
+          'target_name': 'fuzz_warning',
           'type': 'none',
           'actions': [
             {
-              'action_name': 'warn_fuzz',
+              'action_name': 'fuzz_warning',
               'action': ['cat', 'fuzz/warning.txt'],
               'inputs': ['fuzz/warning.txt'],
               'ninja_use_console': 1,
               'outputs': ['dummy'],
             }
           ],
         },
+        {
+          'target_name': 'fuzz',
+          'type': 'none',
+          'dependencies': [
+            'fuzz/fuzz.gyp:nssfuzz',
+          ]
+        },
       ],
     }],
   ],
 }