Bug 1321762 - Fix fuzzing speed regressions r=franziskus
authorTim Taubert <ttaubert@mozilla.com>
Fri, 02 Dec 2016 09:48:36 +0100
changeset 12939 5f2db99c258feee0dbbebdb2f06f10193ef79652
parent 12938 5796201e791e6cbffc3615cb0c894cf1b0fc09a1
child 12940 433172d35f525c82db3eb0b583f40e93a7d3a7c8
push id1850
push userttaubert@mozilla.com
push dateFri, 02 Dec 2016 08:49:09 +0000
reviewersfranziskus
bugs1321762
Bug 1321762 - Fix fuzzing speed regressions r=franziskus Differential Revision: https://nss-review.dev.mozaws.net/D114
automation/taskcluster/graph/src/extend.js
build.sh
coreconf/config.gypi
fuzz/fuzz.gyp
--- a/automation/taskcluster/graph/src/extend.js
+++ b/automation/taskcluster/graph/src/extend.js
@@ -274,17 +274,17 @@ async function scheduleFuzzing() {
   };
 
   // Build base definition.
   let build_base = merge({
     command: [
       "/bin/bash",
       "-c",
       "bin/checkout.sh && " +
-      "nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz"
+      "nss/automation/taskcluster/scripts/build_gyp.sh -g -v --fuzz --ubsan"
     ],
     artifacts: {
       public: {
         expires: 24 * 7,
         type: "directory",
         path: "/home/worker/artifacts"
       }
     },
--- a/build.sh
+++ b/build.sh
@@ -49,17 +49,17 @@ fi
 
 opt_build=0
 build_64=0
 clean=0
 rebuild_gyp=0
 target=Debug
 verbose=0
 fuzz=0
-sancov_default=edge,indirect-calls,8bit-counters,trace-cmp
+sancov_default=edge,indirect-calls,8bit-counters
 
 # parse parameters to store in config
 params=$(echo "$*" | perl -pe 's/-c|-v|-g|-j [0-9]*|-h//g' | perl -pe 's/^\s*(.*?)\s*$/\1/')
 params=$(echo "$params $CC $CCC" | tr " " "\n" | perl -pe '/^\s*$/d')
 params=$(echo "${params[*]}" | sort)
 
 cwd=$(cd $(dirname $0); pwd -P)
 dist_dir="$cwd/../dist"
@@ -73,20 +73,18 @@ fi
 gyp_params=()
 ninja_params=()
 scanbuild=()
 
 enable_fuzz()
 {
     fuzz=1
     nspr_sanitizer asan
-    nspr_sanitizer ubsan
     nspr_sanitizer sancov $sancov_default
     gyp_params+=(-Duse_asan=1)
-    gyp_params+=(-Duse_ubsan=1)
     gyp_params+=(-Duse_sancov=$sancov_default)
 
     # Adding debug symbols even for opt builds.
     nspr_opt+=(--enable-debug-symbols)
 }
 
 # parse command line arguments
 while [ $# -gt 0 ]; do
--- a/coreconf/config.gypi
+++ b/coreconf/config.gypi
@@ -291,17 +291,17 @@
               '<!@(<(python) <(DEPTH)/coreconf/werror.py)',
             ],
           }],
           [ 'fuzz==1', {
             'cflags': [
               '-Wno-unused-function',
             ]
           }],
-          [ 'use_asan==1 or use_ubsan==1', {
+          [ 'fuzz==1 or use_asan==1 or use_ubsan==1', {
             'cflags': ['-O1'],
             'xcode_settings': {
               'GCC_OPTIMIZATION_LEVEL': '1', # -O1
             }
           }],
           [ 'use_asan==1', {
             'variables': {
               'asan_flags': '<!(<(python) <(DEPTH)/coreconf/sanitizers.py asan)',
--- a/fuzz/fuzz.gyp
+++ b/fuzz/fuzz.gyp
@@ -20,47 +20,63 @@
         'libFuzzer/FuzzerMutate.cpp',
         'libFuzzer/FuzzerSHA1.cpp',
         'libFuzzer/FuzzerTracePC.cpp',
         'libFuzzer/FuzzerTraceState.cpp',
         'libFuzzer/FuzzerUtil.cpp',
         'libFuzzer/FuzzerUtilDarwin.cpp',
         'libFuzzer/FuzzerUtilLinux.cpp',
       ],
+      'cflags': [
+        '-O2',
+      ],
+      'cflags!': [
+        '-O1',
+      ],
+      'cflags/': [
+        ['exclude', '-fsanitize'],
+      ],
+      'xcode_settings': {
+        'GCC_OPTIMIZATION_LEVEL': '2', # -O2
+        'OTHER_CFLAGS/': [
+          ['exclude', '-fsanitize'],
+        ],
+      },
     },
     {
       'target_name': 'nssfuzz',
       'type': 'executable',
       'sources': [
         'asn1_mutators.cc',
         'nssfuzz.cc',
         'pkcs8_target.cc',
         'quickder_targets.cc',
       ],
       'dependencies': [
         '<(DEPTH)/exports.gyp:nss_exports',
         'libFuzzer',
-      ]
+      ],
+      'cflags': [
+        '-O2',
+      ],
+      'cflags!': [
+        '-O1',
+      ],
+      'cflags/': [
+        ['exclude', '-fsanitize-coverage'],
+      ],
+      'xcode_settings': {
+        'GCC_OPTIMIZATION_LEVEL': '2', # -O2
+        'OTHER_CFLAGS/': [
+          ['exclude', '-fsanitize-coverage'],
+        ],
+      },
     }
   ],
   'target_defaults': {
     'include_dirs': [
       'libFuzzer',
     ],
-    'cflags': [
-      '-O2',
-    ],
-    'cflags/': [
-      ['exclude', '-fsanitize='],
-      ['exclude', '-fsanitize-'],
-    ],
-    'xcode_settings': {
-      'GCC_OPTIMIZATION_LEVEL': '2', # -O2
-      'OTHER_CFLAGS/': [
-        ['exclude', '-fsanitize='],
-        ['exclude', '-fsanitize-'],
-      ],
-    },
   },
   'variables': {
     'module': 'nss',
   }
 }