firefox pgo


SUBMITTED BY: Guest

DATE: Nov. 21, 2012, 5:10 p.m.

FORMAT: Bash

SIZE: 14.3 kB

HITS: 1914

  1. #!/bin/sh
  2. # This script is POSIX compliant and comes with no warranty.
  3. # Tune it up or otherwise adjust as you see fit.
  4. # By Sasha - Jan 22 2010
  5. # My gcc used = 4.3.3
  6. #
  7. # PGO (Profile Guided Optimization) Firefox build
  8. # for 64bit Slackware 13.0
  9. # Works for me with FF 3.6 (freshly released Jan 22/2010)
  10. # Script based on Slackware 13/64 SlackBuild and other
  11. # examples from here and there, including mozilla.org.
  12. #
  13. # This whole build is a multi-stage clobber-build
  14. # which takes the better part of 1.5 hours, including
  15. # time spent playing with the half-built browser half
  16. # way through the build to generate profiling info.
  17. #
  18. # FF 3.6 build depends on libnotify from Galago and
  19. # some junk from your Wireless Tools package (yes, wtf?!)
  20. # BEGIN:
  21. # First, see that we aren't root, because we _are_ going to
  22. # fire up the new browser half-way through the build, to generate
  23. # some profiling information. Don't wanna browse as root, and
  24. # also, root is not allowed to connect to the X server by
  25. # default, so the build will fail when the browser cannot be started.
  26. echo "Checking UID and file ownership.."
  27. if [ $(id -u) = 0 ]; then
  28. echo "You should not do this as root."
  29. echo "Please change to another UID before running this script."
  30. exit 1
  31. else
  32. # ensure everything is our UID:GID or quit
  33. # (in case any of it is root owned)
  34. if [ "$(chown -R $(id -u):$(id -g) ./* 2>&1 >/dev/null)" ]; then
  35. echo "Stuff in here is not chownable to our UID:GID."
  36. echo "Please fix it and run this script again."
  37. exit 1
  38. fi;
  39. fi;
  40. # my favorite compiler optimizations:
  41. #CFLAGS="-fPIC -O3 -Wall -pipe -march=native -mtune=native -fomit-frame-pointer"
  42. #I read O2 is often faster. so...
  43. CFLAGS="-fPIC -O2 -Wall -pipe -march=native -mtune=native -fomit-frame-pointer"
  44. CXXFLAGS="${CFLAGS}"
  45. CPPFLAGS="${CFLAGS} -I/usr/include"
  46. MAKEFLAGS="-j4"
  47. # FF apparently won't build properly with autoconf != 2.13 so
  48. # in case this is still the case, I installed autoconf 2.13 in
  49. # /usr/local/bin and this PATH makes it be found first, before
  50. # my regular autoconf 2.6:
  51. PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:.
  52. export PATH CPPFLAGS CXXFLAGS CFLAGS MAKEFLAGS
  53. CWD=$(pwd) # where am I now (start base dir)
  54. TMP=$CWD/temp # a slackpkg will be constructed in here.
  55. LIBDIR=lib64 # slack64 libdir.
  56. SRCDIR=$CWD/SOURCE # FF source dir.
  57. OBJDIR=$CWD/OBJDIR # build dest dir.
  58. PKGDIR=$CWD/PGO_FINISHED_PROD # slack package or tarball ends up in here.
  59. PROFIL=$CWD/_PROFILEPROFILE # PGO profile folder
  60. # (stick your places.sqlite in there if you want)
  61. MOZAPP=browser # in mozconfig, which mozilla component to build
  62. APP=firefox # self evident.
  63. VERSION=17.0 # self evident.
  64. EXTENSION=en-US.linux # FF tarball name includes this piece.
  65. # but may change depending on your locale.
  66. ARCH=x86_64 # architecture.
  67. BUILD=1mps #
  68. PYTHON=/usr/bin/python
  69. # Download all the parts here?
  70. # make sure we have all the necessary pieces for
  71. # creating a slackpackage, and the source archive too:
  72. for i in firefox.png mimeTypes.rdf.gz firefox.moz_plugin_path.diff.gz \
  73. mozilla-firefox.desktop slack-desc $APP-$VERSION.source.tar.bz2; do
  74. if [ ! -f "$CWD/$i" ]; then
  75. echo "Error: $CWD/$i missing. Get it somewhere and try again."
  76. exit 1
  77. fi;
  78. done
  79. # clean away old build dirs and make fresh ones:
  80. rm -Rf $SRCDIR $OBJDIR $TMP $PKGDIR
  81. mkdir -p $SRCDIR $OBJDIR $PROFIL $TMP $PKGDIR
  82. # run-script.sh ##################################################
  83. # create the app startup script for profile generation:
  84. cat << EOF > run-$APP.sh
  85. #!/bin/sh
  86. NO_EM_RESTART=1
  87. DISPLAY=:0.0
  88. export NO_EM_RESTART DISPLAY
  89. $OBJDIR/dist/bin/$APP -no-remote -profile $PROFIL
  90. EOF
  91. chmod a+x run-$APP.sh
  92. # /run-script.sh ##################################################
  93. # extract the FF source tar.bz2 into $SRCDIR..
  94. echo "Extracting source.."
  95. cd $SRCDIR
  96. tar xvf $CWD/$APP-$VERSION.source.tar.bz2 || exit 1
  97. sync
  98. SRCDIR=$(pwd)/$(ls)
  99. cd $SRCDIR || exit 1
  100. #/usr/local/bin/autoreconf || exit 1
  101. # Enable x86_64 Tracemonkey Support
  102. # FIXME: deprecated? there is no ENABLE_JIT anymore...
  103. #patch $SRCDIR/js/src/configure.in < $CWD/enable-x86_64-tracemonkey.patch || exit 1
  104. # Pat Volkerding says:
  105. # Fix a long standing bug that's prevented staying current on GTK+.
  106. # Thanks to the BLFS folks. :-)
  107. cat << EOF >> layout/build/Makefile.in
  108. ifdef MOZ_ENABLE_CANVAS
  109. EXTRA_DSO_LDOPTS += \$(XLDFLAGS) -lX11 -lXrender
  110. endif
  111. EOF
  112. # mozconfig #######################################################
  113. # and create our mozconfig in $SRCDIR:
  114. cat << EOF > mozconfig
  115. # FF PGO-build mozconfig file
  116. # option to say use objdir (build dir):
  117. mk_add_options MOZ_OBJDIR=$OBJDIR
  118. # startup script, for generating profile info for optimize:
  119. #mk_add_options PROFILE_GEN_SCRIPT=$CWD/run-$APP.sh
  120. # Automated script; comment this and uncomment the above for a manual script
  121. mk_add_options PROFILE_GEN_SCRIPT='${PYTHON} ${OBJDIR}/_profile/pgo/profileserver.py'
  122. # which mozilla app to build:
  123. ac_add_options --enable-application=$MOZAPP
  124. ########################################: Stuff that always worked:
  125. ###################### (mostly) stuff from the -current slackbuild:
  126. ac_add_options --enable-official-branding
  127. ac_add_options --prefix=/usr --libdir=/usr/$LIBDIR
  128. ac_add_options --host="x86_64-slackware-linux-gnu"
  129. ac_add_options --with-default-mozilla-five-home=/usr/$LIBDIR/$APP-$VERSION
  130. ac_add_options --with-system-zlib
  131. ac_add_options --enable-default-toolkit=cairo-gtk2
  132. ac_add_options --enable-crypto
  133. ac_add_options --enable-svg
  134. ac_add_options --enable-canvas
  135. ac_add_options --enable-xft
  136. ac_add_options --enable-webm
  137. ac_add_options --enable-xinerama
  138. ac_add_options --enable-optimize="-fPIC -O2 -Wall -pipe -march=native -mtune=native -fomit-frame-pointer" #not needed? cflags etc? was Os...?hmm
  139. ac_add_options --enable-reorder
  140. ac_add_options --enable-strip
  141. #ac_add_options --enable-system-cairo #breaks build (https://bugzilla.mozilla.org/show_bug.cgi?id=722975)
  142. ac_add_options --enable-cpp-rtti
  143. ac_add_options --enable-single-profile
  144. ac_add_options --disable-ldap
  145. ac_add_options --disable-accessibility
  146. ac_add_options --disable-debug
  147. ac_add_options --disable-tests
  148. ac_add_options --disable-logging
  149. ac_add_options --disable-pedantic
  150. ac_add_options --disable-installer
  151. ac_add_options --disable-mailnews
  152. ac_add_options --disable-composer
  153. ac_add_options --disable-profilesharing
  154. # End official slackbuild opts
  155. ########################################: stuff I'm 98% sure always works:
  156. ac_add_options --with-gxx-include-dir=/usr/include/c++/4.7.1
  157. ac_add_options --quiet
  158. ac_add_options --with-system-bz2
  159. ac_add_options --with-pthreads
  160. ac_add_options --enable-threads=posix
  161. ac_add_options --enable-system-lcms
  162. ac_add_options --disable-system-sqlite #enable breaks build in packaging state...
  163. ac_add_options --enable-pango
  164. ac_add_options --enable-install-strip
  165. ac_add_options --disable-updater
  166. ac_add_options --disable-gnomeui
  167. ac_add_options --disable-gnomevfs
  168. ########################################: stuff I'm 95% sure works fine:
  169. #ac_add_options --enable-libxul
  170. #ac_add_options --with-system-jpeg
  171. #ac_add_options --with-system-nssac_add_options
  172. ac_add_options --disable-crashreporter
  173. ac_add_options --disable-help-viewer
  174. ac_add_options --disable-debug-modules
  175. ac_add_options --disable-debugger-info-modules
  176. ac_add_options --disable-parental-controls
  177. ac_add_options --disable-safe-browsing
  178. ac_add_options --disable-startup-notification
  179. ########################################: Completely Experimental below..
  180. ########################################: Questionable/Optional stuff
  181. ########################################: that may, or just may not work:
  182. #ac_add_options --enable-javaxpcom
  183. #ac_add_options --enable-oji
  184. #ac_add_options --enable-xpcom-fastload
  185. #ac_add_options --enable-plugins
  186. #ac_add_options --enable-jemalloc
  187. #ac_add_options --enable-mathml
  188. #ac_add_options --disable-xpcom-obsolete
  189. #ac_add_options --enable-svg-foreignobject
  190. # ac_add_options --enable-chrome-format=jar
  191. # ac_add_options --enable-native-uconv # not needed/not recommended
  192. # ac_add_options --enable-image-encoders=all # should not need
  193. # ac_add_options --enable-update-channel=release # needed by moz.org people only?
  194. # ac_add_options --enable-prebinding # OSX only?
  195. # ac_add_options --enable-reflow-perf # try without.. may slow down FF for non-devel user?
  196. ac_add_options --enable-glitz # this thing won't install into lib64
  197. # END of mozconfig file
  198. EOF
  199. # /mozconfig #######################################################
  200. # configure the sources:
  201. cd $OBJDIR
  202. echo ; echo "Info: Running configure in 5" ; sleep 5
  203. $SRCDIR/configure || exit 1
  204. # make the sources:
  205. cd $SRCDIR
  206. #disabled because would not produce a real pgo build!
  207. #see bottom: https://groups.google.com/forum/?fromgroups=#!topic/mozilla.dev.builds/VeR2zDtQ0qM
  208. #echo ; echo "Info: Starting non-PGO build in 5" ; sleep 5
  209. #make -s -f client.mk build MOZ_MAKE_FLAGS="${MAKEFLAGS}" || exit 1
  210. # make PGO build in same objdir, on top of what's already built:
  211. #echo ; echo "Info: Done non-PGO build... Continuing in 5" ; sleep 5
  212. make -s -f client.mk profiledbuild MOZ_MAKE_FLAGS="${MAKEFLAGS}" || exit 1
  213. # Here is when the profiling build should fire up. Use it for a while,
  214. # do some browsing, give it a hard time; sometimes a bad build will
  215. # run for 5, 10 or 15 minutes until it hits a snag, bug, segfault
  216. # or whatever, so you want to make it happen NOW, not when you've
  217. # got 25 tabs open tomorrow and the whole thing locks up on you.
  218. # When you're done, and confident that the browser is stable,
  219. # click File->Quit and the build will resume.
  220. # OPTIONS HERE (functions):
  221. make_tarball () {
  222. # make tarball: This makes a generic tarball of the newly
  223. # compiled Firefox and related components, and zips it up
  224. # into a bzip2 archive. You can then do what you like with
  225. # it, such as install it manually, or just unpack it somewhere
  226. # and use it as-is.
  227. # Package it into a tarball to fix symlinks & gather all pieces:
  228. ( cd $OBJDIR
  229. echo ; echo "Info: Packaging tarball in 5" ; sleep 5
  230. make package ) || exit 1
  231. #move tarball to $CWD (start directory)
  232. ( cd $PKGDIR
  233. cp -fvt . $OBJDIR/dist/$APP-$VERSION.$EXTENSION-$ARCH.tar.bz2
  234. ) || exit 1
  235. cd $CWD
  236. # Now do what you want with the finished tarball in $PKGDIR.
  237. }
  238. # 2) make slackpkg:
  239. make_slackpkg () {
  240. # make a slackware package according to the general idea
  241. # of what happens in the Slack13.0/64 SlackBuild script:
  242. ( cd $OBJDIR
  243. echo ; echo "Info: Creating slackpkg dir structure in 5" ; sleep 5
  244. make install DESTDIR=$TMP
  245. # We don't need these things:
  246. rm -Rf $TMP/usr/$LIBDIR/$APP-devel-$VERSION
  247. rm -Rf $TMP/usr/include
  248. )
  249. #useless
  250. #fails mimeTypes, plugin_path useless since 7.x
  251. #( cd $TMP/usr/$LIBDIR/$APP-$VERSION
  252. # zcat $CWD/mimeTypes.rdf > defaults/profile/mimeTypes.rdf || exit 1
  253. # zcat $CWD/firefox.moz_plugin_path.diff.gz \
  254. # | sed -e "s#usr/lib#usr/$LIBDIR#g" \
  255. # | patch -p1 --verbose --backup --suffix=.orig || exit 1
  256. # # Clean up if the above patch was successful:
  257. # # On my system, that patch is successful, but a bit fuzzy :/
  258. # rm -f firefox.orig
  259. #) || exit 1
  260. mkdir -p $TMP/usr/$LIBDIR/mozilla/plugins
  261. mkdir -p $TMP/usr/share/applications
  262. cat $CWD/mozilla-$APP.desktop > $TMP/usr/share/applications/mozilla-$APP.desktop
  263. mkdir -p $TMP/usr/share/pixmaps
  264. cat $CWD/$APP.png > $TMP/usr/share/pixmaps/$APP.png
  265. # These files/directories are usually created if Firefox is run
  266. # as root which technically should be never. Anyhow, if we don't
  267. # see these items, put stubbies in place (whatever those are) to
  268. # prevent startup errors:
  269. ( cd $TMP/usr/$LIBDIR/$APP-$VERSION
  270. if [ -d extensions/talkback\@mozilla.org ]; then
  271. if [ ! -r extensions/talkback\@mozilla.org/chrome.manifest ]; then
  272. echo > extensions/talkback\@mozilla.org/chrome.manifest
  273. fi
  274. fi
  275. if [ ! -d updates ]; then
  276. mkdir -p updates/0
  277. fi
  278. )
  279. # Install icons/imgs/license/slack-desc:
  280. mkdir -p $TMP/usr/$LIBDIR/$APP-$VERSION/chrome/icons/default
  281. install -m 644 $SRCDIR/browser/branding/official/default16.png $TMP/usr/$LIBDIR/$APP-$VERSION/icons/
  282. install -m 644 $SRCDIR/browser/branding/official/default16.png $TMP/usr/$LIBDIR/$APP-$VERSION/chrome/icons/default/
  283. install -p -c -m 644 $SRCDIR/LICENSE $TMP/usr/$LIBDIR/$APP-$VERSION/
  284. mkdir $TMP/install
  285. cat $CWD/slack-desc > $TMP/install/slack-desc
  286. if [ -e $TMP/usr/share/idl/$APP-$VERSION/.mkdir.done ]; then
  287. rm -f $TMP/usr/share/idl/$APP-$VERSION/.mkdir.done
  288. fi
  289. cd $TMP
  290. # whip up the Slackpackage:
  291. echo "Ready to zip up the slackpkg."
  292. echo "1) su to root."
  293. echo "2) Make sure you are in this folder: $TMP"
  294. echo "3) Now, as root, type:"
  295. echo "chown -R root:root ."
  296. echo "makepkg -l y -c y $PKGDIR/mozilla-$APP-$VERSION-$ARCH-$BUILD.txz"
  297. } # end of make_slackpkg()
  298. #NOTE: Below here, uncomment whichever function-call you
  299. # plan to use: either "make_slackpkg" or "make_tarball"
  300. # You can probably do both if you have some reason to do so..
  301. #make_tarball
  302. make_slackpkg
  303. #EOF

comments powered by Disqus