試験運用中なLinux備忘録・旧記事

はてなダイアリーで公開していた2007年5月-2015年3月の記事を保存しています。

GNU/Linux上でFirefoxのPGOビルドとQt4ビルドを作成しようとしたが...(バージョン3.6時点)

  1. PGOビルドについて
  2. Qt4ビルド

PGOビルドについて

以前のバージョンから、2PassのビルドによるPGO(Profile-guided optimization)という最適化手法*1により動作を高速化することができるように(ビルドシステムが)なっているが、バージョン3.6の時点でもうまくいかない。以前にも試したことがあるのだがダメだった。
方法については以下を.mozconfigに追加して

mk_add_options PROFILE_GEN_SCRIPT='$(PYTHON) $(OBJDIR)/_profile/pgo/profileserver.py'

ビルド時にターゲット「profiledbuild」を指定するだけでよいのだが

[mozilla-1.9.2]$ make -f client.mk profiledbuild
(中略)
OBJDIR=/tmp/work/mozilla-1.9.2 python /tmp/work/mozilla-1.9.2/_profile/pgo/profileserver.py
INFO | automation.py | Application pid: 25300
TEST-UNEXPECTED-FAIL | automation.py | Exited with code -11 during test run
INFO | automation.py | Application ran for: 0:00:00.027888
make: *** [profiledbuild] Error 245
Command exited with non-zero status 2

[mozilla-1.9.2]$ ./dist/bin/firefox
./dist/bin/run-mozilla.sh: line 131: 25789 セグメンテーション違反です               "$prog" ${1+"$@"}

1Pass目のビルドの後の実行の段階で落ちる。原因は不明。

Qt4ビルド

ac_add_options --enable-default-toolkit=cairo-qt

を指定するとQt4ビルドができるようになっているようだったので試してみた。

In file included from gfxQPainterSurface.cpp:43:
../../../dist/system_wrappers/cairo-qpainter.h:3:33: error: cairo-qpainter.h: No such file or directory
(中略)
gfxQPainterSurface.cpp:100: error: ‘cairo_qpainter_surface_get_image’ was not declared in this scope
make[5]: *** [gfxQPainterSurface.o] Error 1

と出たので試しに

ac_add_options --enable-system-cairo

外して試してみたところ、このエラーは出なくなったが

In file included from nsWidgetFactory.cpp:48:
../../../dist/include/nsIWidget.h:713: warning: ‘virtual void nsIWidget::Scroll(const nsIntPoint&, const nsTArray<nsIntRect>&, const nsTArray<nsIWidget::Configuration>&)’ was hidden
nsWindow.h:167: warning:   by ‘void nsWindow::Scroll(const nsIntPoint&, const nsIntRect&, const nsTArray<nsIWidget::Configuration>&)’
nsWidgetFactory.cpp: In function ‘nsresult nsWindowConstructor(nsISupports*, const nsIID&, void**)’:
nsWidgetFactory.cpp:81: error: cannot allocate an object of abstract type ‘nsWindow’
nsWindow.h:103: note:   because the following virtual functions are pure within ‘nsWindow’:
../../../dist/include/nsIWidget.h:713: note:    virtual void nsIWidget::Scroll(const nsIntPoint&, const nsTArray<nsIntRect>&, const nsTArray<nsIWidget::Configuration>&)
nsWidgetFactory.cpp: In function ‘nsresult nsChildWindowConstructor(nsISupports*, const nsIID&, void**)’:
nsWidgetFactory.cpp:82: error: cannot allocate an object of abstract type ‘nsChildWindow’
nsWindow.h:360: note:   because the following virtual functions are pure within ‘nsChildWindow’:
../../../dist/include/nsIWidget.h:713: note:    virtual void nsIWidget::Scroll(const nsIntPoint&, const nsTArray<nsIntRect>&, const nsTArray<nsIWidget::Configuration>&)
nsWidgetFactory.cpp: In function ‘nsresult nsPopupWindowConstructor(nsISupports*, const nsIID&, void**)’:
nsWidgetFactory.cpp:83: error: cannot allocate an object of abstract type ‘nsPopupWindow’
nsWindow.h:369: note:   because the following virtual functions are pure within ‘nsPopupWindow’:
../../../dist/include/nsIWidget.h:713: note:    virtual void nsIWidget::Scroll(const nsIntPoint&, const nsTArray<nsIntRect>&, const nsTArray<nsIWidget::Configuration>&)
make[5]: *** [nsWidgetFactory.o] Error 1
make[5]: Leaving directory `/tmp/work/mozilla-1.9.2/widget/src/qt'

となってダメだった。バージョン3.6の時点では公式の情報として「Qt4版ビルドが作れる」と書かれていたりはしないため、まだ実験的なものなのかもしれない。
下に使用した.mozconfigを貼り付ける。

# -*- sh -*-

CC="ccache gcc"
CXX="ccache g++"

ac_add_options --enable-application=browser
ac_add_options --enable-default-toolkit=cairo-qt
ac_add_options --enable-extensions=default,-gnomevfs,-spellcheck,-python
ac_add_options --enable-image-decorders=png,gif,jpeg
ac_add_options --enable-install-strip
ac_add_options --enable-libxul
ac_add_options --enable-necko-protocols='about data file ftp http res viewsource'
ac_add_options --enable-optimize='-Os -march=native -pipe'
ac_add_options --enable-safe-browsing
ac_add_options --enable-strip
ac_add_options --enable-system-sqlite
ac_add_options --disable-accessibility
ac_add_options --disable-crashreporter
ac_add_options --disable-debug
ac_add_options --disable-debug-modules
ac_add_options --disable-gnomeui
ac_add_options --disable-gnomevfs
ac_add_options --disable-jsd
ac_add_options --disable-logging
ac_add_options --disable-installer
ac_add_options --disable-mathml
ac_add_options --disable-necko-wifi
ac_add_options --disable-official-branding
ac_add_options --disable-parental-controls
ac_add_options --disable-tests
ac_add_options --disable-updater
ac_add_options --with-system-bz2
ac_add_options --with-system-jpeg
ac_add_options --with-system-png
ac_add_options --with-system-zlib

(2010/4/1)Maxwell氏にコメント欄にパッチを頂き、これを適用することでQt4版のビルドができることを確認した(使用したFirefoxのバージョンは3.6.2)。ただ、コメント欄でdiffの記述がズレているため、手動でパッチ適用した後で差分を取り直し、これをgzip圧縮+Base64エンコードしたものを以下に貼り付ける。
[引用][任意]ファイル名: firefox-3.6.2-qt4.patch.gz.b64

H4sIAPubtEsCA6VUXW/TMBR9z6+4vEBKvtjQytaOUVinUQGjtJ32gBCyEie2SO3OdloK2n/Hjpum
q9YtFX7Ita17jnOPfU9C0xSCQsCU/6F5joKD8CQ8DLmgWbSgSYZVJEUc3aqIyRvKEr4I49nsfvYj
iU4QBPtRO57nNafv9SBot4/9N+DZ0Os54MCc08SBKrPTGceC57kbcyaV3h4wNeSUqeeA+jhXyHcC
2B4buSMcm9QxL0SMfcfbmTt5LwRanq5BZ+UBspxL34EGwJuy1k7nnLOUZoVAinJmeO5tyJYDfy0f
TcF9NrWwlt4sFTk58o+1IjoctEtJqnHnVMGW/M38Ggj9cVf1hb/9qtRwWU/1HShSLwmmGVGtrmVZ
HR+cSauzVbVksjNNZM7Q+aV4UQR9DggkndIcCVCEsgwUhwVBCqiEhDMMlMHl5BPY2weJVbhGX8wx
0yheZASoeiE114KLX0jwgiWQCj4FnicG/s5iUi7c4eha3/nrQ6DwFl51dTjduJ7wM2aZIm6rC55H
jZLeU09B09T47/SHrq4G/beya6Z91b0zv2HvuXo0+JzQPBGYudvvqGvaZaXqmPCFltu0jFY0Q5SF
Yegk+zsEadbAZE93IM29gZR9cNA+Ms5gw2Yb7B7D0QfO82qFBnK8ZDERnPGiFMuMq/HPwZeLycev
/TXsepYghd0qw/jPFvEuC3rIex41oocMqKEb+U8p0NiP6nczp0IVKC9LfmlZLrG60nlz3EcK1W2H
zHKynGEN/gc8A+UfdwYAAA==

以下適用作業例。

$ tar jxf [firefox-3.6.2.source.tar.bz2の場所]
$ cd mozilla-1.9.2/
[mozilla-1.9.2]$ base64 -d [上の内容のテキストファイル] | gunzip | patch -p1
patching file widget/src/qt/nsWindow.cpp
patching file widget/src/qt/nsWindow.h
(以下ビルドの流れへ続く)

ただ、表示に怪しい部分が結構あり、安定しているとは言えないかもしれない(ビルド設定に問題がある可能性もあるが...)。

使用したバージョン:

*1:「1Pass目で動作情報を出力するための実行形式を作成し、その後実際に実行ファイルを動かして動作情報を書き出して2Pass目でそれを用いて最適化する」という形をとり、その「動かし方」に最適化した実行形式を最終的に出力する