Emacsに来たnative compileを試す


Emacsのlispファイルをnativeでcompileする、いわゆる gccemacs が Masterブランチにマージされたので、さっそく試してみた。

https://git.savannah.gnu.org/cgit/emacs.git/commit/?id=289000eee729689b0cf362a21baa40ac7f9506f6

環境

Windows10のwsl2上のUbuntu 20.04.2 LTS (Focal Fossa)

ビルド

まずは前提となるパッケージをインストールする。

sudo apt install libgccjit-9-dev

次に最新のソースコードを取ってきてビルドする。

./autogen.sh
./configure --prefix=/usr/local --with-xwidgets --with-mailutils --with-native-compilation
make clean
make
sudo make install

特に詰まることもなく起動でき、以下のとおり NATIVE_COMP が有効になっていることが確認できた。

ビルド後にやったこと

(require 'cl) はするな系のエラーが大量に出てうっとうしかったので、 以下を early-init.el に入れて抑制した。

(custom-set-variables '(warning-suppress-types '((comp))))

ビルド後の確認

裏で package.el で取得したlisp群がnativeコンパイルされて、 ~/.emacs.d/eln-cache/ 配下に保管されていることを確認した。

elcファイルと違ってコンパイルされたELFファイルであることもわかる。

$ file ~/.emacs.d/elpa/all-the-icons-20210425.1035/all-the-icons.elc
/home/grugrut/.emacs.d/elpa/all-the-icons-20210425.1035/all-the-icons.elc: Emacs/XEmacs v27 byte-compiled Lisp data

$ file ~/.emacs.d/eln-cache/28.0.50-0e028d40/all-the-icons-e248ace1-2752b37c.eln
/home/grugrut/.emacs.d/eln-cache/28.0.50-0e028d40/all-the-icons-e248ace1-2752b37c.eln: ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically linked, BuildID[sha1]=305839e28b83cfac289c5e04a54cd2c92c318029, not stripped

See also

comments powered by Disqus