diff -r b22cb12f611c build/moz.configure/lto-pgo.configure
--- a/build/moz.configure/lto-pgo.configure	Thu Oct 07 08:11:19 2021 +0000
+++ b/build/moz.configure/lto-pgo.configure	Sun Oct 10 20:36:46 2021 -0700
@@ -81,17 +81,17 @@
 
 @depends(c_compiler, pgo_profile_path, target_is_windows)
 @imports("multiprocessing")
 @imports(_from="__builtin__", _import="min")
 def pgo_flags(compiler, profdata, target_is_windows):
     if compiler.type == "gcc":
         return namespace(
             gen_cflags=["-fprofile-generate"],
             gen_ldflags=["-fprofile-generate"],
-            use_cflags=["-fprofile-use", "-fprofile-correction", "-Wcoverage-mismatch"],
+            use_cflags=["-fprofile-use", "-fprofile-correction", "-Wno-coverage-mismatch"],
             use_ldflags=["-fprofile-use"],
         )
 
     if compiler.type in ("clang-cl", "clang"):
         prefix = ""
         if compiler.type == "clang-cl":
             prefix = "/clang:"
             gen_ldflags = None
@@ -234,23 +234,23 @@
                 "configure."
             )
 
         if c_compiler.type == "clang":
             if len(value) and value[0].lower() == "full":
                 cflags.append("-flto")
                 ldflags.append("-flto")
             else:
-                cflags.append("-flto=thin")
-                ldflags.append("-flto=thin")
+                cflags.append("-flto")
+                ldflags.append("-flto")
         elif c_compiler.type == "clang-cl":
             if len(value) and value[0].lower() == "full":
                 cflags.append("-flto")
             else:
-                cflags.append("-flto=thin")
+                cflags.append("-flto")
             # With clang-cl, -flto can only be used with -c or -fuse-ld=lld.
             # AC_TRY_LINKs during configure don't have -c, so pass -fuse-ld=lld.
             cflags.append("-fuse-ld=lld")
 
             # Explicitly set the CPU to optimize for so the linker doesn't
             # choose a poor default.  Rust compilation by default uses the
             # pentium4 CPU on x86:
             #
diff -r b22cb12f611c build/pgo/profileserver.py
--- a/build/pgo/profileserver.py	Thu Oct 07 08:11:19 2021 +0000
+++ b/build/pgo/profileserver.py	Sun Oct 10 20:36:46 2021 -0700
@@ -82,19 +82,32 @@
         docroot=os.path.join(build.topsrcdir, "build", "pgo"),
         path_mappings=path_mappings,
     )
     httpd.start(block=False)
 
     locations = ServerLocations()
     locations.add_host(host="127.0.0.1", port=PORT, options="primary,privileged")
 
-    old_profraw_files = glob.glob("*.profraw")
-    for f in old_profraw_files:
-        os.remove(f)
+    using_gcc = False
+    try:
+        if build.config_environment.substs.get('CC_TYPE') == 'gcc':
+            using_gcc = True
+    except BuildEnvironmentNotFoundException:
+        pass
+
+    if using_gcc:
+        for dirpath, _, filenames in os.walk('.'):
+            for f in filenames:
+                if f.endswith('.gcda'):
+                    os.remove(os.path.join(dirpath, f))
+    else:
+        old_profraw_files = glob.glob('*.profraw')
+        for f in old_profraw_files:
+            os.remove(f)
 
     with TemporaryDirectory() as profilePath:
         # TODO: refactor this into mozprofile
         profile_data_dir = os.path.join(build.topsrcdir, "testing", "profiles")
         with open(os.path.join(profile_data_dir, "profiles.json"), "r") as fh:
             base_profiles = json.load(fh)["profileserver"]
 
         prefpaths = [
@@ -207,16 +220,20 @@
 
         # Try to move the crash reports to the artifacts even if Firefox appears
         # to exit successfully, in case there's a crash that doesn't set the
         # return code to non-zero for some reason.
         if get_crashreports(profilePath, name="Firefox exited successfully?") != 0:
             print("Firefox exited successfully, but produced a crashreport")
             sys.exit(1)
 
+        print('Copying profile data....')
+        os.system('pwd');
+        os.system('tar cf profdata.tar.gz `find . -name "*.gcda"`; cd ..; tar xf instrumented/profdata.tar.gz;');
+
         llvm_profdata = env.get("LLVM_PROFDATA")
         if llvm_profdata:
             profraw_files = glob.glob("*.profraw")
             if not profraw_files:
                 print(
                     "Could not find profraw files in the current directory: %s"
                     % os.getcwd()
                 )
diff -r b22cb12f611c mfbt/tests/moz.build
--- a/mfbt/tests/moz.build	Thu Oct 07 08:11:19 2021 +0000
+++ b/mfbt/tests/moz.build	Sun Oct 10 20:36:46 2021 -0700
@@ -80,21 +80,21 @@
             "TestSPSCQueue",
             "TestThreadSafeWeakPtr",
         ]
     )
 
 # Not to be unified with the rest, because this test
 # sets MOZ_PRETEND_NO_JSRUST, which changes the behavior
 # of the included headers.
-CppUnitTests(
-    [
-        "TestUtf8",
-    ]
-)
+#CppUnitTests(
+#    [
+#        "TestUtf8",
+#    ]
+#)
 
 # Wasi doesn't support <signal> yet so skip this test.
 if not CONFIG["MOZ_ASAN"] and CONFIG["OS_ARCH"] != "WASI":
     CppUnitTests(
         [
             "TestPoisonArea",
         ]
     )
diff -r b22cb12f611c toolkit/components/terminator/nsTerminator.cpp
--- a/toolkit/components/terminator/nsTerminator.cpp	Thu Oct 07 08:11:19 2021 +0000
+++ b/toolkit/components/terminator/nsTerminator.cpp	Sun Oct 10 20:36:46 2021 -0700
@@ -451,16 +451,21 @@
       // Defend against overflow
       crashAfterMS = INT32_MAX;
     } else {
       crashAfterMS *= scaleUp;
     }
   }
 #endif
 
+  // Disable watchdog for PGO train builds - writting profile information at
+  // exit may take time and it is better to make build hang rather than
+  // silently produce poorly performing binary.
+  crashAfterMS = INT32_MAX;
+
   UniquePtr<Options> options(new Options());
   const PRIntervalTime ticksDuration =
       PR_MillisecondsToInterval(HEARTBEAT_INTERVAL_MS);
   options->crashAfterTicks = crashAfterMS / ticksDuration;
   // Handle systems where ticksDuration is greater than crashAfterMS.
   if (options->crashAfterTicks == 0) {
     options->crashAfterTicks = crashAfterMS / HEARTBEAT_INTERVAL_MS;
   }
