summarylogtreecommitdiffstats
path: root/clang-profile.patch
blob: caeb402561b6e0de5c723b4139963ddc487b946a (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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
diff --git a/build/pgo/profileserver.py b/build/pgo/profileserver.py
index 3e5a870c33d3..140f6f9c7de3 100644
--- a/build/pgo/profileserver.py
+++ b/build/pgo/profileserver.py
@@ -37,7 +37,7 @@ if __name__ == '__main__':
 
   #TODO: mozfile.TemporaryDirectory
   profilePath = tempfile.mkdtemp()
-  try:
+  try:	
     #TODO: refactor this into mozprofile
     prefpath = os.path.join(build.topsrcdir, "testing", "profiles", "prefs_general.js")
     prefs = {}
@@ -53,6 +53,7 @@ if __name__ == '__main__':
                              locations=locations)
 
     env = os.environ.copy()
+    env["LLVM_PROFILE_FILE"] = "runpid-%p.profraw" # clang can hit naming conflicts if we don't do this
     env["MOZ_CRASHREPORTER_NO_REPORT"] = "1"
     env["XPCOM_DEBUG_BREAK"] = "warn"
 
@@ -72,7 +73,7 @@ if __name__ == '__main__':
                            binary=build.get_binary_path(where="staged-package"),
                            cmdargs=['javascript:Quitter.quit()'],
                            env=env)
-    runner.start()
+    runner.start(outputTimeout=60) # allow up to 60 seconds to start and create a profile
     runner.wait()
 
     jarlog = os.getenv("JARLOG_FILE")
@@ -88,5 +89,15 @@ if __name__ == '__main__':
     runner.start(debug_args=debug_args, interactive=interactive)
     runner.wait()
     httpd.stop()
+    
+    # this is hacky but should build our profdata for use, at least for the main browser...not the other stuff
+    # i'm not super up on the current state of the mozilla build system so for other profraws and other profdata
+    # generated, and for this, it'd be nice to properly get an llvm-profdata search in configure
+    # and properly add it to the flow... just proof of concept for me - halp please!
+    # also, wouldn't it make sense to add an argument to copy an actual user profile, 
+    # and start up on the blank tab page when possible for a more real-world loadup? todo?
+    # Matt Parnell/ilikenwf <parwok@gmail.com>
+    os.chdir(build.topobjdir)
+    os.system("llvm-profdata merge -output=/tmp/default.profdata *.profraw &> /dev/null")
   finally:
     shutil.rmtree(profilePath)
diff --git a/js/src/old-configure.in b/js/src/old-configure.in
index 70b6a7dc7af9..832010150cab 100644
--- a/js/src/old-configure.in
+++ b/js/src/old-configure.in
@@ -1823,13 +1823,18 @@ else
 fi
 
 dnl ========================================================
-dnl Profile guided optimization (gcc checks)
+dnl Profile guided optimization (gcc/clang checks)
 dnl ========================================================
 dnl Test for profiling options
-dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
+dnl Under gcc 3.4+ and clang use -fprofile-generate/-fprofile-use
 
 _SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
+
+if test -n "${CLANG_CC}"; then
+	CFLAGS="$CFLAGS -fprofile-generate"
+else
+	CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
+fi
 
 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
 AC_TRY_COMPILE([], [return 0;],
@@ -1838,11 +1843,15 @@ AC_TRY_COMPILE([], [return 0;],
 AC_MSG_RESULT([$result])
 
 if test $result = "yes"; then
-  PROFILE_GEN_LDFLAGS="-fprofile-generate"
-  PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
-  PROFILE_USE_LDFLAGS="-fprofile-use"
+	if test -n "${CLANG_CC}"; then
+		PROFILE_GEN_CFLAGS="-fprofile-generate"
+		PROFILE_USE_CFLAGS='-fprofile-instr-use=/tmp/default.profdata'
+	else
+		PROFILE_GEN_LDFLAGS="-fprofile-generate"
+		PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
+		PROFILE_USE_LDFLAGS="-fprofile-use"
+    fi
 fi
-
 CFLAGS="$_SAVE_CFLAGS"
 
 AC_SUBST(PROFILE_GEN_CFLAGS)
diff --git a/nsprpub/configure.in b/nsprpub/configure.in
index 22b4e72245d1..1f565e79d300 100644
--- a/nsprpub/configure.in
+++ b/nsprpub/configure.in
@@ -750,13 +750,18 @@ else
 fi
 
 dnl ========================================================
-dnl Profile guided optimization
+dnl Profile guided optimization (gcc/clang checks)
 dnl ========================================================
 dnl Test for profiling options
-dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
+dnl Under gcc 3.4+ and clang use -fprofile-generate/-fprofile-use
 
 _SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
+
+if test -n "${CLANG_CC}"; then
+	CFLAGS="$CFLAGS -fprofile-generate"
+else
+	CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
+fi
 
 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
 AC_TRY_COMPILE([], [return 0;],
@@ -765,11 +770,15 @@ AC_TRY_COMPILE([], [return 0;],
 AC_MSG_RESULT([$result])
 
 if test $result = "yes"; then
-   PROFILE_GEN_LDFLAGS="-fprofile-generate"
-   PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
-   PROFILE_USE_LDFLAGS="-fprofile-use"
+	if test -n "${CLANG_CC}"; then
+		PROFILE_GEN_CFLAGS="-fprofile-generate"
+		PROFILE_USE_CFLAGS='-fprofile-instr-use=/tmp/default.profdata'
+	else
+		PROFILE_GEN_LDFLAGS="-fprofile-generate"
+		PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
+		PROFILE_USE_LDFLAGS="-fprofile-use"
+    fi
 fi
-
 CFLAGS="$_SAVE_CFLAGS"
 
 dnl ===============================================================
diff --git a/old-configure.in b/old-configure.in
index 662d77aaf99f..1ef312e22e6b 100644
--- a/old-configure.in
+++ b/old-configure.in
@@ -4213,13 +4213,18 @@ else
 fi
 
 dnl ========================================================
-dnl Profile guided optimization (gcc checks)
+dnl Profile guided optimization (gcc/clang checks)
 dnl ========================================================
 dnl Test for profiling options
-dnl Under gcc 3.4+, use -fprofile-generate/-fprofile-use
+dnl Under gcc 3.4+ and clang use -fprofile-generate/-fprofile-use
 
 _SAVE_CFLAGS="$CFLAGS"
-CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
+
+if test -n "${CLANG_CC}"; then
+	CFLAGS="$CFLAGS -fprofile-generate"
+else
+	CFLAGS="$CFLAGS -fprofile-generate -fprofile-correction"
+fi
 
 AC_MSG_CHECKING([whether C compiler supports -fprofile-generate])
 AC_TRY_COMPILE([], [return 0;],
@@ -4228,11 +4233,15 @@ AC_TRY_COMPILE([], [return 0;],
 AC_MSG_RESULT([$result])
 
 if test $result = "yes"; then
-  PROFILE_GEN_LDFLAGS="-fprofile-generate"
-  PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
-  PROFILE_USE_LDFLAGS="-fprofile-use"
+	if test -n "${CLANG_CC}"; then
+		PROFILE_GEN_CFLAGS="-fprofile-generate"
+		PROFILE_USE_CFLAGS='-fprofile-instr-use=/tmp/default.profdata'
+	else
+		PROFILE_GEN_LDFLAGS="-fprofile-generate"
+		PROFILE_USE_CFLAGS="-fprofile-use -fprofile-correction -Wcoverage-mismatch"
+		PROFILE_USE_LDFLAGS="-fprofile-use"
+    fi
 fi
-
 CFLAGS="$_SAVE_CFLAGS"
 
 AC_SUBST(PROFILE_GEN_CFLAGS)