Bug 1419798 - Only build fuzzing interfaces if clang or AFL compilers are used. r?glandium draft
authorJesse Schwartzentruber <jdschwa@gmail.com>
Wed, 22 Nov 2017 11:21:09 -0500
changeset 702651 7d7b730194b2156be6b91fee334f8e8a37418d27
parent 702588 b6bed1b710c3e22cab49f22f1b5f44d80286bcb9
child 741546 f7a6a2a05d9f53c3b9fb35079794299b01cfaf22
push id90570
push userbmo:jschwartzentruber@mozilla.com
push dateThu, 23 Nov 2017 15:00:49 +0000
reviewersglandium
bugs1419798
milestone59.0a1
Bug 1419798 - Only build fuzzing interfaces if clang or AFL compilers are used. r?glandium MozReview-Commit-ID: H1I9wdqTV4n
image/moz.build
js/moz.configure
media/mtransport/moz.build
media/webrtc/moz.build
--- a/image/moz.build
+++ b/image/moz.build
@@ -3,17 +3,17 @@
 # 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/.
 
 DIRS += ['build', 'decoders', 'encoders']
 if CONFIG['ENABLE_TESTS']:
     DIRS += ['test/gtest']
 
-if CONFIG['FUZZING']:
+if CONFIG['FUZZING_INTERFACES']:
     DIRS += ['test/fuzzing']
 
 with Files('**'):
     BUG_COMPONENT = ('Core', 'ImageLib')
 
 BROWSER_CHROME_MANIFESTS += ['test/browser/browser.ini']
 
 MOCHITEST_MANIFESTS += ['test/mochitest/mochitest.ini']
--- a/js/moz.configure
+++ b/js/moz.configure
@@ -236,30 +236,46 @@ include('ffi.configure', when=ctypes_and
 with only_when('--enable-compile-environment'):
     js_option('--enable-fuzzing', help='Enable fuzzing support')
 
     @depends('--enable-fuzzing')
     def enable_fuzzing(value):
         if value:
             return True
 
-    @depends(enable_fuzzing,
-             try_compile(body='__AFL_COMPILER;',
+    @depends(try_compile(body='__AFL_COMPILER;',
                          check_msg='for AFL compiler',
                          when='--enable-fuzzing'))
-    def enable_libfuzzer(fuzzing, afl):
-        if fuzzing and not afl:
+    def enable_aflfuzzer(afl):
+        if afl:
+            return True
+
+    @depends(enable_fuzzing,
+             enable_aflfuzzer,
+             c_compiler)
+    def enable_libfuzzer(fuzzing, afl, c_compiler):
+        if fuzzing and not afl and c_compiler.type == 'clang':
+            return True
+
+    @depends(enable_fuzzing,
+             enable_aflfuzzer,
+             enable_libfuzzer)
+    def enable_fuzzing_interfaces(fuzzing, afl, libfuzzer):
+        if fuzzing and (afl or libfuzzer):
             return True
 
     set_config('FUZZING', enable_fuzzing)
     set_define('FUZZING', enable_fuzzing)
 
     set_config('LIBFUZZER', enable_libfuzzer)
     set_define('LIBFUZZER', enable_libfuzzer)
 
+    set_config('FUZZING_INTERFACES', enable_fuzzing_interfaces)
+    set_define('FUZZING_INTERFACES', enable_fuzzing_interfaces)
+
 # Enable pipeline operator
 # ===================================================
 js_option('--enable-pipeline-operator', default=False, help='Enable pipeline operator')
 
 @depends('--enable-pipeline-operator')
 def enable_pipeline_operator(value):
     if value:
         return True
--- a/media/mtransport/moz.build
+++ b/media/mtransport/moz.build
@@ -16,11 +16,12 @@ DIRS += [
 ]
 
 if CONFIG['FUZZING']:
     if CONFIG['LIBFUZZER']:
         # Add trace-pc coverage for libfuzzer
         CFLAGS += ['-fsanitize-coverage=trace-pc-guard']
         CXXFLAGS += ['-fsanitize-coverage=trace-pc-guard']
 
-    TEST_DIRS += [
-        'fuzztest'
-    ]
+    if CONFIG['FUZZING_INTERFACES']:
+        TEST_DIRS += [
+            'fuzztest'
+        ]
--- a/media/webrtc/moz.build
+++ b/media/webrtc/moz.build
@@ -106,11 +106,12 @@ if CONFIG['MOZ_WEBRTC_SIGNALING']:
         ]
 
     if CONFIG['FUZZING']:
         if CONFIG['LIBFUZZER']:
             # Add trace-pc coverage for libfuzzer
             CFLAGS += ['-fsanitize-coverage=trace-pc-guard']
             CXXFLAGS += ['-fsanitize-coverage=trace-pc-guard']
 
-        TEST_DIRS += [
-            'signaling/fuzztest'
-        ]
+        if CONFIG['FUZZING_INTERFACES']:
+            TEST_DIRS += [
+                'signaling/fuzztest'
+            ]