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
|
From fb0662b450db6b5cf8fdce36de0d261307b7fff7 Mon Sep 17 00:00:00 2001
From: Thomas Deutschmann <whissi@gentoo.org>
Date: Thu, 2 Jul 2020 18:05:03 +0200
Subject: [PATCH 25/35] Fix building with PGO when using GCC
Signed-off-by: Thomas Deutschmann <whissi@gentoo.org>
---
build/pgo/profileserver.py | 26 ++++++++++++++++++----
python/mozbuild/mozbuild/build_commands.py | 5 ++---
3 files changed, 27 insertions(+), 9 deletions(-)
diff --git a/build/pgo/profileserver.py b/build/pgo/profileserver.py
index 7f3de106ab..89289a7756 100755
--- a/build/pgo/profileserver.py
+++ b/build/pgo/profileserver.py
@@ -11,7 +11,7 @@ import glob
import subprocess
import mozcrash
-from mozbuild.base import MozbuildObject, BinaryNotFoundException
+from mozbuild.base import MozbuildObject, BinaryNotFoundException, BuildEnvironmentNotFoundException
from mozfile import TemporaryDirectory
from mozhttpd import MozHttpd
from mozprofile import FirefoxProfile, Preferences
@@ -87,9 +87,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
@@ -212,6 +225,11 @@ if __name__ == "__main__":
print("Firefox 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")
diff --git a/python/mozbuild/mozbuild/build_commands.py b/python/mozbuild/mozbuild/build_commands.py
index 688c6f4779..c937e51521 100644
--- a/python/mozbuild/mozbuild/build_commands.py
+++ b/python/mozbuild/mozbuild/build_commands.py
@@ -126,9 +126,8 @@ class Build(MachCommandBase):
return status
pgo_env = os.environ.copy()
- pgo_env["LLVM_PROFDATA"] = instr.config_environment.substs.get(
- "LLVM_PROFDATA"
- )
+ if instr.config_environment.substs.get("CC_TYPE") != "gcc":
+ pgo_env["LLVM_PROFDATA"] = instr.config_environment.substs.get("LLVM_PROFDATA")
pgo_env["JARLOG_FILE"] = mozpath.join(orig_topobjdir, "jarlog/en-US.log")
pgo_cmd = [
instr.virtualenv_manager.python_path,
--
2.29.2
|