半分は成功と言えるのかしら?という状況です。
きっかけは
Ubuntu がパッケージのビルド時に x86_64_v3 を指定しようとしているらしく、ちょっとしたテスト結果も掲載されてなるほどと思ったのです。
Trying out Ubuntu 23.04 on x86-64-v3 rebuild for yourself - Foundations - Ubuntu Community Hub
ただ、テスト内容が 7zip と OpenJDK のビルドであったため、デスクトップ利用の目線だと効果があるのかないのかよくわからなかったため、愛用している Firefox を自前でビルドしてコンパイルオプションの違いを確認してみようと思ったわけです。
まずは準備
Firefox の自前ビルドはこちらの手順を参考にしてみました。
必要なツールをインストールして、ソースコードをダウンロードして、いざコンパイルという流れなのは認識していたので、だいたいそんな手順になっていました。
curl、python3、python3-pip が必要とのことで、だいたいインストール済みだと思われるので、足りないものを確認しながら進めてみました。環境は LMDE 6(Debian 12 ベース)です。
$ curl --version curl 7.88.1 (x86_64-pc-linux-gnu) libcurl/7.88.1 OpenSSL/3.0.11 zlib/1.2.13 brotli/1.0.9 zstd/1.5.4 libidn2/2.3.3 libpsl/0.21.2 (+libidn2/2.3.3) libssh2/1.10.0 nghttp2/1.52.0 librtmp/2.3 OpenLDAP/2.5.13 Release-Date: 2023-02-20 Protocols: dict file ftp ftps gopher gophers http https imap imaps ldap ldaps mqtt pop3 pop3s rtmp rtsp scp sftp smb smbs smtp smtps telnet tftp Features: alt-svc AsynchDNS brotli GSS-API HSTS HTTP2 HTTPS-proxy IDN IPv6 Kerberos Largefile libz NTLM NTLM_WB PSL SPNEGO SSL threadsafe TLS-SRP UnixSockets zstd
curl はインストール済みでした。
$ python3 --version Python 3.11.2
python3 もインストール済みでした。
$ python3-pip --version コマンド 'python3-pip' が見つかりません。もしかして: command 'python3-pie' from deb python3-nopie 次を試してみてください: sudo apt install
python3-pip は未インストールでした。
python3-pip をインストール後、手順に従い mercurial をインストールしてみます。
$ python3 -m pip install --user mercurial error: externally-managed-environment × This environment is externally managed ╰─> To install Python packages system-wide, try apt install python3-xyz, where xyz is the package you are trying to install. If you wish to install a non-Debian-packaged Python package, create a virtual environment using python3 -m venv path/to/venv. Then use path/to/venv/bin/python and path/to/venv/bin/pip. Make sure you have python3-full installed. If you wish to install a non-Debian packaged Python application, it may be easiest to use pipx install xyz, which will manage a virtual environment for you. Make sure you have pipx installed. See /usr/share/doc/python3.11/README.venv for more information. note: If you believe this is a mistake, please contact your Python installation or OS distribution provider. You can override this, at the risk of breaking your Python installation or OS, by passing --break-system-packages. hint: See PEP 668 for the detailed specification.
おや、失敗しますね。
どうも Debian は野良パッケージ的なものをインストールしようとすると警告してくるようです。Debian 12 に mercurial のパッケージが用意されていたので、そちらをインストールしました。
$ hg version Mercurial - 分散構成管理ツール(バージョン 6.3.2) (詳細は https://mercurial-scm.org を参照) Copyright (C) 2005-2023 Olivia Mackall and others This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
mercurial のインストール確認コマンドが正常終了しました。
道具が揃ったので次はソースコードのダウンロードです。ちょっと時間がかかるとは思っていましたが 1時間ほどかかりました。時間がある時にやりましょう。
$ curl https://hg.mozilla.org/mozilla-central/raw-file/default/python/mozboot/bin/bootstrap.py -O python3 bootstrap.py % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 15058 100 15058 0 0 5481 0 0:00:02 0:00:02 --:--:-- 5481 Cloning into mozilla-unified using Mercurial... Destination directory for clone (leave empty to use default destination of mozilla-unified): Cloning Firefox Mercurial repository to /mnt/DATA/myff/mozilla-unified https://hg.mozilla.org/mozilla-unified から取り込み中 clone 用バンドルファイル https://hg.cdn.mozilla.net/mozilla-unified/b3a01fc56cb4969d6bafc98daea7ffdf03c0da3e.zstd-max.hg を適用中 リビジョンを追加中 マニフェストを追加中 ファイルの変更を追加中 768735 個のリビジョン(4932082 の変更を 732119 ファイルに適用)を追加 (+15個のヘッド) clone 用バンドルファイルの適用完了 変更点を探索中 リビジョンを追加中 マニフェストを追加中 ファイルの変更を追加中 連携先での新規ブックマーク aurora を追加中 連携先での新規ブックマーク autoland を追加中 連携先での新規ブックマーク beta を追加中 連携先での新規ブックマーク central を追加中 連携先での新規ブックマーク esr10 を追加中 連携先での新規ブックマーク esr102 を追加中 連携先での新規ブックマーク esr115 を追加中 連携先での新規ブックマーク esr17 を追加中 連携先での新規ブックマーク esr24 を追加中 連携先での新規ブックマーク esr31 を追加中 連携先での新規ブックマーク esr38 を追加中 連携先での新規ブックマーク esr45 を追加中 連携先での新規ブックマーク esr52 を追加中 連携先での新規ブックマーク esr60 を追加中 連携先での新規ブックマーク esr68 を追加中 連携先での新規ブックマーク esr78 を追加中 連携先での新規ブックマーク esr91 を追加中 連携先での新規ブックマーク fx-team を追加中 連携先での新規ブックマーク inbound を追加中 連携先での新規ブックマーク release を追加中 4 個のリビジョン(25 の変更を 25 ファイルに適用)を追加 新規リビジョン範囲 29d1fcf68fc0:58e62af2d7c2 768735 local changesets published (作業領域の更新は 'hg update') updating to "central" - the development head of Gecko and Firefox (warning: large working directory being used without fsmonitor enabled; enable fsmonitor to improve performance; see "hg help -e fsmonitor") ファイルの更新数 353503、 マージ数 0、 削除数 0、 衝突未解消数 0 (ブックマーク central をアクティブ化中) Clone complete. Note on Artifact Mode: Artifact builds download prebuilt C++ components rather than building them locally. Artifact builds are faster! Artifact builds are recommended for people working on Firefox or Firefox for Android frontends, or the GeckoView Java API. They are unsuitable for those working on C++ code. For more information see: https://firefox-source-docs.mozilla.org/contributing/build/artifact_builds.html. Please choose the version of Firefox you want to build (see note above): 1. Firefox for Desktop Artifact Mode [default] 2. Firefox for Desktop 3. GeckoView/Firefox for Android Artifact Mode 4. GeckoView/Firefox for Android 5. SpiderMonkey JavaScript engine Your choice: 1 Mozilla collects data to improve the developer experience. To learn more about the data we intend to collect, read here: https://firefox-source-docs.mozilla.org/build/buildsystem/telemetry.html If you have questions, please ask in #build on Matrix: https://chat.mozilla.org/#/room/#build:mozilla.org If you'd like to opt out of data collection, select (N) at the prompt. Would you like to enable build system telemetry? (Yn): Your requested configuration has been written to "/mnt/DATA/myff/mozilla-unified/mozconfig". Your system should be ready to build Firefox for Desktop Artifact Mode! To build Firefox for Desktop Artifact Mode, please restart the shell (Start a new terminal window)
データのダウロードだけではなく mercurial のリポジトリ?みたいなものも作成するようです。圧縮されたデータを伸張したりとけっこう CPU も使います。
途中で色々と確認される部分がありましたが、とりあえず Yes を応答してやり過ごしました。
Artifact Mode を選択しましたが、コンパイルオプションを変えるのであれば「2. Firefox Desktop」が良かったのかも、とちょっと後悔しました。
(Artifact Mode だと一部の資源がコンパイル済みでダウロードされるそうです)
また、central だと Firefox Nightly のソースコードがダウロードされます。stable のソースが良かったんですが、どこで指定するのかわかりませんでした。
いざコンパイル
さあ、ようやくコンパイルする準備が整ったので、コンパイルしてみましょう。
$ ./mach build 1:30.28 ./ServoCSSPropList.py.stub 1:32.17 ./source-repo.h.stub 1:32.17 ./buildid.h.stub 1:32.79 ./application.ini.stub 1:35.10 Packaging specialpowers@mozilla.org.xpi... 1:35.38 Packaging mozscreenshots@mozilla.org.xpi... 1:35.49 W 0 compiler warnings present. 1:35.77 W Overall system resources - Wall time: 95s; CPU: 9%; Read bytes: 29999104; Write bytes: 1002868736; Read time: 21780; Write time: 43180 To view a profile of the build, run |mach resource-usage|. 1:35.77 Your build was successful! To take your build for a test drive, run: |mach run| For more information on what to do now, see https://firefox-source-docs.mozilla.org/setup/contributing_code.html
すんなりとコンパイルできてしまいました。./mach run で Firefox を起動することができます。
大成功です。
気になるコンパイルオプションを確認してみましょう。
ふぁ?なんですかこのすっからかんの about:buildconfig の画面は。やはり Artifact Mode を選択してしまったのが失敗だったのでしょうか。
う〜ん、コンパイルオプションを変えるともうちょっと情報を表示してくれますかね。mozconfig というファイルにいろいろと指定ができるみたいです。
$ cat mozconfig # Automatically download and use compiled C++ components: ac_add_options --enable-artifact-builds
初期状態では --enable-artifact-builds だけが指定されていましたが、ここに --enable-optimize を追加してみます。
$ cat mozconfig # Automatically download and use compiled C++ components: ac_add_options --enable-artifact-builds ac_add_options --enable-optimize
これでどうだ。もう一度、./mach build です。
$ ./mach build 0:00.52 W Clobber not needed. /mnt/DATA/myff/mozilla-unified/obj-x86_64-pc-linux-gnu/config.status is out of date with respect to /mnt/DATA/myff/mozilla-unified/obj-x86_64-pc-linux-gnu/.mozconfig.json 0:00.70 Using Python 3.11.2 from /home/xxxxxxxx/.mozbuild/srcdirs/mozilla-unified-f6869126bb36/_virtualenvs/build/bin/python 0:00.70 Adding configure options from /mnt/DATA/myff/mozilla-unified/mozconfig 0:00.70 --enable-artifact-builds 0:00.70 --enable-optimize 0:00.70 checking for vcs source checkout... hg 0:00.88 checking for a shell... /usr/bin/sh 0:00.91 checking for host system type... x86_64-pc-linux-gnu 0:00.91 checking for target system type... x86_64-pc-linux-gnu 0:00.98 checking whether cross compiling... no 0:01.06 Traceback (most recent call last): 0:01.06 File "/mnt/DATA/myff/mozilla-unified/configure.py", line 351, in <module> 0:01.06 sys.exit(main(sys.argv)) 0:01.06 ^^^^^^^^^^^^^^ 0:01.06 File "/mnt/DATA/myff/mozilla-unified/configure.py", line 141, in main 0:01.06 sandbox.run() 0:01.06 File "/mnt/DATA/myff/mozilla-unified/python/mozbuild/mozbuild/configure/__init__.py", line 518, in run 0:01.09 self._value_for(option) 0:01.09 File "/mnt/DATA/myff/mozilla-unified/python/mozbuild/mozbuild/configure/__init__.py", line 623, in _value_for 0:01.09 return self._value_for_option(obj) 0:01.09 ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 0:01.09 File "/mnt/DATA/myff/mozilla-unified/python/mozbuild/mozbuild/util.py", line 1070, in method_call 0:01.10 cache[args] = self.func(instance, *args) 0:01.10 ^^^^^^^^^^^^^^^^^^^^^^^^^^ 0:01.10 File "/mnt/DATA/myff/mozilla-unified/python/mozbuild/mozbuild/configure/__init__.py", line 690, in _value_for_option 0:01.10 raise InvalidOptionError( 0:01.10 mozbuild.configure.options.InvalidOptionError: --enable-optimize is not available in this configuration *** Fix above errors and then restart with "./mach build"
まさかのコンパイルエラーです。
もしや、mozconfig には 1行しか記述できないのでは?
ということで、mozconfig に --enable-optimize のみを指定して再実行してみると、先に進むことができました。
0:07.37 checking for libpulse... yes 0:07.37 checking MOZ_PULSEAUDIO_CFLAGS... -I/home/xxxxxxxx/.mozbuild/sysroot-x86_64-linux-gnu/usr/include -D_REENTRANT 0:07.37 checking MOZ_PULSEAUDIO_LIBS... -L/home/xxxxxxxx/.mozbuild/sysroot-x86_64-linux-gnu/usr/lib/x86_64-linux-gnu -lpulse 0:07.37 checking for rustc... /usr/bin/rustc 0:07.37 checking for cargo... /usr/bin/cargo 0:07.47 checking rustc version... 1.63.0 0:07.49 checking cargo version... 1.65.0 0:07.49 ERROR: Rust compiler 1.63.0 is too old. 0:07.49 To compile Rust language sources please install at least 0:07.49 version 1.70.0 of the 'rustc' toolchain (or, if using nightly, 0:07.49 at least one version newer than 1.70.0) and make sure it is 0:07.49 first in your path. 0:07.49 You can verify this by typing 'rustc --version'. 0:07.49 If you have the 'rustup' tool installed you can upgrade 0:07.49 to the latest release by typing 'rustup update'. The 0:07.49 installer is available from https://rustup.rs/ *** Fix above errors and then restart with "./mach build"
が、今度は rustc のバージョンが古いと怒られました。
LMDE 6 というか Debian 12 の rustc は 1.63 なのですよ。
rustup で最新化できるのかな。試してみましょう。
$ ~/.cargo/bin/rustup update info: syncing channel updates for 'stable-x86_64-unknown-linux-gnu' info: checking for self-update stable-x86_64-unknown-linux-gnu unchanged - rustc 1.74.1 (a28077b28 2023-12-04) info: cleaning up downloads & tmp directories
1.74 を見つけてくれるものの、インストールしてくれません。
ちょっと力尽きたので今日はここまで・・・・。