aboutsummaryrefslogtreecommitdiff
path: root/www-client/icecat/files/0013-gcc-lto-pgo-gentoo.patch
blob: 4b873f99b6d6c559a140edda4483dcd3b23e819e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
--- a/build/moz.configure/lto-pgo.configure.pgo
+++ b/build/moz.configure/lto-pgo.configure
@@ -90,12 +90,16 @@ set_config("PGO_PROFILE_PATH", pgo_profi
 
 @depends(
     "--enable-profile-use",
+    c_compiler,
     pgo_profile_path,
     llvm_profdata,
     llvm_profdata_order,
     build_environment,
 )
-def orderfile_path(profile_use, path, profdata, profdata_order, build_env):
+def orderfile_path(profile_use, compiler, path, profdata, profdata_order, build_env):
+    if compiler.type == "gcc":
+        return None
+
     if not profile_use:
         return None
 
@@ -133,7 +137,7 @@ def pgo_flags(
         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"],
         )

--- a/build/pgo/profileserver.py        2025-05-26 17:14:58.234802697 +0300
+++ b/build/pgo/profileserver.py        2025-05-26 17:18:38.000686313 +0300
@@ -97,9 +97,22 @@ if __name__ == "__main__":
     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
@@ -222,16 +235,21 @@
 
         # Try to move the crash reports to the artifacts even if IceCat 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="IceCat exited successfully?") != 0:
             print("IceCat exited successfully, but produced a crashreport")
             sys.exit(1)

+        if using_gcc: 
+            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()
                 )
--- a/gfx/2d/moz.build.pgo
+++ b/gfx/2d/moz.build
@@ -135,11 +135,11 @@ if CONFIG["INTEL_ARCHITECTURE"]:
     # The file uses SSE2 intrinsics, so it needs special compile flags on some
     # compilers.
     SOURCES["BlurSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"]
-    SOURCES["ConvolutionFilterAVX2.cpp"].flags += ["-mavx2"]
+    SOURCES["ConvolutionFilterAVX2.cpp"].flags += ["-mavx2", "-fno-lto"]
     SOURCES["ConvolutionFilterSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"]
     SOURCES["FilterProcessingSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"]
     SOURCES["ImageScalingSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"]
-    SOURCES["SwizzleAVX2.cpp"].flags += ["-mavx2"]
+    SOURCES["SwizzleAVX2.cpp"].flags += ["-mavx2", "-fno-lto"]
     SOURCES["SwizzleSSE2.cpp"].flags += CONFIG["SSE2_FLAGS"]
     SOURCES["SwizzleSSSE3.cpp"].flags += CONFIG["SSSE3_FLAGS"]
 elif CONFIG["TARGET_CPU"].startswith("mips"):
--- a/gfx/skia/generate_mozbuild.py.pgo
+++ b/gfx/skia/generate_mozbuild.py
@@ -54,8 +54,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind
 if CONFIG['INTEL_ARCHITECTURE']:
     SOURCES['skia/modules/skcms/skcms.cc'].flags += ['-DSKCMS_DISABLE_SKX']
     skia_ssse3_flags = ['-Dskvx=skvx_ssse3', '-mssse3']
-    skia_avx_flags = ['-Dskvx=skvx_avx', '-mavx']
-    skia_hsw_flags = ['-Dskvx=skvx_hsw', '-mavx2', '-mf16c', '-mfma']
+    skia_avx_flags = ['-Dskvx=skvx_avx', '-mavx', '-fno-lto']
+    skia_hsw_flags = ['-Dskvx=skvx_hsw', '-mavx2', '-mf16c', '-mfma', '-fno-lto']
     SOURCES['skia/src/core/SkBitmapProcState_opts_ssse3.cpp'].flags += skia_ssse3_flags
     SOURCES['skia/src/core/SkBlitMask_opts_ssse3.cpp'].flags += skia_ssse3_flags
     SOURCES['skia/src/core/SkSwizzler_opts_ssse3.cpp'].flags += ['-Dskvx=skvx_ssse3']
--- a/gfx/skia/moz.build.pgo
+++ b/gfx/skia/moz.build
@@ -582,8 +582,8 @@ if CONFIG['MOZ_WIDGET_TOOLKIT'] == 'wind
 if CONFIG['INTEL_ARCHITECTURE']:
     SOURCES['skia/modules/skcms/skcms.cc'].flags += ['-DSKCMS_DISABLE_SKX']
     skia_ssse3_flags = ['-Dskvx=skvx_ssse3', '-mssse3']
-    skia_avx_flags = ['-Dskvx=skvx_avx', '-mavx']
-    skia_hsw_flags = ['-Dskvx=skvx_hsw', '-mavx2', '-mf16c', '-mfma']
+    skia_avx_flags = ['-Dskvx=skvx_avx', '-mavx', '-fno-lto']
+    skia_hsw_flags = ['-Dskvx=skvx_hsw', '-mavx2', '-mf16c', '-mfma', '-fno-lto']
     SOURCES['skia/src/core/SkBitmapProcState_opts_ssse3.cpp'].flags += skia_ssse3_flags
     SOURCES['skia/src/core/SkBlitMask_opts_ssse3.cpp'].flags += skia_ssse3_flags
     SOURCES['skia/src/core/SkSwizzler_opts_ssse3.cpp'].flags += ['-Dskvx=skvx_ssse3']
--- a/toolkit/components/terminator/nsTerminator.cpp.pgo
+++ b/toolkit/components/terminator/nsTerminator.cpp
@@ -332,6 +332,11 @@ void nsTerminator::StartWatchdog() {
   }
 #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());
   // crashAfterTicks is guaranteed to be > 0 as
   // crashAfterMS >= ADDITIONAL_WAIT_BEFORE_CRASH_MS >> HEARTBEAT_INTERVAL_MS
--- a/security/sandbox/linux/moz.build.1516803      2020-12-10 16:17:55.425139545 +0100
+++ b/security/sandbox/linux/moz.build      2020-12-10 16:29:21.945860841 +0100
@@ -114,9 +114,8 @@ if CONFIG["CC_TYPE"] in ("clang", "gcc")
 # gcc lto likes to put the top level asm in syscall.cc in a different partition
 # from the function using it which breaks the build.  Work around that by
 # forcing there to be only one partition.
-for f in CONFIG["OS_CXXFLAGS"]:
-    if f.startswith("-flto") and CONFIG["CC_TYPE"] != "clang":
-        LDFLAGS += ["--param lto-partitions=1"]
+if CONFIG['CC_TYPE'] != 'clang':
+    LDFLAGS += ['--param', 'lto-partitions=1']
 
 DEFINES["NS_NO_XPCOM"] = True
 DisableStlWrapping()