summarylogtreecommitdiffstats
path: root/clang-profile.patch
diff options
context:
space:
mode:
authorMatt Parnell2017-02-05 21:46:04 -0600
committerMatt Parnell2017-02-05 21:46:04 -0600
commit6a88fcf5322f78d9921310480116352587dd79c8 (patch)
tree01586ff5a8ec606a42de564c1874512d39e3593a /clang-profile.patch
parent238bbcd21ebc011e6fd2f303d0ae111baf305cb2 (diff)
downloadaur-6a88fcf5322f78d9921310480116352587dd79c8.tar.gz
add pgo patch and changes; it is broken and off currently and needs further investigation
Diffstat (limited to 'clang-profile.patch')
-rw-r--r--clang-profile.patch175
1 files changed, 175 insertions, 0 deletions
diff --git a/clang-profile.patch b/clang-profile.patch
new file mode 100644
index 000000000000..978e07e3dabe
--- /dev/null
+++ b/clang-profile.patch
@@ -0,0 +1,175 @@
+# adapted from the previous patch by Matt Parnell/ilikenwf <parwok@gmail.com>
+# bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1064049
+diff --git a/build/pgo/profileserver.py b/build/pgo/profileserver.py
+index 3e5a870c33..25ef5053a7 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"
+
+@@ -88,5 +89,13 @@ 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!
++ # Matt Parnell/ilikenwf <parwok@gmail.com>
++ os.chdir(build.topobjdir)
++ os.system("/usr/bin/llvm-profdata merge -output=default.profdata *.profraw &> /dev/null")
+ finally:
+ shutil.rmtree(profilePath)
+diff --git a/js/src/old-configure.in b/js/src/old-configure.in
+index c756cd202d..ec2855cb47 100644
+--- a/js/src/old-configure.in
++++ b/js/src/old-configure.in
+@@ -1950,13 +1950,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;],
+@@ -1965,11 +1970,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=$(topobjdir)/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 202158b799..c92fdd6aa3 100644
+--- a/nsprpub/configure.in
++++ b/nsprpub/configure.in
+@@ -716,13 +716,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;],
+@@ -731,11 +736,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=$(topobjdir)/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 ada5934ec1..d9eefcb3cc 100644
+--- a/old-configure.in
++++ b/old-configure.in
+@@ -5042,13 +5042,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;],
+@@ -5057,11 +5062,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=$(topobjdir)/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)