Bug 1332827 - Port bug 1330533 to TB [Simplify the LibFuzzer setup in Gecko]. r=jorgk
authorRichard Marti <richard.marti@gmail.com>
Sun, 22 Jan 2017 09:48:08 +0100
changeset 21034 a8a8f8a2b5cd637882b14f0f298f0724d5d15616
parent 21033 24a3ded7409deaceb56181dcd9bbdea44c39ddec
child 21035 137c08b2e6e4801d2e884a3e6c8473becd267bc8
push id12770
push userrichard.marti@gmail.com
push dateSun, 22 Jan 2017 08:48:49 +0000
treeherdercomm-central@a8a8f8a2b5cd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjorgk
bugs1332827, 1330533
Bug 1332827 - Port bug 1330533 to TB [Simplify the LibFuzzer setup in Gecko]. r=jorgk
mail/app/moz.build
mail/app/nsMailApp.cpp
--- a/mail/app/moz.build
+++ b/mail/app/moz.build
@@ -11,17 +11,20 @@ SOURCES += ['nsMailApp.cpp']
 LOCAL_INCLUDES += [
     '!/build',
     '/mozilla/toolkit/xre',
     '/mozilla/xpcom/base',
     '/mozilla/xpcom/build',
 ]
 
 if CONFIG['LIBFUZZER']:
-  USE_LIBS += [ 'fuzzer' ]
+    USE_LIBS += [ 'fuzzer' ]
+    LOCAL_INCLUDES += [
+        '/mozilla/tools/fuzzing/libfuzzer',
+    ]
 
 if CONFIG['OS_ARCH'] == 'WINNT':
     RCINCLUDE = 'splash.rc'
     DEFINES['MOZ_THUNDERBIRD'] = True
 
 if CONFIG['MOZ_SANDBOX'] and CONFIG['OS_ARCH'] == 'WINNT':
     # For sandbox includes and the include dependencies those have
     LOCAL_INCLUDES += [
--- a/mail/app/nsMailApp.cpp
+++ b/mail/app/nsMailApp.cpp
@@ -38,16 +38,20 @@
 #include "BinaryPath.h"
 
 #include "nsXPCOMPrivate.h" // for MAXPATHLEN and XPCOM_DLL
 
 #include "mozilla/Sprintf.h"
 #include "mozilla/Telemetry.h"
 #include "mozilla/WindowsDllBlocklist.h"
 
+#ifdef LIBFUZZER
+#include "FuzzerDefs.h"
+#endif
+
 #ifdef MOZ_LINUX_32_SSE2_STARTUP_ERROR
 #include <cpuid.h>
 #include "mozilla/Unused.h"
 
 static bool
 IsSSE2Available()
 {
   // The rest of the app has been compiled to assume that SSE2 is present
@@ -159,27 +163,16 @@ static bool IsArg(const char* arg, const
     return !strcasecmp(++arg, s);
 #endif
 
   return false;
 }
 
 Bootstrap::UniquePtr gBootstrap;
 
-#ifdef LIBFUZZER
-int libfuzzer_main(int argc, char **argv);
-
-/* This wrapper is used by the libFuzzer main to call into libxul */
-
-void libFuzzerGetFuncs(const char* moduleName, LibFuzzerInitFunc* initFunc,
-                       LibFuzzerTestingFunc* testingFunc) {
-  return gBootstrap->XRE_LibFuzzerGetFuncs(moduleName, initFunc, testingFunc);
-}
-#endif
-
 static int do_main(int argc, char* argv[], char* envp[])
 {
 
   // Allow thunderbird.exe to launch XULRunner apps via -app <application.ini>
   // Note that -app must be the *first* argument.
   const char *appDataFile = getenv("XUL_APP_FILE");
   if ((!appDataFile || !*appDataFile) &&
       (argc > 1 && IsArg(argv[1], "app"))) {
@@ -232,17 +225,17 @@ static int do_main(int argc, char* argv[
     return 255;
   }
 #endif
   config.sandboxBrokerServices = brokerServices;
 #endif
 
 #ifdef LIBFUZZER
   if (getenv("LIBFUZZER"))
-    gBootstrap->XRE_LibFuzzerSetMain(argc, argv, libfuzzer_main);
+    gBootstrap->XRE_LibFuzzerSetDriver(fuzzer::FuzzerDriver);
 #endif
 
   return gBootstrap->XRE_main(argc, argv, config);
 }
 
 static bool
 FileExists(const char *path)
 {