Bug 1475573 - Create --enable-fuzzing debug build job for Android x86 firefox. r=nalexander,froydnj
authorJesse Schwartzentruber <truber@mozilla.com>
Tue, 07 Aug 2018 17:53:57 +0000
changeset 827724 d602a2f69ff89abe965c77ff945c143e8014feb8
parent 827723 f29562384b58405b0e647f1cf0d3c8554375275c
child 827725 dacdc94c62badd03b7e2ff0399d50b2d29f8a6ea
push id118579
push userbmo:jld@mozilla.com
push dateThu, 09 Aug 2018 01:01:21 +0000
reviewersnalexander, froydnj
bugs1475573
milestone63.0a1
Bug 1475573 - Create --enable-fuzzing debug build job for Android x86 firefox. r=nalexander,froydnj Differential Revision: https://phabricator.services.mozilla.com/D2428
build/gecko_templates.mozbuild
ipc/app/moz.build
mobile/android/config/mozconfigs/android-x86/debug-fuzzing
taskcluster/ci/build/android.yml
testing/mozharness/configs/builds/releng_sub_android_configs/64_x86_fuzzing_debug.py
testing/mozharness/mozharness/mozilla/building/buildbase.py
tools/fuzzing/faulty/Faulty.cpp
--- a/build/gecko_templates.mozbuild
+++ b/build/gecko_templates.mozbuild
@@ -31,16 +31,25 @@ def GeckoBinary(linkage='dependent', moz
         DEFINES['XPCOM_GLUE'] = True
 
         USE_LIBS += [
             'xpcomglue',
         ]
     elif linkage != None:
         error('`linkage` must be "dependent", "standalone" or None')
 
+    if CONFIG['LIBFUZZER']:
+        assert mozglue is not None, 'libfuzzer depends on "mozglue"'
+        USE_LIBS += [
+            'fuzzer'
+        ]
+        LOCAL_INCLUDES += [
+            '/tools/fuzzing/libfuzzer'
+        ]
+
     if mozglue:
         LDFLAGS += CONFIG['MOZ_GLUE_WRAP_LDFLAGS']
         if mozglue == 'program':
             USE_LIBS += ['mozglue']
             DEFINES['MOZ_HAS_MOZGLUE'] = True
             if CONFIG['MOZ_GLUE_IN_PROGRAM'] and CONFIG['CC_TYPE'] in ('clang', 'gcc'):
                 LDFLAGS += ['-rdynamic']
         elif mozglue == 'library':
--- a/ipc/app/moz.build
+++ b/ipc/app/moz.build
@@ -18,16 +18,25 @@ else:
 
 include('/ipc/chromium/chromium-config.mozbuild')
 
 LOCAL_INCLUDES += [
     '/toolkit/xre',
     '/xpcom/base',
 ]
 
+if CONFIG['LIBFUZZER']:
+    USE_LIBS += [
+        'fuzzer',
+        'mozglue'
+    ]
+    LOCAL_INCLUDES += [
+        '/tools/fuzzing/libfuzzer',
+    ]
+
 # DELAYLOAD_DLLS in this block ensures that the DLL blocklist is functional
 if CONFIG['OS_ARCH'] == 'WINNT':
     DELAYLOAD_DLLS += [
         'nss3.dll',
     ]
 
     if CONFIG['MOZ_SANDBOX']:
         # For sandbox includes and the include dependencies those have
new file mode 100644
--- /dev/null
+++ b/mobile/android/config/mozconfigs/android-x86/debug-fuzzing
@@ -0,0 +1,13 @@
+. "$topsrcdir/mobile/android/config/mozconfigs/android-x86/debug"
+
+# Remove unwanted environment variables from the 'debug' mozconfig.
+unset MOZILLA_OFFICIAL
+unset MOZ_TELEMETRY_REPORTING
+unset MOZ_ANDROID_POCKET
+
+ac_add_options --enable-fuzzing
+
+# This adds '-fuzzing' to the APK filename for local builds.
+export MOZ_PKG_SPECIAL=fuzzing
+
+. "$topsrcdir/mobile/android/config/mozconfigs/common.override"
--- a/taskcluster/ci/build/android.yml
+++ b/taskcluster/ci/build/android.yml
@@ -150,16 +150,66 @@ android-x86/opt:
         - android-ndk-linux
         - android-sdk-linux
         - linux64-clang
         - linux64-rust-android
         - linux64-rust-size
         - linux64-sccache
         - linux64-node
 
+android-x86-fuzzing/debug:
+    description: "Android x86 Fuzzing Debug"
+    index:
+        product: mobile
+        job-name: android-x86-fuzzing-debug
+    treeherder:
+        platform: android-4-2-x86/debug
+        symbol: Bf
+    worker-type: aws-provisioner-v1/gecko-{level}-b-android
+    worker:
+        docker-image: {in-tree: android-build}
+        max-run-time: 7200
+        env:
+            GRADLE_USER_HOME: "/builds/worker/workspace/build/src/mobile/android/gradle/dotgradle-offline"
+            TOOLTOOL_MANIFEST: "mobile/android/config/tooltool-manifests/android-x86/releng.manifest"
+        artifacts:
+            - name: public/android/R
+              path: /builds/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/app/R
+              type: directory
+            - name: public/android/maven
+              path: /builds/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/geckoview/maven/
+              type: directory
+            - name: public/build/geckoview-androidTest.apk
+              path: /builds/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/geckoview/outputs/apk/androidTest/officialWithGeckoBinariesNoMinApi/debug/geckoview-official-withGeckoBinaries-noMinApi-debug-androidTest.apk
+              type: file
+            - name: public/build/geckoview_example.apk
+              path: /builds/worker/workspace/build/src/obj-firefox/gradle/build/mobile/android/geckoview_example/outputs/apk/officialWithGeckoBinariesNoMinApi/debug/geckoview_example-official-withGeckoBinaries-noMinApi-debug.apk
+              type: file
+            - name: public/build
+              path: /builds/worker/artifacts/
+              type: directory
+    run:
+        using: mozharness
+        actions: [get-secrets build multi-l10n update]
+        config:
+            - builds/releng_base_android_64_builds.py
+        script: "mozharness/scripts/fx_desktop_build.py"
+        secrets: true
+        custom-build-variant-cfg: x86-fuzzing-debug
+        tooltool-downloads: internal
+    toolchains:
+        - android-gradle-dependencies
+        - android-ndk-linux
+        - android-sdk-linux
+        - linux64-clang
+        - linux64-rust-android
+        - linux64-rust-size
+        - linux64-sccache
+        - linux64-node
+
 android-x86-nightly/opt:
     description: "Android 4.2 x86 Nightly"
     attributes:
         nightly: true
     shipping-phase: promote
     shipping-product: fennec
     index:
         product: mobile
new file mode 100644
--- /dev/null
+++ b/testing/mozharness/configs/builds/releng_sub_android_configs/64_x86_fuzzing_debug.py
@@ -0,0 +1,6 @@
+config = {
+    'base_name': 'Android 4.2 x86 %(branch)s debug fuzzing build',
+    'stage_platform': 'android-x86-fuzzing-debug',
+    'src_mozconfig': 'mobile/android/config/mozconfigs/android-x86/debug-fuzzing',
+    'debug_build': True,
+}
--- a/testing/mozharness/mozharness/mozilla/building/buildbase.py
+++ b/testing/mozharness/mozharness/mozilla/building/buildbase.py
@@ -432,16 +432,17 @@ class BuildOptionParser(object):
         'api-16-debug-artifact': 'builds/releng_sub_%s_configs/%s_api_16_debug_artifact.py',
         'api-16-gradle': 'builds/releng_sub_%s_configs/%s_api_16_gradle.py',
         'api-16-gradle-artifact': 'builds/releng_sub_%s_configs/%s_api_16_gradle_artifact.py',
         'api-16-without-google-play-services': 'builds/releng_sub_%s_configs/%s_api_16_without_google_play_services.py',
         'rusttests': 'builds/releng_sub_%s_configs/%s_rusttests.py',
         'rusttests-debug': 'builds/releng_sub_%s_configs/%s_rusttests_debug.py',
         'x86': 'builds/releng_sub_%s_configs/%s_x86.py',
         'x86-artifact': 'builds/releng_sub_%s_configs/%s_x86_artifact.py',
+        'x86-fuzzing-debug': 'builds/releng_sub_%s_configs/%s_x86_fuzzing_debug.py',
         'api-16-partner-sample1': 'builds/releng_sub_%s_configs/%s_api_16_partner_sample1.py',
         'aarch64': 'builds/releng_sub_%s_configs/%s_aarch64.py',
         'android-test': 'builds/releng_sub_%s_configs/%s_test.py',
         'android-test-ccov': 'builds/releng_sub_%s_configs/%s_test_ccov.py',
         'android-checkstyle': 'builds/releng_sub_%s_configs/%s_checkstyle.py',
         'android-lint': 'builds/releng_sub_%s_configs/%s_lint.py',
         'android-findbugs': 'builds/releng_sub_%s_configs/%s_findbugs.py',
         'android-geckoview-docs': 'builds/releng_sub_%s_configs/%s_geckoview_docs.py',
--- a/tools/fuzzing/faulty/Faulty.cpp
+++ b/tools/fuzzing/faulty/Faulty.cpp
@@ -357,17 +357,17 @@ Faulty::MutationFactor()
 void
 Faulty::MaybeCollectAndClosePipe(int aPipe, unsigned int aProbability)
 {
   if (!mFuzzPipes) {
     return;
   }
 
   if (aPipe > -1) {
-    FAULTY_LOG("Collecting pipe %d to bucket of pipes (count: %ld)",
+    FAULTY_LOG("Collecting pipe %d to bucket of pipes (count: %zu)",
                aPipe, mFds.size());
     mFds.insert(aPipe);
   }
 
   if (mFds.size() > 0 && FuzzingTraits::Sometimes(aProbability)) {
     std::set<int>::iterator it(mFds.begin());
     std::advance(it, FuzzingTraits::Random(mFds.size()));
     FAULTY_LOG("Trying to close collected pipe: %d", *it);